summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--device/noise-protocol.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/device/noise-protocol.go b/device/noise-protocol.go
index 6dcc831..a848c47 100644
--- a/device/noise-protocol.go
+++ b/device/noise-protocol.go
@@ -314,11 +314,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
}