batch udp packet sending

This commit is contained in:
Jay Wren
2026-02-03 16:56:21 -05:00
parent 42bee7cf17
commit 15333f9fed
9 changed files with 133 additions and 1 deletions

View File

@@ -13,11 +13,18 @@ type EncReader func(
payload []byte,
)
// BatchPacket represents a single packet in a batch write operation
type BatchPacket struct {
Payload []byte
Addr netip.AddrPort
}
type Conn interface {
Rebind() error
LocalAddr() (netip.AddrPort, error)
ListenOut(r EncReader)
WriteTo(b []byte, addr netip.AddrPort) error
WriteBatch(pkts []BatchPacket) (int, error)
ReloadConfig(c *config.C)
SupportsMultipleReaders() bool
Close() error
@@ -40,6 +47,9 @@ func (NoopConn) SupportsMultipleReaders() bool {
func (NoopConn) WriteTo(_ []byte, _ netip.AddrPort) error {
return nil
}
func (NoopConn) WriteBatch(pkts []BatchPacket) (int, error) {
return len(pkts), nil
}
func (NoopConn) ReloadConfig(_ *config.C) {
return
}