1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-02-20 23:47:21 -05:00
v2fly/transport/internet/dialer_test.go

26 lines
575 B
Go
Raw Normal View History

2016-06-14 22:54:08 +02:00
package internet_test
2016-01-21 12:18:37 +00:00
import (
2017-04-09 00:54:07 +02:00
"context"
2016-01-21 12:18:37 +00:00
"testing"
2017-01-14 00:27:45 +01:00
"v2ray.com/core/common/net"
2016-08-20 20:55:45 +02:00
"v2ray.com/core/testing/servers/tcp"
. "v2ray.com/core/transport/internet"
2017-10-26 21:44:22 +02:00
. "v2ray.com/ext/assert"
2016-01-21 12:18:37 +00:00
)
2016-06-04 00:38:22 +02:00
func TestDialWithLocalAddr(t *testing.T) {
2017-10-24 16:15:35 +02:00
assert := With(t)
2016-06-04 00:38:22 +02:00
2016-08-15 22:12:11 +02:00
server := &tcp.Server{}
2016-06-04 00:38:22 +02:00
dest, err := server.Start()
2017-10-24 16:15:35 +02:00
assert(err, IsNil)
2016-06-04 00:38:22 +02:00
defer server.Close()
2017-02-23 23:48:47 +01:00
conn, err := DialSystem(context.Background(), net.LocalHostIP, net.TCPDestination(net.LocalHostIP, dest.Port))
2017-10-24 16:15:35 +02:00
assert(err, IsNil)
2017-10-26 21:44:22 +02:00
assert(conn.RemoteAddr().String(), Equals, "127.0.0.1:"+dest.Port.String())
2016-01-21 12:18:37 +00:00
conn.Close()
}