1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-07 10:47:48 -05:00
v2fly/transport/internet/tcp/sockopt_linux_test.go

33 lines
716 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"
2018-11-22 11:30:06 -05:00
"v2ray.com/core/common"
2017-04-18 06:02:43 -04:00
"v2ray.com/core/testing/servers/tcp"
2018-11-22 11:19:24 -05:00
"v2ray.com/core/transport/internet"
2017-04-18 06:12:17 -04:00
. "v2ray.com/core/transport/internet/tcp"
2017-04-18 06:02:43 -04:00
)
func TestGetOriginalDestination(t *testing.T) {
2017-04-18 06:12:17 -04:00
tcpServer := tcp.Server{}
2017-04-18 06:02:43 -04:00
dest, err := tcpServer.Start()
2019-02-02 16:19:30 -05:00
common.Must(err)
2017-04-18 06:02:43 -04:00
defer tcpServer.Close()
2018-11-22 11:30:06 -05:00
config, err := internet.ToMemoryStreamConfig(nil)
common.Must(err)
conn, err := Dial(context.Background(), dest, config)
2019-02-02 16:19:30 -05:00
common.Must(err)
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)
2019-02-03 13:46:53 -05:00
if !(dest == originalDest || strings.Contains(err.Error(), "failed to call getsockopt")) {
t.Error("unexpected state")
}
2017-04-18 06:02:43 -04:00
}