net

package
v2.2.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2016 License: MIT Imports: 13 Imported by: 0

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:

AddressPB
DestinationPB
NetworkList
PortRange

Package net contains common network utilities.

Index

Constants

View Source
const (
	AddressFamilyIPv4   = AddressFamily(0)
	AddressFamilyIPv6   = AddressFamily(1)
	AddressFamilyDomain = AddressFamily(2)
)

Variables

View Source
var (
	LocalHostIP = IPAddress([]byte{127, 0, 0, 1})
	AnyIP       = IPAddress([]byte{0, 0, 0, 0})
)
View Source
var (
	// ErrInvalidPortRage indicates an error during port range parsing.
	ErrInvalidPortRange = errors.New("Invalid port range.")
)
View Source
var Network_name = map[int32]string{
	0: "Unknown",
	1: "RawTCP",
	2: "TCP",
	3: "UDP",
	4: "KCP",
	5: "WebSocket",
}
View Source
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

func DomainAddress(domain string) Address

DomainAddress creates an Address with given domain.

func IPAddress

func IPAddress(ip []byte) Address

IPAddress creates an Address with given IP.

func ParseAddress added in v1.9.1

func ParseAddress(addr string) Address

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.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"`
}

func (*AddressPB) AsAddress

func (this *AddressPB) AsAddress() Address

func (*AddressPB) Descriptor

func (*AddressPB) Descriptor() ([]byte, []int)

func (*AddressPB) GetAddress

func (m *AddressPB) GetAddress() isAddressPB_Address

func (*AddressPB) GetDomain

func (m *AddressPB) GetDomain() string

func (*AddressPB) GetIp

func (m *AddressPB) GetIp() []byte

func (*AddressPB) ProtoMessage

func (*AddressPB) ProtoMessage()

func (*AddressPB) Reset

func (m *AddressPB) Reset()

func (*AddressPB) String

func (m *AddressPB) String() string

func (*AddressPB) XXX_OneofFuncs

func (*AddressPB) 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 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 struct {
	Network Network
	Address Address
	Port    Port
}

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

func (Destination) Equals added in v1.9.1

func (this Destination) Equals(another Destination) bool

func (Destination) NetAddr added in v1.9.1

func (this Destination) NetAddr() string

func (Destination) String

func (this Destination) String() string

type DestinationPB

type DestinationPB struct {
	Network Network    `protobuf:"varint,1,opt,name=network,enum=v2ray.core.common.net.Network" json:"network,omitempty"`
	Address *AddressPB `protobuf:"bytes,2,opt,name=address" json:"address,omitempty"`
	Port    uint32     `protobuf:"varint,3,opt,name=port" json:"port,omitempty"`
}

func (*DestinationPB) AsDestination

func (this *DestinationPB) AsDestination() Destination

func (*DestinationPB) Descriptor

func (*DestinationPB) Descriptor() ([]byte, []int)

func (*DestinationPB) GetAddress

func (m *DestinationPB) GetAddress() *AddressPB

func (*DestinationPB) ProtoMessage

func (*DestinationPB) ProtoMessage()

func (*DestinationPB) Reset

func (m *DestinationPB) Reset()

func (*DestinationPB) String

func (m *DestinationPB) String() string

type IPNet added in v1.1.1

type IPNet struct {
	// contains filtered or unexported fields
}

func NewIPNet added in v1.1.1

func NewIPNet() *IPNet

func NewIPNetInitialValue added in v1.1.1

func NewIPNetInitialValue(data map[uint32]byte) *IPNet

func (*IPNet) Add added in v1.1.1

func (this *IPNet) Add(ipNet *net.IPNet)

func (*IPNet) Contains added in v1.1.1

func (this *IPNet) Contains(ip net.IP) bool

func (*IPNet) Serialize added in v1.1.1

func (this *IPNet) Serialize() []uint32

type Network added in v0.14.1

type Network int32
const (
	Network_Unknown   Network = 0
	Network_RawTCP    Network = 1
	Network_TCP       Network = 2
	Network_UDP       Network = 3
	Network_KCP       Network = 4
	Network_WebSocket Network = 5
)

func ParseNetwork

func ParseNetwork(nwStr string) Network

func (Network) AsList added in v1.9.1

func (this Network) AsList() *NetworkList

func (Network) EnumDescriptor

func (Network) EnumDescriptor() ([]byte, []int)

func (Network) String added in v1.17.2

func (x Network) String() string

func (Network) SystemString

func (this Network) SystemString() string

func (Network) UrlPrefix

func (this Network) UrlPrefix() string

type NetworkList added in v0.14.1

type NetworkList struct {
	Network []Network `protobuf:"varint,1,rep,packed,name=network,enum=v2ray.core.common.net.Network" json:"network,omitempty"`
}

func NewNetworkList added in v1.9.1

func NewNetworkList(networks collect.StringList) *NetworkList

NewNetworkList construsts a NetWorklist from the given StringListeralList.

func (*NetworkList) Descriptor

func (*NetworkList) Descriptor() ([]byte, []int)

func (NetworkList) Get

func (this NetworkList) Get(idx int) Network

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.

func (*NetworkList) ProtoMessage

func (*NetworkList) ProtoMessage()

func (*NetworkList) Reset

func (m *NetworkList) Reset()

func (*NetworkList) String

func (m *NetworkList) String() string

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

func PortFromBytes(port []byte) Port

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

func PortFromInt(v uint32) (Port, error)

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

func PortFromString(s string) (Port, error)

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

func (this Port) Bytes(b []byte) []byte

Bytes returns the correspoding bytes of this Port, in big endian order.

func (Port) String added in v1.1.1

func (this Port) String() string

String returns the string presentation of this Port.

func (Port) Value added in v1.1.1

func (this Port) Value() uint16

Value return the correspoding uint16 value 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

func (this PortRange) Contains(port Port) bool

Contains returns true if the given port is within the range of this PortRange.

func (*PortRange) Descriptor

func (*PortRange) Descriptor() ([]byte, []int)

func (PortRange) FromPort

func (this PortRange) FromPort() Port

func (*PortRange) ProtoMessage

func (*PortRange) ProtoMessage()

func (*PortRange) Reset

func (m *PortRange) Reset()

func (*PortRange) String

func (m *PortRange) String() string

func (PortRange) ToPort

func (this PortRange) ToPort() Port

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.14.1

func (reader *TimeOutReader) GetTimeOut() uint32

func (*TimeOutReader) Read

func (reader *TimeOutReader) Read(p []byte) (int, error)

func (*TimeOutReader) Release added in v1.11.2

func (reader *TimeOutReader) Release()

func (*TimeOutReader) SetTimeOut added in v0.14.1

func (reader *TimeOutReader) SetTimeOut(value uint32)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL