1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-28 10:15:23 +00:00
v2fly/transport/internet/dialer_test.go

26 lines
575 B
Go
Raw Normal View History

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