mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 13:16:07 +03: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 (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/xtls/xray-core/common"
|
||||
@ -12,7 +11,6 @@ import (
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/common/protocol"
|
||||
"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/features/routing"
|
||||
"github.com/xtls/xray-core/transport"
|
||||
@ -148,9 +146,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata,
|
||||
} else {
|
||||
if x.Status == Initializing { // nearly impossible
|
||||
XUDPManager.Unlock()
|
||||
if xudp.Show {
|
||||
fmt.Printf("XUDP hit: %v err: conflict\n", meta.GlobalID)
|
||||
}
|
||||
newError("XUDP hit ", meta.GlobalID).Base(errors.New("conflict")).AtWarning().WriteToLog(session.ExportIDToError(ctx))
|
||||
// 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.
|
||||
return nil
|
||||
@ -168,9 +164,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata,
|
||||
b.Release()
|
||||
mb = nil
|
||||
}
|
||||
if xudp.Show {
|
||||
fmt.Printf("XUDP hit: %v err: %v\n", meta.GlobalID, err)
|
||||
}
|
||||
newError("XUDP hit ", meta.GlobalID).Base(err).WriteToLog(session.ExportIDToError(ctx))
|
||||
}
|
||||
if mb != nil {
|
||||
ctx = session.ContextWithTimeoutOnly(ctx, true)
|
||||
@ -180,10 +174,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata,
|
||||
XUDPManager.Lock()
|
||||
delete(XUDPManager.Map, x.GlobalID)
|
||||
XUDPManager.Unlock()
|
||||
err = newError("failed to dispatch request to ", meta.Target).Base(err)
|
||||
if xudp.Show {
|
||||
fmt.Printf("XUDP new: %v err: %v\n", meta.GlobalID, err)
|
||||
}
|
||||
err = newError("XUDP new ", meta.GlobalID).Base(errors.New("failed to dispatch request to ", meta.Target).Base(err))
|
||||
return err // it will break the whole Mux connection
|
||||
}
|
||||
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,
|
||||
output: link.Writer,
|
||||
}
|
||||
if xudp.Show {
|
||||
fmt.Printf("XUDP new: %v err: %v\n", meta.GlobalID, err)
|
||||
}
|
||||
newError("XUDP new ", meta.GlobalID).Base(err).WriteToLog(session.ExportIDToError(ctx))
|
||||
}
|
||||
x.Mux = &Session{
|
||||
input: x.Mux.input,
|
||||
|
@ -1,7 +1,6 @@
|
||||
package mux
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"runtime"
|
||||
"sync"
|
||||
@ -11,7 +10,6 @@ import (
|
||||
"github.com/xtls/xray-core/common/buf"
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/common/protocol"
|
||||
"github.com/xtls/xray-core/common/xudp"
|
||||
"github.com/xtls/xray-core/transport/pipe"
|
||||
)
|
||||
|
||||
@ -182,9 +180,7 @@ func (s *Session) Close(locked bool) error {
|
||||
if s.XUDP.Status == Active {
|
||||
s.XUDP.Expire = time.Now().Add(time.Minute)
|
||||
s.XUDP.Status = Expiring
|
||||
if xudp.Show {
|
||||
fmt.Printf("XUDP put: %v\n", s.XUDP.GlobalID)
|
||||
}
|
||||
newError("XUDP put ", s.XUDP.GlobalID).AtDebug().WriteToLog()
|
||||
}
|
||||
XUDPManager.Unlock()
|
||||
}
|
||||
@ -234,9 +230,7 @@ func init() {
|
||||
if x.Status == Expiring && now.After(x.Expire) {
|
||||
x.Interrupt()
|
||||
delete(XUDPManager.Map, id)
|
||||
if xudp.Show {
|
||||
fmt.Printf("XUDP del: %v\n", id)
|
||||
}
|
||||
newError("XUDP del ", id).AtDebug().WriteToLog()
|
||||
}
|
||||
}
|
||||
XUDPManager.Unlock()
|
||||
|
@ -117,7 +117,6 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
||||
UDPOverride.Port = destination.Port
|
||||
}
|
||||
}
|
||||
newError("opening connection to ", destination).WriteToLog(session.ExportIDToError(ctx))
|
||||
|
||||
input := link.Reader
|
||||
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)
|
||||
}
|
||||
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 newCancel context.CancelFunc
|
||||
|
Loading…
Reference in New Issue
Block a user