Warn about discarded received packets

This commit is contained in:
Davide De Rosa 2019-12-12 09:32:34 +01:00
parent a65682a89a
commit 90c118a3d0

View File

@ -437,6 +437,7 @@ public class OpenVPNSession: Session {
// Ruby: recv_link // Ruby: recv_link
private func receiveLink(packets: [Data]) { private func receiveLink(packets: [Data]) {
guard shouldHandlePackets() else { guard shouldHandlePackets() else {
log.warning("Discarding \(packets.count) LINK packets (should not handle)")
return return
} }
@ -536,6 +537,7 @@ public class OpenVPNSession: Session {
// Ruby: recv_tun // Ruby: recv_tun
private func receiveTunnel(packets: [Data]) { private func receiveTunnel(packets: [Data]) {
guard shouldHandlePackets() else { guard shouldHandlePackets() else {
log.warning("Discarding \(packets.count) TUN packets (should not handle)")
return return
} }
sendDataPackets(packets) sendDataPackets(packets)
@ -1221,7 +1223,7 @@ public class OpenVPNSession: Session {
// MARK: Stop // MARK: Stop
private func shouldHandlePackets() -> Bool { private func shouldHandlePackets() -> Bool {
return (!isStopping && !keys.isEmpty) return !isStopping && !keys.isEmpty
} }
private func deferStop(_ method: StopMethod, _ error: Error?) { private func deferStop(_ method: StopMethod, _ error: Error?) {