github.com/EagleQL/Xray-core@v1.4.3/transport/internet/tcp/sockopt_linux_test.go (about) 1 // +build linux 2 3 package tcp_test 4 5 import ( 6 "context" 7 "strings" 8 "testing" 9 10 "github.com/xtls/xray-core/common" 11 "github.com/xtls/xray-core/testing/servers/tcp" 12 "github.com/xtls/xray-core/transport/internet" 13 . "github.com/xtls/xray-core/transport/internet/tcp" 14 ) 15 16 func TestGetOriginalDestination(t *testing.T) { 17 tcpServer := tcp.Server{} 18 dest, err := tcpServer.Start() 19 common.Must(err) 20 defer tcpServer.Close() 21 22 config, err := internet.ToMemoryStreamConfig(nil) 23 common.Must(err) 24 conn, err := Dial(context.Background(), dest, config) 25 common.Must(err) 26 defer conn.Close() 27 28 originalDest, err := GetOriginalDestination(conn) 29 if !(dest == originalDest || strings.Contains(err.Error(), "failed to call getsockopt")) { 30 t.Error("unexpected state") 31 } 32 }