net

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TCPNetwork = Network("tcp")
	UDPNetwork = Network("udp")
)

Variables

This section is empty.

Functions

func ChanToWriter

func ChanToWriter(writer io.Writer, stream <-chan *alloc.Buffer) error

ChanToWriter dumps all content from a given chan to a writer until the chan is closed.

func ReadAllBytes added in v0.14.1

func ReadAllBytes(reader io.Reader, buffer []byte) (int, error)

ReadAllBytes reads all bytes required from reader, if no error happens.

func ReadFrom added in v0.14.1

func ReadFrom(reader io.Reader, buffer *alloc.Buffer) (*alloc.Buffer, error)

ReadFrom reads from a reader and put all content to a buffer. If buffer is nil, ReadFrom creates a new normal buffer.

func ReaderToChan

func ReaderToChan(stream chan<- *alloc.Buffer, reader io.Reader) error

ReaderToChan dumps all content from a given reader to a chan by constantly reading it until EOF.

Types

type Address

type Address interface {
	IP() net.IP     // IP of this Address
	Domain() string // Domain of this Address
	Port() Port     // Port of this 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
}

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, port Port) Address

DomainAddress creates an Address with given domain and port.

func IPAddress

func IPAddress(ip []byte, port Port) Address

IPAddress creates an Address with given IP and port.

type Destination

type Destination interface {
	Network() string  // Protocol of communication (tcp / udp)
	Address() Address // Address of destination
	String() string   // String representation of the destination

	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 NewTCPDestination

func NewTCPDestination(address Address) Destination

NewTCPDestination creates a TCP destination with given address

func NewUDPDestination

func NewUDPDestination(address Address) Destination

NewUDPDestination creates a UDP destination with given address

type DomainAddressImpl

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

func (*DomainAddressImpl) Domain

func (addr *DomainAddressImpl) Domain() string

func (*DomainAddressImpl) IP

func (addr *DomainAddressImpl) IP() net.IP

func (*DomainAddressImpl) IsDomain

func (addr *DomainAddressImpl) IsDomain() bool

func (*DomainAddressImpl) IsIPv4

func (addr *DomainAddressImpl) IsIPv4() bool

func (*DomainAddressImpl) IsIPv6

func (addr *DomainAddressImpl) IsIPv6() bool

func (*DomainAddressImpl) Port added in v1.1.1

func (this *DomainAddressImpl) Port() Port

func (*DomainAddressImpl) String

func (this *DomainAddressImpl) 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 IPv4Address

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

func (*IPv4Address) Domain

func (addr *IPv4Address) Domain() string

func (*IPv4Address) IP

func (addr *IPv4Address) IP() net.IP

func (*IPv4Address) IsDomain

func (addr *IPv4Address) IsDomain() bool

func (*IPv4Address) IsIPv4

func (addr *IPv4Address) IsIPv4() bool

func (*IPv4Address) IsIPv6

func (addr *IPv4Address) IsIPv6() bool

func (*IPv4Address) Port added in v1.1.1

func (this *IPv4Address) Port() Port

func (*IPv4Address) String

func (this *IPv4Address) String() string

type IPv6Address

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

func (*IPv6Address) Domain

func (addr *IPv6Address) Domain() string

func (*IPv6Address) IP

func (addr *IPv6Address) IP() net.IP

func (*IPv6Address) IsDomain

func (addr *IPv6Address) IsDomain() bool

func (*IPv6Address) IsIPv4

func (addr *IPv6Address) IsIPv4() bool

func (*IPv6Address) IsIPv6

func (addr *IPv6Address) IsIPv6() bool

func (*IPv6Address) Port added in v1.1.1

func (this *IPv6Address) Port() Port

func (*IPv6Address) String

func (this *IPv6Address) String() string

type Network added in v0.14.1

type Network string

type NetworkList added in v0.14.1

type NetworkList interface {
	HasNetwork(Network) bool
}

type Packet

type Packet interface {
	Destination() Destination
	Chunk() *alloc.Buffer // First chunk of this commnunication
	MoreChunks() bool
}

Packet is a network packet to be sent to destination.

func NewPacket added in v0.14.1

func NewPacket(dest Destination, firstChunk *alloc.Buffer, moreChunks bool) Packet

NewPacket creates a new Packet with given destination and payload.

type Port added in v1.1.1

type Port serial.Uint16Literal

func PortFromBytes added in v1.1.1

func PortFromBytes(port []byte) Port

func (Port) Bytes added in v1.1.1

func (this Port) Bytes() []byte

func (Port) String added in v1.1.1

func (this Port) String() string

func (Port) Value added in v1.1.1

func (this Port) Value() uint16

type PortRange added in v0.14.1

type PortRange interface {
	From() Port
	To() Port
}

type TCPDestination

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

func (TCPDestination) Address

func (dest TCPDestination) Address() Address

func (TCPDestination) IsTCP

func (dest TCPDestination) IsTCP() bool

func (TCPDestination) IsUDP

func (dest TCPDestination) IsUDP() bool

func (TCPDestination) Network

func (dest TCPDestination) Network() string

func (TCPDestination) String

func (dest TCPDestination) String() string

type TimeOutReader

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

func NewTimeOutReader

func NewTimeOutReader(timeout int, connection net.Conn) *TimeOutReader

func (*TimeOutReader) GetTimeOut added in v0.14.1

func (reader *TimeOutReader) GetTimeOut() int

func (*TimeOutReader) Read

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

func (*TimeOutReader) SetTimeOut added in v0.14.1

func (reader *TimeOutReader) SetTimeOut(value int)

type UDPDestination

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

func (UDPDestination) Address

func (dest UDPDestination) Address() Address

func (UDPDestination) IsTCP

func (dest UDPDestination) IsTCP() bool

func (UDPDestination) IsUDP

func (dest UDPDestination) IsUDP() bool

func (UDPDestination) Network

func (dest UDPDestination) Network() string

func (UDPDestination) String

func (dest UDPDestination) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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