udp

package
v0.8.10 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialAddrAndIncreaseResultMap

func DialAddrAndIncreaseResultMap(address string, resultMap *ResultMap) error

func DialUDPAddrWithHelloMsgAndGetReply

func DialUDPAddrWithHelloMsgAndGetReply(
	address *net.UDPAddr,
	helloMsg fmt.Stringer,
) (string, error)

DialUDPAddrWithHelloMsgAndGetReply will open a UDP socket with provided UDP address and send there a helloMsg (fmt.Stringer), and block goroutine waiting for the message back, which will be returned as a string

func GenRandomAddressIPv4

func GenRandomAddressIPv4(port uint16) *net.UDPAddr

GenRandomAddressIPv4 will generate random *net.UDPAddr (IPv4) with provided port

func GenRandomAddressIPv6

func GenRandomAddressIPv6(port uint16) *net.UDPAddr

GenRandomAddressIPv6 will generate random *net.UDPAddr (IPv6) with provided port

func ReplyWithLocalAddr

func ReplyWithLocalAddr(conn *net.UDPConn) error

func ReplyWithMsg added in v0.6.0

func ReplyWithMsg(message string) func(conn *net.UDPConn) error

func ReplyWithReceivedMsg

func ReplyWithReceivedMsg(conn *net.UDPConn) error

func UnsafeStartUDPServer

func UnsafeStartUDPServer(
	ns *netns.NetNS,
	address string,
	processConn func(conn *net.UDPConn) error,
	callbacks ...func() error,
) (<-chan struct{}, <-chan error)

UnsafeStartUDPServer will start TCP server in provided *netns.NesNS. Every initialized udp "connection" will be processed via provided callback functions. It was named UnsafeStartUDPServer instead of StartUDPServer because you have to be very cautious and remember to not spawn new goroutines inside provided callbacks (more info in warning below)

WARNING!:

Don't spawn new goroutines inside callback functions as the goroutine inside
UnsafeStartUDPServer function have exclusive access to the current network
namespace, and you should assume, that any new goroutine will be placed
in a different namespace

Types

type ResultMap

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

func NewResultMap

func NewResultMap() *ResultMap

func (*ResultMap) GetFinalResults

func (m *ResultMap) GetFinalResults() map[string]uint

func (*ResultMap) Increase

func (m *ResultMap) Increase(key string)

Jump to

Keyboard shortcuts

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