txthinking/brook · error
data too small
Error message
data too small
What it means
Length validation in PacketServerConnFactory.Handle: the first UDP packet from a client is shorter than the 12+4+16 byte minimum needed for the protocol header (salt/nonce plus encrypted fixed fields plus GCM tag), so it cannot be a legitimate brook packet and is discarded. Typically caused by stray traffic, port scans, or a non-brook client hitting the packet server port.
Source
Thrown at packetserverconn.go:48
"github.com/txthinking/x"
"golang.org/x/crypto/hkdf"
)
type PacketServerConnFactory struct {
Conns map[string]*PacketConn
Lock *sync.Mutex
}
func NewPacketServerConnFactory() *PacketServerConnFactory {
return &PacketServerConnFactory{
Conns: make(map[string]*PacketConn),
Lock: &sync.Mutex{},
}
}
func (f *PacketServerConnFactory) Handle(addr *net.UDPAddr, b, p []byte, w func([]byte) (int, error), timeout int) (net.Conn, []byte, error) {
if len(b) < 12+4+16 {
return nil, nil, errors.New("data too small")
}
ck := x.BP32.Get().([]byte)
if _, err := io.ReadFull(hkdf.New(sha256.New, p, b[:12], ClientHKDFInfo), ck); err != nil {
x.BP32.Put(ck)
return nil, nil, err
}
cb, err := aes.NewCipher(ck)
if err != nil {
x.BP32.Put(ck)
return nil, nil, err
}
x.BP32.Put(ck)
ca, err := cipher.NewGCM(cb)
if err != nil {
return nil, nil, err
}
if _, err := ca.Open(b[:12], b[:12], b[12:], nil); err != nil {View on GitHub (pinned to 5cd13ef3b1)
Solutions
- Ensure the client is a compatible brook version speaking the packet protocol
- Confirm the traffic is actually addressed to the brook UDP port (scans/noise also trigger this)
- If legitimate packets are truncated, check for middleboxes fragmenting or clipping UDP payloads
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packetserverconn.go:48 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of txthinking/brook@5cd13ef3b1 (2026-09-06).
Data as JSON: /api/errors/c429d09a3dfb65ac.
Report an issue: GitHub.