github.com/imannamdari/v2ray-core/v5@v5.0.5/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/imannamdari/v2ray-core/v5/common" 12 "github.com/imannamdari/v2ray-core/v5/testing/servers/tcp" 13 "github.com/imannamdari/v2ray-core/v5/transport/internet" 14 . "github.com/imannamdari/v2ray-core/v5/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 }