dispatcher

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("closed")

Functions

This section is empty.

Types

type DispatcherToPacketConn

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

func NewDispatcherToPacketConn

func NewDispatcherToPacketConn(ctx context.Context,
	dispatcher i.FlowHandler, opts ...PacketDispatcherOption) *DispatcherToPacketConn

func (*DispatcherToPacketConn) Close

func (d *DispatcherToPacketConn) Close() error

func (*DispatcherToPacketConn) ReadPacket

func (d *DispatcherToPacketConn) ReadPacket() (*udp.Packet, error)

func (*DispatcherToPacketConn) WritePacket

func (d *DispatcherToPacketConn) WritePacket(p *udp.Packet) error

type PacketDispatcher

type PacketDispatcher struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

TODO: make it as a PacketConn

func NewPacketDispatcher

func NewPacketDispatcher(ctx context.Context, dispatcher i.FlowHandler,
	opts ...PacketDispatcherOption) *PacketDispatcher

func (*PacketDispatcher) Close

func (s *PacketDispatcher) Close() error

func (*PacketDispatcher) DispatchPacket

func (s *PacketDispatcher) DispatchPacket(destination net.Destination, payload *buf.Buffer) error

payload's ownership is transferred to the dispatcher. PacketDispatcher releases it even if DispatchPacket fails.

func (*PacketDispatcher) SetResponseCallback

func (p *PacketDispatcher) SetResponseCallback(callback func(packet *udp.Packet))

type PacketDispatcher0 added in v1.0.4

type PacketDispatcher0 struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewPacketDispatcher0 added in v1.0.4

func NewPacketDispatcher0(ctx context.Context, dispatcher i.FlowHandler) *PacketDispatcher0

func (*PacketDispatcher0) Close added in v1.0.4

func (s *PacketDispatcher0) Close() error

func (*PacketDispatcher0) DispatchPacket added in v1.0.4

func (s *PacketDispatcher0) DispatchPacket(destination net.Destination, payload *buf.Buffer) error

payload's ownership is transferred to the dispatcher. PacketDispatcher0 releases it even if DispatchPacket fails.

func (*PacketDispatcher0) SetResponseCallback added in v1.0.4

func (p *PacketDispatcher0) SetResponseCallback(callback func(packet *udp.Packet))

type PacketDispatcherOption

type PacketDispatcherOption func(*PacketDispatcher)

func WithBufferSize

func WithBufferSize(size int) PacketDispatcherOption

func WithLinkLifetime

func WithLinkLifetime(lifetime time.Duration) PacketDispatcherOption

func WithRequestTimeout

func WithRequestTimeout(timeout time.Duration) PacketDispatcherOption

func WithResponseCallback

func WithResponseCallback(callback func(packet *udp.Packet)) PacketDispatcherOption

func WithResponseTimeout

func WithResponseTimeout(timeout time.Duration) PacketDispatcherOption

Jump to

Keyboard shortcuts

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