Decode a fragmented handshake message straight into its packet, behind room for the Nebula header, instead of copying it there

This commit is contained in:
JackDoan committed 2026-10-15 10:42:39 -05:00
1 parent 4b295e086e
commit cbcf441d7c
8 files changed
+49 -30

No files matched your search

+4 -1
View File
@@ -91,6 +91,7 @@ func NewTable[K, S comparable](cfg TableConfig) *Table[K, S] {
// Result describes a completed message.
type Result struct {
Msg []byte // the decoded message, nil for a repeat
Packet []byte // header.Len bytes for the caller's Nebula header, then Msg
Hash [sha256.Size]byte // sha256 of the message
Received int // packet bytes received for it, for the amplification budget
@@ -159,12 +160,14 @@ func (t *Table[K, S]) Add(key K, source S, now time.Time, h Header, sym []byte)
t.remove(key, e)
t.mu.Unlock()
msg, err := e.a.Decode()
pkt, err := e.a.Decode(make([]byte, header.Len))
if err != nil {
return nil, err
}
msg := pkt[header.Len:]
return &Result{
Msg: msg,
Packet: pkt,
Hash: sha256.Sum256(msg),
Received: e.a.Received(),
msgLen: e.a.msgLen,