2017-04-18 06:02:43 -04:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package tcp_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"v2ray.com/core/testing/assert"
|
|
|
|
"v2ray.com/core/testing/servers/tcp"
|
2017-04-18 06:12:17 -04:00
|
|
|
. "v2ray.com/core/transport/internet/tcp"
|
2017-04-18 06:02:43 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetOriginalDestination(t *testing.T) {
|
|
|
|
assert := assert.On(t)
|
|
|
|
|
2017-04-18 06:12:17 -04:00
|
|
|
tcpServer := tcp.Server{}
|
2017-04-18 06:02:43 -04:00
|
|
|
dest, err := tcpServer.Start()
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
defer tcpServer.Close()
|
|
|
|
|
|
|
|
conn, err := Dial(context.Background(), dest)
|
|
|
|
assert.Error(err).IsNil()
|
2017-04-18 06:12:17 -04:00
|
|
|
defer conn.Close()
|
2017-04-18 06:02:43 -04:00
|
|
|
|
2017-04-18 06:20:46 -04:00
|
|
|
_, err = GetOriginalDestination(conn)
|
2017-04-18 06:02:43 -04:00
|
|
|
assert.String(err.Error()).Contains("failed to call getsockopt")
|
|
|
|
}
|