Skip to content

Commit

Permalink
ipn/wg: flood on handshake and keepalives
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Nov 16, 2024
1 parent 84a240a commit 84bee96
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions intra/ipn/wg/wgconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,23 +403,25 @@ func (s *StdNetBind) Send(buf [][]byte, peer conn.Endpoint) (err error) {
return syscall.EAFNOSUPPORT
}

datalen := len(data) // grab the length before we overwrite it

if s.overwriteReserve {
if s.amnezia.Set() {
overwritten = s.amnezia.send(&data)
} else if len(data) > 3 && isWgMsgType(data[0]) {
} else if datalen && isWgMsgType(data[0]) {

Check failure on line 411 in intra/ipn/wg/wgconn.go

View workflow job for this annotation

GitHub Actions / 🧬 Build

invalid operation: datalen && isWgMsgType(data[0]) (mismatched types int and bool)

Check failure on line 411 in intra/ipn/wg/wgconn.go

View workflow job for this annotation

GitHub Actions / 📐 Analyze (go)

invalid operation: datalen && isWgMsgType(data[0]) (mismatched types int and bool)

Check failure on line 411 in intra/ipn/wg/wgconn.go

View workflow job for this annotation

GitHub Actions / 🧭 Lint

invalid operation: datalen && isWgMsgType(data[0]) (mismatched types int and bool) (compile)
// overwrite the 3 reserved bytes on non-random packets
// from: github.com/bepass-org/warp-plus/blob/19ac233cc6/wireguard/device/peer.go#L138
copy(data[1:4], s.reserved)
overwritten = true
}
}

if !flooded && !overwritten && (experimentalWg || s.overwriteReserve) {
if len(data) == device.MessageInitiationSize {
go s.flood(uc, dst, fkHandshake) // probably a handshake
if !flooded && (experimentalWg || s.overwriteReserve) {
if datalen == device.MessageInitiationSize {
s.flood(uc, dst, fkHandshake) // was probably a handshake
flooded = true
} else if len(data) == device.MessageKeepaliveSize {
go s.flood(uc, dst, fkKeepalive) // probably a keepalive
} else if datalen == device.MessageKeepaliveSize {
s.flood(uc, dst, fkKeepalive) // was probably a keepalive
flooded = true
}
}
Expand Down

0 comments on commit 84bee96

Please sign in to comment.