1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00
v2fly/transport/internet/tcp/sockopt_linux_test.go
database64128 c78ee5aac7
🏡 Housekeeping: Update to Go 1.17 (#1215)
* ⬆ Update to Go 1.17

* 🏗 Update workflows and add windows-arm64

* 💾 Update generated files

* 📛 Update not-so-friendly filenames
2021-08-21 13:20:40 +08:00

34 lines
797 B
Go

//go:build linux
// +build linux
package tcp_test
import (
"context"
"strings"
"testing"
"github.com/v2fly/v2ray-core/v4/common"
"github.com/v2fly/v2ray-core/v4/testing/servers/tcp"
"github.com/v2fly/v2ray-core/v4/transport/internet"
. "github.com/v2fly/v2ray-core/v4/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")
}
}