udp

package
v0.0.0-...-61b8474 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MTU = 9001

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr struct {
	IP   net.IP
	Port uint16
}

func FromBytesManual

func FromBytesManual(data []byte) (Addr, error)

func NewAddr

func NewAddr(ip net.IP, port uint16) *Addr

func (*Addr) Copy

func (a *Addr) Copy() *Addr

func (*Addr) Equals

func (a *Addr) Equals(t *Addr) bool

func (*Addr) NetAddr

func (a *Addr) NetAddr() net.Addr

func (*Addr) Network

func (a *Addr) Network() string

func (*Addr) String

func (a *Addr) String() string

func (*Addr) ToBytesGob

func (a *Addr) ToBytesGob() ([]byte, error)

func (*Addr) ToBytesJSON

func (a *Addr) ToBytesJSON() ([]byte, error)

func (*Addr) ToBytesManual

func (a *Addr) ToBytesManual() ([]byte, error)

type AddrSlice

type AddrSlice []*Addr

func (AddrSlice) Equal

func (a AddrSlice) Equal(b AddrSlice) bool

type Conn

type Conn interface {
	LocalAddr() (*Addr, error)
	Listen(r EncReader)
	WriteTo(b []byte, addr *Addr) error
	Close() error
}

func NewGenericListener

func NewGenericListener(logger *zap.Logger, ip net.IP, port int) (Conn, error)

type EncReader

type EncReader func(addr *Addr, out []byte, packet []byte)

type GenericConn

type GenericConn struct {
	*net.UDPConn
	// contains filtered or unexported fields
}

func (*GenericConn) Listen

func (u *GenericConn) Listen(r EncReader)

func (*GenericConn) LocalAddr

func (u *GenericConn) LocalAddr() (*Addr, error)

func (*GenericConn) WriteTo

func (u *GenericConn) WriteTo(b []byte, addr *Addr) error

type MakeupWriter

type MakeupWriter interface {
	WriteTo(srcPort uint16, destPort uint16, b []byte, addr *Addr) error
	Close() error
}

func DialMakeup

func DialMakeup(ip net.IP, port int) (MakeupWriter, error)

Jump to

Keyboard shortcuts

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