add context for conn
This commit is contained in:
@@ -15,7 +15,8 @@ import (
|
||||
"github.com/go-gost/core/observer/stats"
|
||||
"github.com/go-gost/relay"
|
||||
xbypass "github.com/go-gost/x/bypass"
|
||||
ctxvalue "github.com/go-gost/x/ctx"
|
||||
xctx "github.com/go-gost/x/ctx"
|
||||
ictx "github.com/go-gost/x/internal/ctx"
|
||||
xnet "github.com/go-gost/x/internal/net"
|
||||
serial "github.com/go-gost/x/internal/util/serial"
|
||||
"github.com/go-gost/x/internal/util/sniffing"
|
||||
@@ -40,7 +41,7 @@ func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network
|
||||
log.Debugf("%s >> %s/%s", conn.RemoteAddr(), address, network)
|
||||
|
||||
{
|
||||
clientID := ctxvalue.ClientIDFromContext(ctx)
|
||||
clientID := xctx.ClientIDFromContext(ctx)
|
||||
rw := traffic_wrapper.WrapReadWriter(
|
||||
h.limiter,
|
||||
conn,
|
||||
@@ -85,7 +86,7 @@ func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network
|
||||
|
||||
switch h.md.hash {
|
||||
case "host":
|
||||
ctx = ctxvalue.ContextWithHash(ctx, &ctxvalue.Hash{Source: address})
|
||||
ctx = xctx.ContextWithHash(ctx, &xctx.Hash{Source: address})
|
||||
}
|
||||
|
||||
var cc net.Conn
|
||||
@@ -103,7 +104,7 @@ func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network
|
||||
}
|
||||
default:
|
||||
var buf bytes.Buffer
|
||||
cc, err = h.options.Router.Dial(ctxvalue.ContextWithBuffer(ctx, &buf), network, address)
|
||||
cc, err = h.options.Router.Dial(ictx.ContextWithBuffer(ctx, &buf), network, address)
|
||||
ro.Route = buf.String()
|
||||
}
|
||||
if err != nil {
|
||||
@@ -114,8 +115,8 @@ func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network
|
||||
defer cc.Close()
|
||||
|
||||
log = log.WithFields(map[string]any{"src": cc.LocalAddr().String(), "dst": cc.RemoteAddr().String()})
|
||||
ro.Src = cc.LocalAddr().String()
|
||||
ro.Dst = cc.RemoteAddr().String()
|
||||
ro.SrcAddr = cc.LocalAddr().String()
|
||||
ro.DstAddr = cc.RemoteAddr().String()
|
||||
|
||||
if h.md.noDelay {
|
||||
if _, err := resp.WriteTo(conn); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user