diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 307fba159..2ffb6cdf7 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -42,7 +42,10 @@ type tcpWorker struct { func (w *tcpWorker) callback(conn internet.Connection) { ctx, cancel := context.WithCancel(w.ctx) if w.recvOrigDest { - dest := tcp.GetOriginalDestination(conn) + dest, err := tcp.GetOriginalDestination(conn) + if err != nil { + log.Trace(newError("failed to get original destination").Base(err)) + } if dest.IsValid() { ctx = proxy.ContextWithOriginalTarget(ctx, dest) } diff --git a/transport/internet/tcp/sockopt_linux.go b/transport/internet/tcp/sockopt_linux.go index 29aeb4c31..10b88d209 100644 --- a/transport/internet/tcp/sockopt_linux.go +++ b/transport/internet/tcp/sockopt_linux.go @@ -6,7 +6,6 @@ import ( "net" "syscall" - "v2ray.com/core/app/log" v2net "v2ray.com/core/common/net" "v2ray.com/core/transport/internet" "v2ray.com/core/transport/internet/internal" @@ -14,19 +13,17 @@ import ( const SO_ORIGINAL_DST = 80 -func GetOriginalDestination(conn internet.Connection) v2net.Destination { +func GetOriginalDestination(conn internet.Connection) (v2net.Destination, error) { fd, err := internal.GetSysFd(conn.(net.Conn)) if err != nil { - log.Trace(newError("failed to get original destination").Base(err)) - return v2net.Destination{} + return v2net.Destination{}, newError("failed to get original destination").Base(err) } addr, err := syscall.GetsockoptIPv6Mreq(fd, syscall.IPPROTO_IP, SO_ORIGINAL_DST) if err != nil { - log.Trace(newError("failed to call getsockopt").Base(err)) - return v2net.Destination{} + return v2net.Destination{}, newError("failed to call getsockopt").Base(err) } ip := v2net.IPAddress(addr.Multiaddr[4:8]) port := uint16(addr.Multiaddr[2])<<8 + uint16(addr.Multiaddr[3]) - return v2net.TCPDestination(ip, v2net.Port(port)) + return v2net.TCPDestination(ip, v2net.Port(port)), nil } diff --git a/transport/internet/tcp/sockopt_other.go b/transport/internet/tcp/sockopt_other.go index 3c0fbf109..5f3e5d147 100644 --- a/transport/internet/tcp/sockopt_other.go +++ b/transport/internet/tcp/sockopt_other.go @@ -7,6 +7,6 @@ import ( "v2ray.com/core/transport/internet" ) -func GetOriginalDestination(conn internet.Connection) net.Destination { - return net.Destination{} +func GetOriginalDestination(conn internet.Connection) (net.Destination, error) { + return net.Destination{}, nil }