1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-28 14:56:33 -04:00
This commit is contained in:
Darien Raymond 2018-07-03 16:56:57 +02:00
parent 2a07ead0dc
commit 07e2592117
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 9 additions and 4 deletions

View File

@ -3,11 +3,10 @@ package protocol
import (
"io"
"v2ray.com/core/common/task"
"v2ray.com/core/common"
"v2ray.com/core/common/buf"
"v2ray.com/core/common/net"
"v2ray.com/core/common/task"
)
type AddressOption func(*AddressParser)
@ -110,7 +109,7 @@ func (p *AddressParser) readAddress(b *buf.Buffer, reader io.Reader) (net.Addres
domain := string(b.BytesFrom(-domainLength))
if maybeIPPrefix(domain[0]) {
addr := net.ParseAddress(domain)
if addr.Family().IsIPv4() || addrFamily.IsIPv6() {
if addr.Family().IsIPv4() || addr.Family().IsIPv6() {
return addr, nil
}
}

View File

@ -69,6 +69,12 @@ func TestAddressReading(t *testing.T) {
Input: []byte{3, 7, 10, 46, 56, 46, 56, 46, 56, 0, 80},
Error: true,
},
{
Options: []AddressOption{AddressFamilyByte(0x03, net.AddressFamilyDomain)},
Input: append(append([]byte{3, 24}, []byte("2a00:1450:4007:816::200e")...), 0, 80),
Address: net.ParseAddress("2a00:1450:4007:816::200e"),
Port: net.Port(80),
},
}
for _, tc := range data {
@ -79,9 +85,9 @@ func TestAddressReading(t *testing.T) {
if tc.Error {
assert(err, IsNotNil)
} else {
assert(err, IsNil)
assert(addr, Equals, tc.Address)
assert(port, Equals, tc.Port)
assert(err, IsNil)
}
}
}