udp

package
v0.1.34 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const BufferSize = 16 * 1024
View Source
const MaxUdpAge = 5 * time.Minute

Variables

View Source
var BufPool = sync.Pool{New: func() any { return make([]byte, BufferSize) }}
View Source
var ReadMsgsBufPool = sync.Pool{New: func() any {
	msgs := make([]ipv4.Message, batchSize)
	for i := range msgs {

		msgs[i].Buffers = make([][]byte, 1)
		msgs[i].Buffers[0] = BufPool.Get().([]byte)
	}
	return msgs
}}
View Source
var WriteMsgsBufPool = sync.Pool{New: func() any {
	msgs := make([]ipv4.Message, batchSize)
	for i := range msgs {

		msgs[i].Buffers = make([][]byte, 1)
	}
	return msgs
}}

Functions

func BuildUdp

func BuildUdp(udpConfig config.UdpConfig)

func ListenUdp

func ListenUdp(network, address string) (*net.UDPConn, error)

func StartUdps

func StartUdps()

Types

type EnhancePacketConn added in v0.1.34

type EnhancePacketConn interface {
	net.PacketConn
	WaitReadFrom() (data []byte, put func(), addr netip.AddrPort, err error)
}

func NewEnhancePacketConn added in v0.1.34

func NewEnhancePacketConn(pc net.PacketConn) EnhancePacketConn

type MmsgMapItem

type MmsgMapItem struct {
	net.Conn
	*ipv4.PacketConn
	sync.Mutex
}

type MmsgTunnel

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

func (*MmsgTunnel) Handle

func (t *MmsgTunnel) Handle()

type StdMapItem

type StdMapItem struct {
	net.Conn
	*ipv4.PacketConn
	sync.Mutex
}

type StdTunnel

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

func (*StdTunnel) Handle

func (t *StdTunnel) Handle()

type Tunnel

type Tunnel interface {
	Handle()
}

func NewMmsgTunnel

func NewMmsgTunnel(udpConfig config.UdpConfig) Tunnel

func NewStdTunnel

func NewStdTunnel(udpConfig config.UdpConfig) Tunnel

Jump to

Keyboard shortcuts

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