1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-23 02:26:49 -05:00
v2fly/transport/internet/tcp/sockopt_linux_test.go

30 lines
602 B
Go
Raw Normal View History

2017-04-18 06:02:43 -04:00
// +build linux
package tcp_test
import (
"context"
2017-04-19 05:52:17 -04:00
"strings"
2017-04-18 06:02:43 -04:00
"testing"
"v2ray.com/core/testing/servers/tcp"
2017-04-18 06:12:17 -04:00
. "v2ray.com/core/transport/internet/tcp"
2017-10-24 11:36:42 -04:00
. "v2ray.com/ext/assert"
2017-04-18 06:02:43 -04:00
)
func TestGetOriginalDestination(t *testing.T) {
2017-10-24 10:15:35 -04:00
assert := With(t)
2017-04-18 06:02:43 -04:00
2017-04-18 06:12:17 -04:00
tcpServer := tcp.Server{}
2017-04-18 06:02:43 -04:00
dest, err := tcpServer.Start()
2017-10-24 10:15:35 -04:00
assert(err, IsNil)
2017-04-18 06:02:43 -04:00
defer tcpServer.Close()
2017-04-18 07:02:42 -04:00
conn, err := Dial(context.Background(), dest)
2017-10-24 10:15:35 -04:00
assert(err, IsNil)
2017-04-18 06:12:17 -04:00
defer conn.Close()
2017-04-18 06:02:43 -04:00
2017-04-19 05:52:17 -04:00
originalDest, err := GetOriginalDestination(conn)
2017-10-24 11:36:42 -04:00
assert(dest == originalDest || strings.Contains(err.Error(), "failed to call getsockopt"), IsTrue)
2017-04-18 06:02:43 -04:00
}