1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-04-21 21:19:12 -04:00

handle switch account command in vmess out

This commit is contained in:
v2ray
2016-01-20 17:31:43 +01:00
parent b0adb24003
commit baaef1dad5
12 changed files with 253 additions and 52 deletions

View File

@@ -17,6 +17,7 @@ type Address interface {
IsDomain() bool // True if this Address is an domain address
String() string // String representation of this Address
Equals(Address) bool
}
func ParseAddress(addr string) Address {
@@ -91,6 +92,17 @@ func (this *IPv4Address) String() string {
return this.IP().String()
}
func (this *IPv4Address) Equals(another Address) bool {
anotherIPv4, ok := another.(*IPv4Address)
if !ok {
return false
}
return this[0] == anotherIPv4[0] &&
this[1] == anotherIPv4[1] &&
this[2] == anotherIPv4[2] &&
this[3] == anotherIPv4[3]
}
type IPv6Address [16]byte
func (addr *IPv6Address) IP() net.IP {
@@ -117,6 +129,19 @@ func (this *IPv6Address) String() string {
return "[" + this.IP().String() + "]"
}
func (this *IPv6Address) Equals(another Address) bool {
anotherIPv6, ok := another.(*IPv6Address)
if !ok {
return false
}
for idx, v := range *this {
if anotherIPv6[idx] != v {
return false
}
}
return true
}
type DomainAddressImpl string
func (addr *DomainAddressImpl) IP() net.IP {
@@ -142,3 +167,11 @@ func (addr *DomainAddressImpl) IsDomain() bool {
func (this *DomainAddressImpl) String() string {
return this.Domain()
}
func (this *DomainAddressImpl) Equals(another Address) bool {
anotherDomain, ok := another.(*DomainAddressImpl)
if !ok {
return false
}
return this.Domain() == anotherDomain.Domain()
}