mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 12:49:20 +02:00
Amend XUDP related logs
- Useful for debug XUDP improvements - Move XUDP log in core log - Freedom connection log show local port
This commit is contained in:
parent
76b27a37cb
commit
05d24d6827
|
@ -2,7 +2,6 @@ package mux
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
|
@ -12,7 +11,6 @@ import (
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/protocol"
|
"github.com/xtls/xray-core/common/protocol"
|
||||||
"github.com/xtls/xray-core/common/session"
|
"github.com/xtls/xray-core/common/session"
|
||||||
"github.com/xtls/xray-core/common/xudp"
|
|
||||||
"github.com/xtls/xray-core/core"
|
"github.com/xtls/xray-core/core"
|
||||||
"github.com/xtls/xray-core/features/routing"
|
"github.com/xtls/xray-core/features/routing"
|
||||||
"github.com/xtls/xray-core/transport"
|
"github.com/xtls/xray-core/transport"
|
||||||
|
@ -148,9 +146,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata,
|
||||||
} else {
|
} else {
|
||||||
if x.Status == Initializing { // nearly impossible
|
if x.Status == Initializing { // nearly impossible
|
||||||
XUDPManager.Unlock()
|
XUDPManager.Unlock()
|
||||||
if xudp.Show {
|
newError("XUDP hit ", meta.GlobalID).Base(errors.New("conflict")).AtWarning().WriteToLog(session.ExportIDToError(ctx))
|
||||||
fmt.Printf("XUDP hit: %v err: conflict\n", meta.GlobalID)
|
|
||||||
}
|
|
||||||
// It's not a good idea to return an err here, so just let client wait.
|
// It's not a good idea to return an err here, so just let client wait.
|
||||||
// Client will receive an End frame after sending a Keep frame.
|
// Client will receive an End frame after sending a Keep frame.
|
||||||
return nil
|
return nil
|
||||||
|
@ -168,9 +164,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata,
|
||||||
b.Release()
|
b.Release()
|
||||||
mb = nil
|
mb = nil
|
||||||
}
|
}
|
||||||
if xudp.Show {
|
newError("XUDP hit ", meta.GlobalID).Base(err).WriteToLog(session.ExportIDToError(ctx))
|
||||||
fmt.Printf("XUDP hit: %v err: %v\n", meta.GlobalID, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if mb != nil {
|
if mb != nil {
|
||||||
ctx = session.ContextWithTimeoutOnly(ctx, true)
|
ctx = session.ContextWithTimeoutOnly(ctx, true)
|
||||||
|
@ -180,10 +174,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata,
|
||||||
XUDPManager.Lock()
|
XUDPManager.Lock()
|
||||||
delete(XUDPManager.Map, x.GlobalID)
|
delete(XUDPManager.Map, x.GlobalID)
|
||||||
XUDPManager.Unlock()
|
XUDPManager.Unlock()
|
||||||
err = newError("failed to dispatch request to ", meta.Target).Base(err)
|
err = newError("XUDP new ", meta.GlobalID).Base(errors.New("failed to dispatch request to ", meta.Target).Base(err))
|
||||||
if xudp.Show {
|
|
||||||
fmt.Printf("XUDP new: %v err: %v\n", meta.GlobalID, err)
|
|
||||||
}
|
|
||||||
return err // it will break the whole Mux connection
|
return err // it will break the whole Mux connection
|
||||||
}
|
}
|
||||||
link.Writer.WriteMultiBuffer(mb) // it's meaningless to test a new pipe
|
link.Writer.WriteMultiBuffer(mb) // it's meaningless to test a new pipe
|
||||||
|
@ -191,9 +182,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata,
|
||||||
input: link.Reader,
|
input: link.Reader,
|
||||||
output: link.Writer,
|
output: link.Writer,
|
||||||
}
|
}
|
||||||
if xudp.Show {
|
newError("XUDP new ", meta.GlobalID).Base(err).WriteToLog(session.ExportIDToError(ctx))
|
||||||
fmt.Printf("XUDP new: %v err: %v\n", meta.GlobalID, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
x.Mux = &Session{
|
x.Mux = &Session{
|
||||||
input: x.Mux.input,
|
input: x.Mux.input,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package mux
|
package mux
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -11,7 +10,6 @@ import (
|
||||||
"github.com/xtls/xray-core/common/buf"
|
"github.com/xtls/xray-core/common/buf"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/protocol"
|
"github.com/xtls/xray-core/common/protocol"
|
||||||
"github.com/xtls/xray-core/common/xudp"
|
|
||||||
"github.com/xtls/xray-core/transport/pipe"
|
"github.com/xtls/xray-core/transport/pipe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -182,9 +180,7 @@ func (s *Session) Close(locked bool) error {
|
||||||
if s.XUDP.Status == Active {
|
if s.XUDP.Status == Active {
|
||||||
s.XUDP.Expire = time.Now().Add(time.Minute)
|
s.XUDP.Expire = time.Now().Add(time.Minute)
|
||||||
s.XUDP.Status = Expiring
|
s.XUDP.Status = Expiring
|
||||||
if xudp.Show {
|
newError("XUDP put ", s.XUDP.GlobalID).AtDebug().WriteToLog()
|
||||||
fmt.Printf("XUDP put: %v\n", s.XUDP.GlobalID)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
XUDPManager.Unlock()
|
XUDPManager.Unlock()
|
||||||
}
|
}
|
||||||
|
@ -234,9 +230,7 @@ func init() {
|
||||||
if x.Status == Expiring && now.After(x.Expire) {
|
if x.Status == Expiring && now.After(x.Expire) {
|
||||||
x.Interrupt()
|
x.Interrupt()
|
||||||
delete(XUDPManager.Map, id)
|
delete(XUDPManager.Map, id)
|
||||||
if xudp.Show {
|
newError("XUDP del ", id).AtDebug().WriteToLog()
|
||||||
fmt.Printf("XUDP del: %v\n", id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XUDPManager.Unlock()
|
XUDPManager.Unlock()
|
||||||
|
|
|
@ -117,7 +117,6 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
||||||
UDPOverride.Port = destination.Port
|
UDPOverride.Port = destination.Port
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newError("opening connection to ", destination).WriteToLog(session.ExportIDToError(ctx))
|
|
||||||
|
|
||||||
input := link.Reader
|
input := link.Reader
|
||||||
output := link.Writer
|
output := link.Writer
|
||||||
|
@ -148,6 +147,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
||||||
return newError("failed to open connection to ", destination).Base(err)
|
return newError("failed to open connection to ", destination).Base(err)
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
newError("connection opened to ", destination, ", local endpoint ", conn.LocalAddr(), ", remote endpoint ", conn.RemoteAddr()).WriteToLog(session.ExportIDToError(ctx))
|
||||||
|
|
||||||
var newCtx context.Context
|
var newCtx context.Context
|
||||||
var newCancel context.CancelFunc
|
var newCancel context.CancelFunc
|
||||||
|
|
Loading…
Reference in New Issue