1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 18:06:15 -05:00
v2fly/transport/internet/dialer_test.go

26 lines
575 B
Go
Raw Normal View History

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