1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-09-29 21:54:10 -04:00

proto for destination

This commit is contained in:
Darien Raymond
2016-09-20 11:53:05 +02:00
parent c518726910
commit 7de7588ec2
35 changed files with 170 additions and 195 deletions

View File

@@ -16,18 +16,18 @@ func GetOriginalDestination(conn internet.Connection) v2net.Destination {
tcpConn, ok := conn.(internet.SysFd)
if !ok {
log.Info("Dokodemo: Failed to get sys fd.")
return nil
return v2net.Destination{}
}
fd, err := tcpConn.SysFd()
if err != nil {
log.Info("Dokodemo: Failed to get original destination: ", err)
return nil
return v2net.Destination{}
}
addr, err := syscall.GetsockoptIPv6Mreq(fd, syscall.IPPROTO_IP, SO_ORIGINAL_DST)
if err != nil {
log.Info("Dokodemo: Failed to call getsockopt: ", err)
return nil
return v2net.Destination{}
}
ip := v2net.IPAddress(addr.Multiaddr[4:8])
port := uint16(addr.Multiaddr[2])<<8 + uint16(addr.Multiaddr[3])