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/port.proto
It has these top-level messages:
AddressPB PortRange
Package net contains common network utilities.
Index ¶
- Constants
- Variables
- type Address
- type AddressFamily
- type AddressPB
- func (this *AddressPB) AsAddress() Address
- func (*AddressPB) Descriptor() ([]byte, []int)
- func (m *AddressPB) GetAddress() isAddressPB_Address
- func (m *AddressPB) GetDomain() string
- func (m *AddressPB) GetIp() []byte
- func (*AddressPB) ProtoMessage()
- func (m *AddressPB) Reset()
- func (m *AddressPB) String() string
- func (*AddressPB) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, ...)
- type AddressPB_Domain
- type AddressPB_Ip
- type Destination
- type IPNet
- type Network
- type NetworkList
- type Port
- type PortRange
- type TimeOutReader
Constants ¶
const ( AddressFamilyIPv4 = AddressFamily(0) AddressFamilyIPv6 = AddressFamily(1) AddressFamilyDomain = AddressFamily(2) )
const ( // TCPNetwork represents the TCP network. TCPNetwork = Network("tcp") // UDPNetwork represents the UDP network. UDPNetwork = Network("udp") // KCPNetwork represents the KCP network. KCPNetwork = Network("kcp") // WSNetwork represents the Websocket over HTTP network. WSNetwork = Network("ws") )
Variables ¶
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.
type AddressFamily ¶ added in v1.24.1
type AddressFamily int
func (AddressFamily) Either ¶ added in v1.24.1
func (this AddressFamily) Either(fs ...AddressFamily) bool
func (AddressFamily) IsDomain ¶ added in v1.24.1
func (this AddressFamily) IsDomain() bool
func (AddressFamily) IsIPv4 ¶ added in v1.24.1
func (this AddressFamily) IsIPv4() bool
func (AddressFamily) IsIPv6 ¶ added in v1.24.1
func (this AddressFamily) IsIPv6() bool
type AddressPB ¶
type AddressPB struct { // Types that are valid to be assigned to Address: // *AddressPB_Ip // *AddressPB_Domain Address isAddressPB_Address `protobuf_oneof:"address"` }
type AddressPB_Domain ¶
type AddressPB_Domain struct {
Domain string `protobuf:"bytes,2,opt,name=domain,oneof"`
}
type AddressPB_Ip ¶
type AddressPB_Ip struct {
Ip []byte `protobuf:"bytes,1,opt,name=ip,proto3,oneof"`
}
type Destination ¶
type Destination interface { Network() Network // Protocol of communication (tcp / udp) Address() Address // Address of destination Port() Port String() string // String representation of the destination NetAddr() string Equals(Destination) bool IsTCP() bool // True if destination is reachable via TCP IsUDP() bool // True if destination is reachable via UDP }
Destination represents a network destination including address and protocol (tcp / udp).
func DestinationFromAddr ¶ added in v1.24.1
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
type IPNet ¶ added in v1.1.1
type IPNet struct {
// contains filtered or unexported fields
}
type Network ¶ added in v0.14.1
type Network string
Network represents a communication network on internet.
func (Network) AsList ¶ added in v1.9.1
func (this Network) AsList() *NetworkList
type NetworkList ¶ added in v0.14.1
type NetworkList []Network
NetworkList is a list of Networks.
func NewNetworkList ¶ added in v1.9.1
func NewNetworkList(networks collect.StringList) NetworkList
NewNetworkList construsts a NetWorklist from the given StringListeralList.
func (*NetworkList) HasNetwork ¶ added in v0.14.1
func (this *NetworkList) HasNetwork(network Network) bool
HashNetwork returns true if the given network is in this NetworkList.
type Port ¶ added in v1.1.1
type Port uint16
Port represents a network port in TCP and UDP protocol.
func PortFromBytes ¶ added in v1.1.1
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.9.1
PortFromInt converts an integer to a Port. @error when the integer is not positive or larger then 65535
func PortFromString ¶ added in v1.9.1
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.1.1
Bytes returns the correspoding bytes of this Port, in big endian order.
func (Port) String ¶ added in v1.1.1
String returns the string presentation of this Port.
type PortRange ¶ added in v0.14.1
type PortRange struct { From uint32 `protobuf:"varint,1,opt,name=From,json=from" json:"From,omitempty"` To uint32 `protobuf:"varint,2,opt,name=To,json=to" json:"To,omitempty"` }
PortRange represents a range of ports.
func (PortRange) Contains ¶ added in v1.9.1
Contains returns true if the given port is within the range of this PortRange.
type TimeOutReader ¶
type TimeOutReader struct {
// contains filtered or unexported fields
}
func NewTimeOutReader ¶
func NewTimeOutReader(timeout uint32, connection net.Conn) *TimeOutReader
func (*TimeOutReader) GetTimeOut ¶ added in v0.9.1
func (reader *TimeOutReader) GetTimeOut() uint32
func (*TimeOutReader) Read ¶
func (reader *TimeOutReader) Read(p []byte) (int, error)
func (*TimeOutReader) Release ¶ added in v1.11.1
func (reader *TimeOutReader) Release()
func (*TimeOutReader) SetTimeOut ¶ added in v0.9.1
func (reader *TimeOutReader) SetTimeOut(value uint32)