Documentation ¶
Overview ¶
Package net is a generated protocol buffer package.
It is generated from these files:
v2ray.com/core/common/net/address.proto v2ray.com/core/common/net/destination.proto v2ray.com/core/common/net/network.proto v2ray.com/core/common/net/port.proto
It has these top-level messages:
IPOrDomain Endpoint NetworkList PortRange
Package net contains common network utilities.
Index ¶
- Constants
- Variables
- type Address
- type AddressFamily
- type Destination
- type Endpoint
- type IPNet
- type IPOrDomain
- func (this *IPOrDomain) AsAddress() Address
- func (*IPOrDomain) Descriptor() ([]byte, []int)
- func (m *IPOrDomain) GetAddress() isIPOrDomain_Address
- func (m *IPOrDomain) GetDomain() string
- func (m *IPOrDomain) GetIp() []byte
- func (*IPOrDomain) ProtoMessage()
- func (m *IPOrDomain) Reset()
- func (m *IPOrDomain) String() string
- func (*IPOrDomain) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, ...)
- type IPOrDomain_Domain
- type IPOrDomain_Ip
- type Network
- type NetworkList
- type Port
- type PortRange
- type TimeOutReader
Constants ¶
const ( AddressFamilyIPv4 = AddressFamily(0) AddressFamilyIPv6 = AddressFamily(1) AddressFamilyDomain = AddressFamily(2) )
Variables ¶
var ( LocalHostIP = IPAddress([]byte{127, 0, 0, 1}) AnyIP = IPAddress([]byte{0, 0, 0, 0}) )
var ( // ErrInvalidPortRage indicates an error during port range parsing. ErrInvalidPortRange = errors.New("Invalid port range.") )
var Network_name = map[int32]string{
0: "Unknown",
1: "RawTCP",
2: "TCP",
3: "UDP",
4: "KCP",
5: "WebSocket",
}
var Network_value = map[string]int32{
"Unknown": 0,
"RawTCP": 1,
"TCP": 2,
"UDP": 3,
"KCP": 4,
"WebSocket": 5,
}
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address interface { IP() net.IP // IP of this Address Domain() string // Domain of this Address Family() AddressFamily String() string // String representation of this Address Equals(Address) bool }
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.
func DomainAddress ¶
DomainAddress creates an Address with given domain.
func ParseAddress ¶ added in v1.0.0
ParseAddress parses a string into an Address. The return value will be an IPAddress when the string is in the form of IPv4 or IPv6 address, or a DomainAddress otherwise.
type AddressFamily ¶ added in v1.0.0
type AddressFamily int
func (AddressFamily) Either ¶ added in v1.24.4
func (this AddressFamily) Either(fs ...AddressFamily) bool
func (AddressFamily) IsDomain ¶ added in v1.0.0
func (this AddressFamily) IsDomain() bool
func (AddressFamily) IsIPv4 ¶ added in v1.0.0
func (this AddressFamily) IsIPv4() bool
func (AddressFamily) IsIPv6 ¶ added in v1.0.0
func (this AddressFamily) IsIPv6() bool
type Destination ¶
Destination represents a network destination including address and protocol (tcp / udp).
func DestinationFromAddr ¶ added in v1.0.0
func DestinationFromAddr(addr net.Addr) Destination
func TCPDestination ¶
func TCPDestination(address Address, port Port) Destination
TCPDestination creates a TCP destination with given address
func UDPDestination ¶
func UDPDestination(address Address, port Port) Destination
UDPDestination creates a UDP destination with given address
func (Destination) Equals ¶ added in v1.13.1
func (this Destination) Equals(another Destination) bool
func (Destination) NetAddr ¶ added in v1.0.0
func (this Destination) NetAddr() string
func (Destination) String ¶
func (this Destination) String() string
type Endpoint ¶ added in v1.0.0
type Endpoint struct { Network Network `protobuf:"varint,1,opt,name=network,enum=v2ray.core.common.net.Network" json:"network,omitempty"` Address *IPOrDomain `protobuf:"bytes,2,opt,name=address" json:"address,omitempty"` Port uint32 `protobuf:"varint,3,opt,name=port" json:"port,omitempty"` }
func (*Endpoint) AsDestination ¶ added in v1.0.0
func (this *Endpoint) AsDestination() Destination
func (*Endpoint) Descriptor ¶ added in v1.0.0
func (*Endpoint) GetAddress ¶ added in v1.0.0
func (m *Endpoint) GetAddress() *IPOrDomain
func (*Endpoint) ProtoMessage ¶ added in v1.0.0
func (*Endpoint) ProtoMessage()
type IPOrDomain ¶ added in v1.0.0
type IPOrDomain struct { // Types that are valid to be assigned to Address: // *IPOrDomain_Ip // *IPOrDomain_Domain Address isIPOrDomain_Address `protobuf_oneof:"address"` }
func (*IPOrDomain) AsAddress ¶ added in v1.0.0
func (this *IPOrDomain) AsAddress() Address
func (*IPOrDomain) Descriptor ¶ added in v1.0.0
func (*IPOrDomain) Descriptor() ([]byte, []int)
func (*IPOrDomain) GetAddress ¶ added in v1.0.0
func (m *IPOrDomain) GetAddress() isIPOrDomain_Address
func (*IPOrDomain) GetDomain ¶ added in v1.0.0
func (m *IPOrDomain) GetDomain() string
func (*IPOrDomain) GetIp ¶ added in v1.0.0
func (m *IPOrDomain) GetIp() []byte
func (*IPOrDomain) ProtoMessage ¶ added in v1.0.0
func (*IPOrDomain) ProtoMessage()
func (*IPOrDomain) Reset ¶ added in v1.0.0
func (m *IPOrDomain) Reset()
func (*IPOrDomain) String ¶ added in v1.0.0
func (m *IPOrDomain) String() string
func (*IPOrDomain) XXX_OneofFuncs ¶
func (*IPOrDomain) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})
XXX_OneofFuncs is for the internal use of the proto package.
type IPOrDomain_Domain ¶ added in v1.0.0
type IPOrDomain_Domain struct {
Domain string `protobuf:"bytes,2,opt,name=domain,oneof"`
}
type IPOrDomain_Ip ¶ added in v1.0.0
type IPOrDomain_Ip struct {
Ip []byte `protobuf:"bytes,1,opt,name=ip,proto3,oneof"`
}
type Network ¶
type Network int32
func ParseNetwork ¶ added in v1.0.0
func (Network) AsList ¶ added in v1.13.1
func (this Network) AsList() *NetworkList
func (Network) EnumDescriptor ¶ added in v1.0.0
func (Network) SystemString ¶ added in v1.0.0
type NetworkList ¶
type NetworkList struct {
Network []Network `protobuf:"varint,1,rep,packed,name=network,enum=v2ray.core.common.net.Network" json:"network,omitempty"`
}
func (*NetworkList) Descriptor ¶ added in v1.0.0
func (*NetworkList) Descriptor() ([]byte, []int)
func (NetworkList) Get ¶
func (this NetworkList) Get(idx int) Network
func (NetworkList) HasNetwork ¶
func (this NetworkList) HasNetwork(network Network) bool
HashNetwork returns true if the given network is in this NetworkList.
func (*NetworkList) ProtoMessage ¶ added in v1.0.0
func (*NetworkList) ProtoMessage()
func (*NetworkList) Reset ¶ added in v1.0.0
func (m *NetworkList) Reset()
func (*NetworkList) String ¶ added in v1.0.0
func (m *NetworkList) String() string
type Port ¶ added in v1.0.0
type Port uint16
Port represents a network port in TCP and UDP protocol.
func PortFromBytes ¶ added in v1.0.0
PortFromBytes converts a byte array to a Port, assuming bytes are in big endian order. @unsafe Caller must ensure that the byte array has at least 2 elements.
func PortFromInt ¶ added in v1.0.0
PortFromInt converts an integer to a Port. @error when the integer is not positive or larger then 65535
func PortFromString ¶ added in v1.0.0
PortFromString converts a string to a Port. @error when the string is not an integer or the integral value is a not a valid Port.
func (Port) Bytes ¶ added in v1.13.1
Bytes returns the correspoding bytes of this Port, in big endian order.
type PortRange ¶
type PortRange struct { From uint32 `protobuf:"varint,1,opt,name=From" json:"From,omitempty"` To uint32 `protobuf:"varint,2,opt,name=To" json:"To,omitempty"` }
PortRange represents a range of ports.
func (PortRange) Contains ¶ added in v1.0.0
Contains returns true if the given port is within the range of this PortRange.
func (*PortRange) Descriptor ¶ added in v1.0.0
func (*PortRange) ProtoMessage ¶ added in v1.0.0
func (*PortRange) ProtoMessage()
type TimeOutReader ¶
type TimeOutReader struct {
// contains filtered or unexported fields
}
func NewTimeOutReader ¶
func NewTimeOutReader(timeout uint32, connection net.Conn) *TimeOutReader
func (*TimeOutReader) GetTimeOut ¶
func (reader *TimeOutReader) GetTimeOut() uint32
func (*TimeOutReader) Release ¶ added in v1.13.1
func (reader *TimeOutReader) Release()
func (*TimeOutReader) SetTimeOut ¶
func (reader *TimeOutReader) SetTimeOut(value uint32)