1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 18:06:15 -05:00
v2fly/transport/internet/tcp/sockopt_linux_test.go
2017-04-19 11:52:17 +02:00

30 lines
625 B
Go

// +build linux
package tcp_test
import (
"context"
"strings"
"testing"
"v2ray.com/core/testing/assert"
"v2ray.com/core/testing/servers/tcp"
. "v2ray.com/core/transport/internet/tcp"
)
func TestGetOriginalDestination(t *testing.T) {
assert := assert.On(t)
tcpServer := tcp.Server{}
dest, err := tcpServer.Start()
assert.Error(err).IsNil()
defer tcpServer.Close()
conn, err := Dial(context.Background(), dest)
assert.Error(err).IsNil()
defer conn.Close()
originalDest, err := GetOriginalDestination(conn)
assert.Bool(dest == originalDest || strings.Contains(err.Error(), "failed to call getsockopt"))
}