sniffing protocol for port forwarding

This commit is contained in:
ginuerzh
2022-11-30 10:54:19 +08:00
parent 5f31240e29
commit 2e89811d59
9 changed files with 46 additions and 9 deletions

View File

@ -84,14 +84,18 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand
var rw io.ReadWriter = conn
var host string
var protocol string
if h.md.sniffing {
if network == "tcp" {
rw, host, _ = forward.SniffHost(ctx, conn)
rw, host, protocol, _ = forward.Sniffing(ctx, conn)
}
}
var target *chain.Node
if h.hop != nil {
target = h.hop.Select(ctx, chain.HostSelectOption(host))
target = h.hop.Select(ctx,
chain.HostSelectOption(host),
chain.ProtocolSelectOption(protocol),
)
}
if target == nil {
err := errors.New("target not available")