]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: add debug logs describing handshake rejection
authorAvery Pennarun <apenwarr@tailscale.com>
Wed, 16 Oct 2019 02:39:44 +0000 (22:39 -0400)
committerDavid Crawshaw <david@zentus.com>
Thu, 2 Apr 2020 04:59:00 +0000 (15:59 +1100)
Useful in testing when bad network stacks repeat or
batch large numbers of packets.

Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
device/noise-protocol.go

index 5d9632c83b520c7c58fa91985cac177fdcbb1d75..dbb6f93d99d0cc1d8cd53994d5ece1292b359d2f 100644 (file)
@@ -315,11 +315,15 @@ func (device *Device) ConsumeMessageInitiation(msg *MessageInitiation) *Peer {
 
        // protect against replay & flood
 
-       var ok bool
-       ok = timestamp.After(handshake.lastTimestamp)
-       ok = ok && time.Since(handshake.lastInitiationConsumption) > HandshakeInitationRate
+       replay := !timestamp.After(handshake.lastTimestamp)
+       flood := time.Since(handshake.lastInitiationConsumption) <= HandshakeInitationRate
        handshake.mutex.RUnlock()
-       if !ok {
+       if replay {
+               device.log.Debug.Printf("%v - ConsumeMessageInitiation: handshake replay @ %v\n", peer, timestamp)
+               return nil
+       }
+       if flood {
+               device.log.Debug.Printf("%v - ConsumeMessageInitiation: handshake flood\n", peer)
                return nil
        }