diff --git a/NearDrop/AppDelegate.swift b/NearDrop/AppDelegate.swift index ef58b16..86ee624 100644 --- a/NearDrop/AppDelegate.swift +++ b/NearDrop/AppDelegate.swift @@ -305,11 +305,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele case .inputOutput: description = "I/O Error"; case .protocolError(_): - description = NSLocalizedString("Error.Protocol", value: "Communication error", comment: "") + description = NSLocalizedString("Error.Protocol", value: "Communication error", comment: "") + "(\(ne.localizedDescription))" + case .packetFilterError: + description = NSLocalizedString("Error.PacketFilter", value: "Communication error", comment: "") case .requiredFieldMissing: - description = NSLocalizedString("Error.Protocol", value: "Communication error", comment: "") + description = NSLocalizedString("Error.Protocol", value: "Communication error", comment: "") + "(\(ne.localizedDescription))" case .ukey2: - description = NSLocalizedString("Error.Crypto", value: "Encryption error", comment: "") + description = NSLocalizedString("Error.Crypto", value: "Encryption error", comment: "") + "(\(ne.localizedDescription))" case .canceled(reason: _): break; // can't happen for incoming transfers } @@ -328,7 +330,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele if let plusWindow = plusWindow { log("Closing plus screen because of error") - self.plusWindow?.close() + plusWindow.close() } log("Showing alert with message: \"\(alert.messageText)\" and description: \"\(alert.informativeText)\"") diff --git a/NearDrop/Base.lproj/Localizable.strings b/NearDrop/Base.lproj/Localizable.strings index 78056c1..6ae13f3 100644 --- a/NearDrop/Base.lproj/Localizable.strings +++ b/NearDrop/Base.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "Communication error"; +"Error.PacketFilter" = "Your Mac may have a faulty packet filter enabled. Open System Preferences > Network > VPN & Filter and disable the content filter to use QuickDrop."; /* No comment provided by engineer. */ "NFiles" = "%d files"; diff --git a/NearDrop/ar.lproj/Localizable.strings b/NearDrop/ar.lproj/Localizable.strings index 95befe9..022a933 100644 --- a/NearDrop/ar.lproj/Localizable.strings +++ b/NearDrop/ar.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "خطأ في الاتصال"; +"Error.PacketFilter" = "قد يحتوي جهاز Mac الخاص بك على مرشح حزم معطّل. افتح تفضيلات النظام > الشبكة > VPN & التصفية، وقم بتعطيل مرشح المحتوى لاستخدام QuickDrop."; /* No comment provided by engineer. */ "NFiles" = "%d ملفات"; diff --git a/NearDrop/de.lproj/Localizable.strings b/NearDrop/de.lproj/Localizable.strings index 928c170..6884fd8 100644 --- a/NearDrop/de.lproj/Localizable.strings +++ b/NearDrop/de.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "Fehler bei der Datenübertragung"; +"Error.PacketFilter" = "Auf deinem Mac ist möglicherweise ein fehlerhafter Paketfilter aktiviert. Öffne Systemeinstellungen > Netzwerk > VPN & Filter und deaktiviere den Inhaltsfilter, um QuickDrop zu verwenden."; /* No comment provided by engineer. */ "NFiles" = "%d Dateien"; diff --git a/NearDrop/es.lproj/Localizable.strings b/NearDrop/es.lproj/Localizable.strings index 97471e5..3a3b8fb 100644 --- a/NearDrop/es.lproj/Localizable.strings +++ b/NearDrop/es.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "Error de comunicación"; +"Error.PacketFilter" = "Es posible que tu Mac tenga activado un filtro de paquetes defectuoso. Abre Preferencias del Sistema > Red > VPN y Filtro y desactiva el filtro de contenido para usar QuickDrop."; /* No comment provided by engineer. */ //"NFiles" = "%d files"; diff --git a/NearDrop/fr.lproj/Localizable.strings b/NearDrop/fr.lproj/Localizable.strings index a28c89f..8580bac 100644 --- a/NearDrop/fr.lproj/Localizable.strings +++ b/NearDrop/fr.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "Erreur de communication"; +"Error.PacketFilter" = "Votre Mac peut avoir un filtre de paquets défectueux activé. Ouvrez Réglages système > Réseau > VPN et filtre, puis désactivez le filtre de contenu pour utiliser QuickDrop."; /* No comment provided by engineer. */ "NFiles" = "%d fichiers"; diff --git a/NearDrop/hu.lproj/Localizable.strings b/NearDrop/hu.lproj/Localizable.strings index ab09b69..b29cd70 100644 --- a/NearDrop/hu.lproj/Localizable.strings +++ b/NearDrop/hu.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "Kommunikációs hiba"; +"Error.PacketFilter" = "Lehet, hogy a Mac-ed hibás csomagszűrőt használ. Nyisd meg a Rendszerbeállítások > Hálózat > VPN és szűrő menüt, és kapcsold ki a tartalomszűrőt a QuickDrop használatához."; /* No comment provided by engineer. */ "NFiles" = "%d fájl"; diff --git a/NearDrop/it.lproj/Localizable.strings b/NearDrop/it.lproj/Localizable.strings index abeb6c5..e3ec567 100644 --- a/NearDrop/it.lproj/Localizable.strings +++ b/NearDrop/it.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "Errore di comunicazione"; +"Error.PacketFilter" = "Sul tuo Mac potrebbe essere attivo un filtro pacchetti difettoso. Apri Impostazioni di Sistema > Rete > VPN e Filtri e disattiva il filtro dei contenuti per utilizzare QuickDrop."; /* No comment provided by engineer. */ "NFiles" = "%d files"; diff --git a/NearDrop/ja.lproj/Localizable.strings b/NearDrop/ja.lproj/Localizable.strings index dfe646e..b8503be 100644 --- a/NearDrop/ja.lproj/Localizable.strings +++ b/NearDrop/ja.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "通信エラー"; +"Error.PacketFilter" = "お使いのMacで不具合のあるパケットフィルターが有効になっている可能性があります。システム設定 > ネットワーク > VPNとフィルターを開き、コンテンツフィルターを無効にしてQuickDropを使用してください。"; /* No comment provided by engineer. */ "NFiles" = "%dつのファイル"; diff --git a/NearDrop/ko.lproj/Localizable.strings b/NearDrop/ko.lproj/Localizable.strings index 5cb2e7f..47dc0b0 100644 --- a/NearDrop/ko.lproj/Localizable.strings +++ b/NearDrop/ko.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "통신 오류"; +"Error.PacketFilter" = "Mac에서 오류가 있는 패킷 필터가 활성화되어 있을 수 있습니다. 시스템 설정 > 네트워크 > VPN 및 필터로 이동하여 콘텐츠 필터를 비활성화하면 QuickDrop을 사용할 수 있습니다."; /* No comment provided by engineer. */ "NFiles" = "%d개의 파일"; diff --git a/NearDrop/nl.lproj/Localizable.strings b/NearDrop/nl.lproj/Localizable.strings index dcf9e53..7d78c07 100644 --- a/NearDrop/nl.lproj/Localizable.strings +++ b/NearDrop/nl.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "Communicatiefout"; +"Error.PacketFilter" = "Je Mac heeft mogelijk een defect pakketfilter ingeschakeld. Open Systeemvoorkeuren > Netwerk > VPN & Filter en schakel het inhoudsfilter uit om QuickDrop te gebruiken."; /* No comment provided by engineer. */ "NFiles" = "%d bestanden"; diff --git a/NearDrop/pt-BR.lproj/Localizable.strings b/NearDrop/pt-BR.lproj/Localizable.strings index a0ad227..c6f6017 100644 --- a/NearDrop/pt-BR.lproj/Localizable.strings +++ b/NearDrop/pt-BR.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "Erro de comunicação"; +"Error.PacketFilter" = "O seu Mac pode ter um filtro de pacotes com defeito ativado. Abra Preferências do Sistema > Rede > VPN e Filtro e desative o filtro de conteúdo para usar o QuickDrop."; /* No comment provided by engineer. */ "NFiles" = "%d arquivos"; diff --git a/NearDrop/pt-PT.lproj/Localizable.strings b/NearDrop/pt-PT.lproj/Localizable.strings index 9a25ab4..70f339a 100644 --- a/NearDrop/pt-PT.lproj/Localizable.strings +++ b/NearDrop/pt-PT.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "Erro de comunicação"; +"Error.PacketFilter" = "O seu Mac pode ter um filtro de pacotes com defeito ativado. Abra Preferências do Sistema > Rede > VPN e Filtro e desative o filtro de conteúdo para usar o QuickDrop."; /* No comment provided by engineer. */ "NFiles" = "%d ficheiros"; diff --git a/NearDrop/ro.lproj/Localizable.strings b/NearDrop/ro.lproj/Localizable.strings index d4e14ba..19929ae 100644 --- a/NearDrop/ro.lproj/Localizable.strings +++ b/NearDrop/ro.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "Eroare de comunicare"; +"Error.PacketFilter" = "Este posibil ca Mac-ul tău să aibă un filtru de pachete defect activat. Deschide Preferințe de sistem > Rețea > VPN și Filtru și dezactivează filtrul de conținut pentru a folosi QuickDrop."; /* No comment provided by engineer. */ "NFiles" = "%d fișiere"; diff --git a/NearDrop/ru.lproj/Localizable.strings b/NearDrop/ru.lproj/Localizable.strings index 14e06fe..6de19b5 100644 --- a/NearDrop/ru.lproj/Localizable.strings +++ b/NearDrop/ru.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "Ошибка протокола"; +"Error.PacketFilter" = "На вашем Mac может быть включен неисправный фильтр пакетов. Откройте Системные настройки > Сеть > VPN и фильтры и отключите фильтр содержимого, чтобы использовать QuickDrop."; /* No comment provided by engineer. */ /*"NFiles" = "%d файлов";*/ diff --git a/NearDrop/th.lproj/Localizable.strings b/NearDrop/th.lproj/Localizable.strings index 9ac69ae..1ab3617 100644 --- a/NearDrop/th.lproj/Localizable.strings +++ b/NearDrop/th.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "การสื่อสารผิดพลาด"; +"Error.PacketFilter" = "Mac ของคุณอาจเปิดใช้ตัวกรองแพ็กเกจที่มีปัญหาอยู่ เปิดการตั้งค่าระบบ > เครือข่าย > VPN และตัวกรอง แล้วปิดตัวกรองเนื้อหาเพื่อใช้งาน QuickDrop"; /* No comment provided by engineer. */ "NFiles" = "%d ไฟล์"; diff --git a/NearDrop/uk.lproj/Localizable.strings b/NearDrop/uk.lproj/Localizable.strings index 55b4596..9babd97 100644 --- a/NearDrop/uk.lproj/Localizable.strings +++ b/NearDrop/uk.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "Помилка протоколу"; +"Error.PacketFilter" = "На вашому Mac може бути ввімкнено несправний фільтр пакетів. Відкрийте Системні налаштування > Мережа > VPN і фільтр та вимкніть фільтр вмісту, щоб скористатися QuickDrop."; /* No comment provided by engineer. */ "NFiles" = "%d files"; diff --git a/NearDrop/zh-Hans.lproj/Localizable.strings b/NearDrop/zh-Hans.lproj/Localizable.strings index 206fd0f..d42f958 100644 --- a/NearDrop/zh-Hans.lproj/Localizable.strings +++ b/NearDrop/zh-Hans.lproj/Localizable.strings @@ -15,6 +15,7 @@ /* No comment provided by engineer. */ "Error.Protocol" = "通信出错"; +"Error.PacketFilter" = "你的 Mac 可能启用了有故障的数据包过滤器。请打开系统设置 > 网络 > VPN 与过滤器,并禁用内容过滤器以使用 QuickDrop。"; /* No comment provided by engineer. */ "NFiles" = "%d files"; diff --git a/NearbyShare/InboundNearbyConnection.swift b/NearbyShare/InboundNearbyConnection.swift index c9942ae..d88a8ba 100644 --- a/NearbyShare/InboundNearbyConnection.swift +++ b/NearbyShare/InboundNearbyConnection.swift @@ -67,30 +67,16 @@ class InboundNearbyConnection: NearbyConnection { let frame = try Location_Nearby_Connections_OfflineFrame(serializedBytes: frameData) try processConnectionResponseFrame(frame) default: - var smsg: Securemessage_SecureMessage do { - smsg = try Securemessage_SecureMessage(serializedBytes: frameData) + let smsg = try Securemessage_SecureMessage(serializedBytes: frameData) + try decryptAndProcessReceivedSecureMessage(smsg) } catch { - log("Error deserializing secure message. Trying again....") - - // last 32 bytes = HMAC key - // change 2 bytes before to 0x12 0x20 for Protobuf to succeed - - if frameData.count < 34 { - throw NearbyError.protocolError("Frame too short") - } - - var newData = frameData - let count = newData.count - newData[count - 34] = 0x12 - newData[count - 33] = 0x20 - - smsg = try Securemessage_SecureMessage(serializedBytes: newData) - - log("Secure message deserialized successfully after fixing Protobuf message") + + log("Error deserializing secure message (probably due to packet filter)") + lastError = NearbyError.packetFilterError + protocolError() } - try decryptAndProcessReceivedSecureMessage(smsg) } } catch { lastError = error diff --git a/NearbyShare/NearbyConnectionManager.swift b/NearbyShare/NearbyConnectionManager.swift index 75b661c..442a797 100644 --- a/NearbyShare/NearbyConnectionManager.swift +++ b/NearbyShare/NearbyConnectionManager.swift @@ -52,6 +52,7 @@ public enum NearbyError: Error { case protocolError(_ message: String) case requiredFieldMissing(_ message: String) case ukey2 + case packetFilterError case inputOutput case canceled(reason: CancellationReason)