1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-19 10:56:06 -05:00
v2fly/transport/internet/tcp/sockopt_linux_test.go

34 lines
797 B
Go
Raw Normal View History

//go:build linux
2017-04-18 06:02:43 -04:00
// +build linux
package tcp_test
import (
"context"
2017-04-19 05:52:17 -04:00
"strings"
2017-04-18 06:02:43 -04:00
"testing"
"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/testing/servers/tcp"
"github.com/v2fly/v2ray-core/v5/transport/internet"
. "github.com/v2fly/v2ray-core/v5/transport/internet/tcp"
2017-04-18 06:02:43 -04:00
)
func TestGetOriginalDestination(t *testing.T) {
2017-04-18 06:12:17 -04:00
tcpServer := tcp.Server{}
2017-04-18 06:02:43 -04:00
dest, err := tcpServer.Start()
2019-02-02 16:19:30 -05:00
common.Must(err)
2017-04-18 06:02:43 -04:00
defer tcpServer.Close()
2018-11-22 11:30:06 -05:00
config, err := internet.ToMemoryStreamConfig(nil)
common.Must(err)
conn, err := Dial(context.Background(), dest, config)
2019-02-02 16:19:30 -05:00
common.Must(err)
2017-04-18 06:12:17 -04:00
defer conn.Close()
2017-04-18 06:02:43 -04:00
2017-04-19 05:52:17 -04:00
originalDest, err := GetOriginalDestination(conn)
2019-02-03 13:46:53 -05:00
if !(dest == originalDest || strings.Contains(err.Error(), "failed to call getsockopt")) {
t.Error("unexpected state")
}
2017-04-18 06:02:43 -04:00
}