summaryrefslogtreecommitdiffhomepage
path: root/device/noise-protocol.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2021-01-22 14:11:17 -0800
committerJason A. Donenfeld <Jason@zx2c4.com>2021-01-26 22:40:20 +0100
commit7139279cd0b08ebbd2c0322bc01d5678aa00cd0e (patch)
treeb49339aabb016e640f2f6088bc5753395d4239b8 /device/noise-protocol.go
parent37efdcaccfb16e47137728b5462c90d0b2ae8460 (diff)
device: change logging interface to use functions
This commit overhauls wireguard-go's logging. The primary, motivating change is to use a function instead of a *log.Logger as the basic unit of logging. Using functions provides a lot more flexibility for people to bring their own logging system. It also introduces logging helper methods on Device. These reduce line noise at the call site. They also allow for log functions to be nil; when nil, instead of generating a log line and throwing it away, we don't bother generating it at all. This spares allocation and pointless work. This is a breaking change, although the fix required of clients is fairly straightforward. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
Diffstat (limited to 'device/noise-protocol.go')
-rw-r--r--device/noise-protocol.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/device/noise-protocol.go b/device/noise-protocol.go
index e34da83..df520d0 100644
--- a/device/noise-protocol.go
+++ b/device/noise-protocol.go
@@ -319,11 +319,11 @@ func (device *Device) ConsumeMessageInitiation(msg *MessageInitiation) *Peer {
flood := time.Since(handshake.lastInitiationConsumption) <= HandshakeInitationRate
handshake.mutex.RUnlock()
if replay {
- device.log.Debug.Printf("%v - ConsumeMessageInitiation: handshake replay @ %v\n", peer, timestamp)
+ device.debugf("%v - ConsumeMessageInitiation: handshake replay @ %v", peer, timestamp)
return nil
}
if flood {
- device.log.Debug.Printf("%v - ConsumeMessageInitiation: handshake flood\n", peer)
+ device.debugf("%v - ConsumeMessageInitiation: handshake flood", peer)
return nil
}