mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-02-01 14:17:59 -05:00
fix test break
This commit is contained in:
parent
14c75e5035
commit
cee2fe4b6f
@ -42,7 +42,10 @@ type tcpWorker struct {
|
|||||||
func (w *tcpWorker) callback(conn internet.Connection) {
|
func (w *tcpWorker) callback(conn internet.Connection) {
|
||||||
ctx, cancel := context.WithCancel(w.ctx)
|
ctx, cancel := context.WithCancel(w.ctx)
|
||||||
if w.recvOrigDest {
|
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() {
|
if dest.IsValid() {
|
||||||
ctx = proxy.ContextWithOriginalTarget(ctx, dest)
|
ctx = proxy.ContextWithOriginalTarget(ctx, dest)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"v2ray.com/core/app/log"
|
|
||||||
v2net "v2ray.com/core/common/net"
|
v2net "v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/transport/internet"
|
"v2ray.com/core/transport/internet"
|
||||||
"v2ray.com/core/transport/internet/internal"
|
"v2ray.com/core/transport/internet/internal"
|
||||||
@ -14,19 +13,17 @@ import (
|
|||||||
|
|
||||||
const SO_ORIGINAL_DST = 80
|
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))
|
fd, err := internal.GetSysFd(conn.(net.Conn))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Trace(newError("failed to get original destination").Base(err))
|
return v2net.Destination{}, newError("failed to get original destination").Base(err)
|
||||||
return v2net.Destination{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, err := syscall.GetsockoptIPv6Mreq(fd, syscall.IPPROTO_IP, SO_ORIGINAL_DST)
|
addr, err := syscall.GetsockoptIPv6Mreq(fd, syscall.IPPROTO_IP, SO_ORIGINAL_DST)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Trace(newError("failed to call getsockopt").Base(err))
|
return v2net.Destination{}, newError("failed to call getsockopt").Base(err)
|
||||||
return v2net.Destination{}
|
|
||||||
}
|
}
|
||||||
ip := v2net.IPAddress(addr.Multiaddr[4:8])
|
ip := v2net.IPAddress(addr.Multiaddr[4:8])
|
||||||
port := uint16(addr.Multiaddr[2])<<8 + uint16(addr.Multiaddr[3])
|
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
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,6 @@ import (
|
|||||||
"v2ray.com/core/transport/internet"
|
"v2ray.com/core/transport/internet"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetOriginalDestination(conn internet.Connection) net.Destination {
|
func GetOriginalDestination(conn internet.Connection) (net.Destination, error) {
|
||||||
return net.Destination{}
|
return net.Destination{}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user