From 90c118a3d0fd7b3a8da634cf6ca3dc9851297e35 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 12 Dec 2019 09:32:34 +0100 Subject: [PATCH] Warn about discarded received packets --- TunnelKit/Sources/Protocols/OpenVPN/OpenVPNSession.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/TunnelKit/Sources/Protocols/OpenVPN/OpenVPNSession.swift b/TunnelKit/Sources/Protocols/OpenVPN/OpenVPNSession.swift index 370a9d8..248ad3a 100644 --- a/TunnelKit/Sources/Protocols/OpenVPN/OpenVPNSession.swift +++ b/TunnelKit/Sources/Protocols/OpenVPN/OpenVPNSession.swift @@ -437,6 +437,7 @@ public class OpenVPNSession: Session { // Ruby: recv_link private func receiveLink(packets: [Data]) { guard shouldHandlePackets() else { + log.warning("Discarding \(packets.count) LINK packets (should not handle)") return } @@ -536,6 +537,7 @@ public class OpenVPNSession: Session { // Ruby: recv_tun private func receiveTunnel(packets: [Data]) { guard shouldHandlePackets() else { + log.warning("Discarding \(packets.count) TUN packets (should not handle)") return } sendDataPackets(packets) @@ -1221,7 +1223,7 @@ public class OpenVPNSession: Session { // MARK: Stop private func shouldHandlePackets() -> Bool { - return (!isStopping && !keys.isEmpty) + return !isStopping && !keys.isEmpty } private func deferStop(_ method: StopMethod, _ error: Error?) {