From 48b2604064a750ef7c9da2e48a9953529a721e45 Mon Sep 17 00:00:00 2001 From: Ludvig Strigeus Date: Sun, 16 Dec 2018 17:07:34 +0100 Subject: [PATCH] Add DPRINTF --- tunsafe_types.h | 6 ++++++ wireguard.cpp | 2 ++ 2 files changed, 8 insertions(+) diff --git a/tunsafe_types.h b/tunsafe_types.h index d4dc203..bde5f84 100644 --- a/tunsafe_types.h +++ b/tunsafe_types.h @@ -68,4 +68,10 @@ void RERROR(const char *msg, ...); void RINFO(const char *msg, ...); void tunsafe_die(const char *msg); +#ifdef _DEBUG +#define DPRINTF RINFO +#else +#define DPRINTF(msg, ...) +#endif + #endif // TINYVPN_TYPES_H_ diff --git a/wireguard.cpp b/wireguard.cpp index 05f0400..43047ed 100644 --- a/wireguard.cpp +++ b/wireguard.cpp @@ -1007,6 +1007,7 @@ WireguardProcessor::PacketResult WireguardProcessor::CheckIncomingHandshakeRateL WgRateLimit::RateLimitResult rr = dev_.rate_limiter()->CheckRateLimit(GetIpForRateLimit(packet)); if ((overload && rr.is_rate_limited()) || !dev_.CheckCookieMac1(packet)) { + DPRINTF("Rate limited or cookie mac failed!"); stats_.invalid_packets_in++; stats_.invalid_bytes_in += packet->size; return kPacketResult_Free; @@ -1014,6 +1015,7 @@ WireguardProcessor::PacketResult WireguardProcessor::CheckIncomingHandshakeRateL dev_.rate_limiter()->CommitResult(rr); if (overload && !rr.is_first_ip() && !dev_.CheckCookieMac2(packet)) { + DPRINTF("Responding with cookie message"); dev_.CreateCookieMessage((MessageHandshakeCookie*)packet->data, packet, ((MessageHandshakeInitiation*)packet->data)->sender_key_id); packet->size = sizeof(MessageHandshakeCookie); PrepareOutgoingHandshakePacket(NULL, packet);