1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-07 10:47:48 -05:00
v2fly/transport/internet/udp/hub_linux_test.go
2016-08-15 23:11:01 +02:00

41 lines
1.0 KiB
Go

// +build linux
package udp_test
import (
"syscall"
"testing"
"github.com/v2ray/v2ray-core/common/alloc"
v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/proxy"
"github.com/v2ray/v2ray-core/testing/assert"
"github.com/v2ray/v2ray-core/transport/internet/internal"
. "github.com/v2ray/v2ray-core/transport/internet/udp"
)
func TestHubSocksOption(t *testing.T) {
assert := assert.On(t)
hub, err := ListenUDP(v2net.LocalHostIP, v2net.Port(0), ListenOption{
Callback: func(*alloc.Buffer, *proxy.SessionInfo) {},
ReceiveOriginalDest: true,
})
assert.Error(err).IsNil()
conn := hub.Connection()
sysfd, err := internal.GetSysFd(conn)
assert.Error(err).IsNil()
fd, err := sysfd.SysFd()
assert.Error(err).IsNil()
v, err := syscall.GetsockoptInt(fd, syscall.SOL_IP, syscall.IP_TRANSPARENT)
assert.Error(err).IsNil()
assert.Int(v).Equals(1)
v, err = syscall.GetsockoptInt(fd, syscall.SOL_IP, syscall.IP_RECVORIGDSTADDR)
assert.Error(err).IsNil()
assert.Int(v).Equals(1)
}