network

package
v0.0.0-...-73c317a Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

View Source
const MaxDatagramSize = 65507
View Source
const Timeout = time.Second * 1
View Source
const UDPv4 = "udp4"
View Source
const UDPv6 = "udp6"

Variables

This section is empty.

Functions

func GetAddress

func GetAddress(rawAddr string) (addr *net.UDPAddr, err error)

func GetAddressesAndInterfaces

func GetAddressesAndInterfaces(rawIntfc, rawAddr string) (addr *net.UDPAddr, intfc *net.Interface, srcAddr *net.UDPAddr, err error)

func GetDefaultInterfaceName

func GetDefaultInterfaceName() (string, error)

TODO: DRY this up w/ the above

func GetFreePort

func GetFreePort() (int, error)

TODO: DRY this up w/ the above

func GetNetwork

func GetNetwork(rawAddr string) string

func GetReceiverConn

func GetReceiverConn(addr *net.UDPAddr, intfc *net.Interface) (conn *net.UDPConn, err error)

func GetSenderConn

func GetSenderConn(addr *net.UDPAddr, srcAddr *net.UDPAddr) (conn *net.UDPConn, err error)

Types

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) GetRawSrcAddr

func (m *Manager) GetRawSrcAddr(
	dstAddr *net.UDPAddr,
) (*net.UDPAddr, error)

func (*Manager) GetReceiver

func (m *Manager) GetReceiver(
	dstAddr *net.UDPAddr,
	interfaceName string,
) (*Receiver, error)

func (*Manager) GetSender

func (m *Manager) GetSender(
	dstAddr *net.UDPAddr,
) (*Sender, error)

func (*Manager) RegisterCallback

func (m *Manager) RegisterCallback(
	dstAddr *net.UDPAddr,
	interfaceName string,
	callback func(*net.UDPAddr, *net.UDPAddr, []byte),
) error

func (*Manager) Send

func (m *Manager) Send(
	dstAddr *net.UDPAddr,
	b []byte,
) error

func (*Manager) Start

func (m *Manager) Start()

func (*Manager) Stop

func (m *Manager) Stop()

func (*Manager) UnregisterCallback

func (m *Manager) UnregisterCallback(
	dstAddr *net.UDPAddr,
	interfaceName string,
	callback func(*net.UDPAddr, *net.UDPAddr, []byte),
) error

type Receiver

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

func NewReceiver

func NewReceiver(
	dstAddr *net.UDPAddr,
	interfaceName string,
) *Receiver

func (*Receiver) Close

func (r *Receiver) Close()

func (*Receiver) Open

func (r *Receiver) Open() error

func (*Receiver) RegisterCallback

func (r *Receiver) RegisterCallback(
	callback func(*net.UDPAddr, *net.UDPAddr, []byte),
) error

func (*Receiver) UnregisterCallback

func (r *Receiver) UnregisterCallback(
	callback func(*net.UDPAddr, *net.UDPAddr, []byte),
) error

type Sender

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

func NewSender

func NewSender(
	dstAddr *net.UDPAddr,
) *Sender

func (*Sender) Close

func (s *Sender) Close()

func (*Sender) GetRawSrcAddr

func (s *Sender) GetRawSrcAddr() (*net.UDPAddr, error)

func (*Sender) Open

func (s *Sender) Open() error

func (*Sender) Send

func (s *Sender) Send(b []byte) error

Jump to

Keyboard shortcuts

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