Skip to content

Commit

Permalink
cleanup, use correct maxOutLen
Browse files Browse the repository at this point in the history
  • Loading branch information
wadey committed Aug 21, 2023
1 parent 7921c0f commit 7b874fc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
13 changes: 0 additions & 13 deletions header/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,6 @@ type m map[string]interface{}
const (
Version uint8 = 1
Len = 16

// The total Nebula packet overhead is 60 bytes:
// - HeaderLen bytes for the Nebula header.
// - 16 bytes for the encryption cipher's AEAD 128-bit tag.
// NOTE: both AESGCM and ChaChaPoly have a 16 byte tag, but if we add other
// ciphers in the future we could calculate this based on the cipher,
// returned by (cipher.AEAD).Overhead().
// - 20 bytes for our IPv4 header.
// (max is 60 bytes, but we don't use IPv4 options)
// TODO: Could routers along the path inject a larger IPv4 header? If so,
// we may need to increase this.
// - 8 bytes for our UDP header.
NebulaOverhead = Len + 16 + 20 + 8
)

type MessageType uint8
Expand Down
3 changes: 2 additions & 1 deletion inside.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ func (f *Interface) rejectOutside(packet []byte, ci *ConnectionState, hostinfo *
}

// Use some out buffer space to build the packet before encryption
const maxOutLen = iputil.MaxRejectPacketSize + header.NebulaOverhead
const aeadOverhead = 16
const maxOutLen = iputil.MaxRejectPacketSize + header.Len + aeadOverhead
outPacket := iputil.CreateRejectPacket(packet, out[maxOutLen:maxOutLen+iputil.MaxRejectPacketSize])
out = out[:maxOutLen]

Expand Down

0 comments on commit 7b874fc

Please sign in to comment.