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