1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-05-23 20:59:08 -04:00

more docs

This commit is contained in:
V2 Ray
2015-09-21 10:15:25 +00:00
parent e4b6d5e0f0
commit 313aec4097
3 changed files with 23 additions and 15 deletions

View File

@@ -7,15 +7,16 @@ import (
"github.com/v2ray/v2ray-core/common/log"
)
// Address represents a network address to be communicated with. It may be an IP address or domain address, not both. This interface doesn't resolve IP address for a given domain.
// Address represents a network address to be communicated with. It may be an IP address or domain
// address, not both. This interface doesn't resolve IP address for a given domain.
type Address interface {
IP() net.IP // IP of this Address
Domain() string // Domain of this Address
Port() uint16 // Port of this Address
IP() net.IP // IP of this Address
Domain() string // Domain of this Address
Port() uint16 // Port of this Address
PortBytes() []byte // Port in bytes, network byte order
IsIPv4() bool // True if this Address is an IPv4 address
IsIPv6() bool // True if this Address is an IPv6 address
IsIPv4() bool // True if this Address is an IPv4 address
IsIPv6() bool // True if this Address is an IPv6 address
IsDomain() bool // True if this Address is an domain address
String() string // String representation of this Address
@@ -32,10 +33,12 @@ func IPAddress(ip []byte, port uint16) Address {
case net.IPv6len:
return IPv6Address{
PortAddress: PortAddress{port: port},
ip: [16]byte{ip[0], ip[1], ip[2], ip[3],
ip[4], ip[5], ip[6], ip[7],
ip[8], ip[9], ip[10], ip[11],
ip[12], ip[13], ip[14], ip[15]},
ip: [16]byte{
ip[0], ip[1], ip[2], ip[3],
ip[4], ip[5], ip[6], ip[7],
ip[8], ip[9], ip[10], ip[11],
ip[12], ip[13], ip[14], ip[15],
},
}
default:
panic(log.Error("Unknown IP format: %v", ip))