mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 23:47:07 -05:00
fix #1181
This commit is contained in:
parent
2a07ead0dc
commit
07e2592117
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user