mirror of https://github.com/v2ray/v2ray-core
fix build for linux
parent
2668954c12
commit
954587cdc9
|
@ -6,6 +6,7 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"v2ray.com/core/app/log"
|
"v2ray.com/core/app/log"
|
||||||
|
"v2ray.com/core/common/errors"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/transport/internet"
|
"v2ray.com/core/transport/internet"
|
||||||
)
|
)
|
||||||
|
@ -15,18 +16,18 @@ const SO_ORIGINAL_DST = 80
|
||||||
func GetOriginalDestination(conn internet.Connection) net.Destination {
|
func GetOriginalDestination(conn internet.Connection) net.Destination {
|
||||||
tcpConn, ok := conn.(internet.SysFd)
|
tcpConn, ok := conn.(internet.SysFd)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Trace(errors.New("Dokodemo: Failed to get sys fd."))
|
log.Trace(errors.New("failed to get sys fd").Path("Transport", "Internet", "TCP"))
|
||||||
return net.Destination{}
|
return net.Destination{}
|
||||||
}
|
}
|
||||||
fd, err := tcpConn.SysFd()
|
fd, err := tcpConn.SysFd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Trace(errors.New("Dokodemo: Failed to get original destination: ", err))
|
log.Trace(errors.New("failed to get original destination").Base(err).Path("Transport", "Internet", "TCP"))
|
||||||
return net.Destination{}
|
return net.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(errors.New("Dokodemo: Failed to call getsockopt: ", err))
|
log.Trace(errors.New("failed to call getsockopt").Base(err).Path("Transport", "Internet", "TCP"))
|
||||||
return net.Destination{}
|
return net.Destination{}
|
||||||
}
|
}
|
||||||
ip := net.IPAddress(addr.Multiaddr[4:8])
|
ip := net.IPAddress(addr.Multiaddr[4:8])
|
||||||
|
|
Loading…
Reference in New Issue