lx: gate reserved-byte clear on receive so AmneziaWG magic survives
The Cloudflare "reserved" bytes (1-3) were zeroed unconditionally on every received datagram across all StdNetBind/WinRingBind receive paths. AmneziaWG reads its magic header as LittleEndian.Uint32(packet[padding:]) where padding is s1/s2/s4; with small padding (0-3) the magic overlaps bytes 1-3, so clearing them collapses it out of the ranged h1-h4 window and every packet is dropped (handshake included) — the AWG endpoint never comes up. Plain WG (types 1-4, bytes 1-3 already zero) and large padding are unaffected, which is why it went unnoticed. Gate all five receive clears (bind_std receiveIP, msgx_darwin receiveSingle + makeReceiveMsgX, bind_windows receiveIPv4/v6) behind a new hasReserved() so bytes 1-3 are only touched when a WARP reserved value is actually configured. Send paths already gate on a per-endpoint loaded/non-zero check, so they are left unchanged. The reserved map is populated before the receive goroutines start and never mutated after, so the lock-free read is safe. Tests: awg_stdnetbind_reserved_lx_test.go brings up two Devices over StdNetBind with zero padding (magic in bytes 0-3) and asserts delivery (red before the fix, green after); reserved_gate_lx_test.go pins the hasReserved() gate.
This commit is contained in:
parent
ee7ff1b77f
commit
1e787bb3e0
7 changed files with 283 additions and 11 deletions
|
|
@ -188,10 +188,10 @@ func (t *chanTun) Write(bufs [][]byte, offset int) (int, error) {
|
|||
return len(bufs), nil
|
||||
}
|
||||
|
||||
func (t *chanTun) MTU() (int, error) { return DefaultMTU, nil }
|
||||
func (t *chanTun) Name() (string, error) { return "chantun", nil }
|
||||
func (t *chanTun) Events() <-chan tun.Event { return t.events }
|
||||
func (t *chanTun) BatchSize() int { return 1 }
|
||||
func (t *chanTun) MTU() (int, error) { return DefaultMTU, nil }
|
||||
func (t *chanTun) Name() (string, error) { return "chantun", nil }
|
||||
func (t *chanTun) Events() <-chan tun.Event { return t.events }
|
||||
func (t *chanTun) BatchSize() int { return 1 }
|
||||
|
||||
func (t *chanTun) Close() error {
|
||||
t.closeOnce.Do(func() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue