dice.Roll()

This commit is contained in:
v2ray committed 2016-01-21 22:45:44 +01:00
1 parent d623b1809d
commit 37a9d8ef50
6 files changed
+23 -36

No files matched your search

+2 -6
View File
@@ -2,9 +2,9 @@ package dialer
import (
"errors"
"math/rand"
"net"
"github.com/v2ray/v2ray-core/common/dice"
v2net "github.com/v2ray/v2ray-core/common/net"
)
@@ -24,11 +24,7 @@ func Dial(dest v2net.Destination) (net.Conn, error) {
if len(ips) == 0 {
return nil, ErrInvalidHost
}
if len(ips) == 1 {
ip = ips[0]
} else {
ip = ips[rand.Intn(len(ips))]
}
ip = ips[dice.Roll(len(ips))]
}
if dest.IsTCP() {
return net.DialTCP("tcp", nil, &net.TCPAddr{
+1
View File
@@ -19,6 +19,7 @@ func TestDialDomain(t *testing.T) {
}
dest, err := server.Start()
assert.Error(err).IsNil()
defer server.Close()
conn, err := Dial(v2net.TCPDestination(v2net.DomainAddress("local.v2ray.com"), dest.Port()))
assert.Error(err).IsNil()