mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-10 06:16:53 -05:00
33 lines
716 B
Go
33 lines
716 B
Go
// +build linux
|
|
|
|
package tcp_test
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"v2ray.com/core/common"
|
|
"v2ray.com/core/testing/servers/tcp"
|
|
"v2ray.com/core/transport/internet"
|
|
. "v2ray.com/core/transport/internet/tcp"
|
|
)
|
|
|
|
func TestGetOriginalDestination(t *testing.T) {
|
|
tcpServer := tcp.Server{}
|
|
dest, err := tcpServer.Start()
|
|
common.Must(err)
|
|
defer tcpServer.Close()
|
|
|
|
config, err := internet.ToMemoryStreamConfig(nil)
|
|
common.Must(err)
|
|
conn, err := Dial(context.Background(), dest, config)
|
|
common.Must(err)
|
|
defer conn.Close()
|
|
|
|
originalDest, err := GetOriginalDestination(conn)
|
|
if !(dest == originalDest || strings.Contains(err.Error(), "failed to call getsockopt")) {
|
|
t.Error("unexpected state")
|
|
}
|
|
}
|