Linux + iPhone Continuity / iMessage / SMS
fix: improve pairing reliability and connection status
brynnb3adc7f354ffc
diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.mdindex 202cdde..2698ac6 100644--- a/docs/PROTOCOL.md+++ b/docs/PROTOCOL.md@@ -175,7 +175,9 @@ Instructs the daemon to asynchronously reach out to a specific host to initiate### `accept_device` (Local Client -> Daemon)Trusts a pending pair request by moving the target fingerprint into the daemon's internal secure `known_hosts.json`.**Payload**: `{"command": "accept_device", "fingerprint": "12:aa:bb:cc..."}`-**Response**: The daemon synchronously broadcasts `pair_accepted` with the `fingerprint` and resolved `device_name`.+**Response**: The daemon promotes any matching live TLS session, notifies the phone and local subscribers,+then replies with `{"command":"accept_device_result","accepted":true,"connected":true}`. `connected` is false+when the trust record was saved for a device that is no longer connected.### `send_file` (Local Client -> Daemon)Offloads an entire file transfer to the daemon. The daemon spawns a thread to read the local filesystem and pushes the chunks sequence securely.diff --git a/po/cs.po b/po/cs.poindex f40e356..bbb1dcf 100644--- a/po/cs.po+++ b/po/cs.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Czech\n"@@ -930,6 +930,10 @@ msgstr "Zatím nepřipojeno."msgid "Bluetooth is unavailable on this machine."msgstr "Bluetooth není na tomto stroji dostupné."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "Hledání zařízení v okolí..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "Plný režim — zprávy, kontakty a oznámení."@@ -1059,10 +1063,6 @@ msgstr ""msgid "Unknown Device"msgstr "Neznámé zařízení"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "Hledání zařízení v okolí..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "Připojeno"@@ -1075,6 +1075,10 @@ msgstr "Offline"msgid "Nearby (Tap to Pair)"msgstr "V okolí (klepnutím spárujete)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "Částečně připojeno"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "Spárováno"@@ -1290,6 +1294,14 @@ msgstr "Včera"msgid "Today"msgstr "Dnes"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "Pro synchronizaci zpráv je potřeba připojení Bluetooth."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "Vyberte konverzaci"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Odesílání…"@@ -1326,10 +1338,6 @@ msgstr "Nová zpráva"msgid "Search conversations"msgstr "Hledat konverzace"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "Vyberte konverzaci"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "Komu:"diff --git a/po/de.po b/po/de.poindex 08446fc..3f5fbd4 100644--- a/po/de.po+++ b/po/de.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-22\n""Last-Translator: Tether project\n""Language-Team: German\n"@@ -950,6 +950,10 @@ msgstr "Noch nicht verbunden."msgid "Bluetooth is unavailable on this machine."msgstr "Bluetooth ist auf diesem Rechner nicht verfügbar."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "Suche nach Geräten in der Nähe..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "Vollmodus — Nachrichten, Kontakte und Mitteilungen."@@ -1085,10 +1089,6 @@ msgstr ""msgid "Unknown Device"msgstr "Unbekanntes Gerät"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "Suche nach Geräten in der Nähe..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "Verbunden"@@ -1101,6 +1101,10 @@ msgstr "Offline"msgid "Nearby (Tap to Pair)"msgstr "In der Nähe (zum Koppeln tippen)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "Teilweise verbunden"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "Gekoppelt"@@ -1316,6 +1320,16 @@ msgstr "Gestern"msgid "Today"msgstr "Heute"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr ""+"Zum Synchronisieren von Nachrichten ist eine Bluetooth-Verbindung "+"erforderlich."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "Wählen Sie eine Unterhaltung"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Wird gesendet…"@@ -1355,10 +1369,6 @@ msgstr "Neue Nachricht"msgid "Search conversations"msgstr "Unterhaltungen durchsuchen"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "Wählen Sie eine Unterhaltung"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "An:"diff --git a/po/es.po b/po/es.poindex 83e91c9..1fd36fc 100644--- a/po/es.po+++ b/po/es.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-22\n""Last-Translator: Tether project\n""Language-Team: Spanish\n"@@ -943,6 +943,10 @@ msgstr "Aún no conectado."msgid "Bluetooth is unavailable on this machine."msgstr "Bluetooth no está disponible en este equipo."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "Buscando dispositivos cercanos..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "Modo completo — mensajes, contactos y notificaciones."@@ -1076,10 +1080,6 @@ msgstr ""msgid "Unknown Device"msgstr "Dispositivo desconocido"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "Buscando dispositivos cercanos..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "Conectado"@@ -1092,6 +1092,10 @@ msgstr "Desconectado"msgid "Nearby (Tap to Pair)"msgstr "Cerca (toque para emparejar)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "Parcialmente conectado"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "Emparejado"@@ -1307,6 +1311,14 @@ msgstr "Ayer"msgid "Today"msgstr "Hoy"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "Se necesita una conexión Bluetooth para sincronizar los mensajes."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "Seleccione una conversación"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Enviando…"@@ -1344,10 +1356,6 @@ msgstr "Mensaje nuevo"msgid "Search conversations"msgstr "Buscar conversaciones"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "Seleccione una conversación"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "Para:"diff --git a/po/fr.po b/po/fr.poindex ec86f1b..64d9169 100644--- a/po/fr.po+++ b/po/fr.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-22\n""Last-Translator: Tether project\n""Language-Team: French\n"@@ -948,6 +948,10 @@ msgstr "Pas encore connecté."msgid "Bluetooth is unavailable on this machine."msgstr "Bluetooth est indisponible sur cette machine."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "Recherche d'appareils à proximité..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "Mode complet — messages, contacts et notifications."@@ -1082,10 +1086,6 @@ msgstr ""msgid "Unknown Device"msgstr "Appareil inconnu"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "Recherche d'appareils à proximité..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "Connecté"@@ -1098,6 +1098,10 @@ msgstr "Hors ligne"msgid "Nearby (Tap to Pair)"msgstr "À proximité (toucher pour appairer)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "Partiellement connecté"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "Appairé"@@ -1313,6 +1317,14 @@ msgstr "Hier"msgid "Today"msgstr "Aujourd'hui"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "Une connexion Bluetooth est nécessaire pour synchroniser les messages."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "Sélectionnez une conversation"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Envoi…"@@ -1350,10 +1362,6 @@ msgstr "Nouveau message"msgid "Search conversations"msgstr "Rechercher des conversations"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "Sélectionnez une conversation"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "À :"diff --git a/po/it.po b/po/it.poindex fb501ab..327dc1f 100644--- a/po/it.po+++ b/po/it.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Italian\n"@@ -942,6 +942,10 @@ msgstr "Non ancora connesso."msgid "Bluetooth is unavailable on this machine."msgstr "Bluetooth non è disponibile su questa macchina."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "Ricerca di dispositivi nelle vicinanze..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "Modalità completa — messaggi, contatti e notifiche."@@ -1073,10 +1077,6 @@ msgstr "Nessun iPhone accoppiato è connesso. Apri l'app Tether sul telefono."msgid "Unknown Device"msgstr "Dispositivo sconosciuto"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "Ricerca di dispositivi nelle vicinanze..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "Connesso"@@ -1089,6 +1089,10 @@ msgstr "Offline"msgid "Nearby (Tap to Pair)"msgstr "Nelle vicinanze (tocca per accoppiare)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "Parzialmente connesso"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "Accoppiato"@@ -1303,6 +1307,14 @@ msgstr "Ieri"msgid "Today"msgstr "Oggi"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "È necessaria una connessione Bluetooth per sincronizzare i messaggi."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "Seleziona una conversazione"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Invio…"@@ -1342,10 +1354,6 @@ msgstr "Nuovo messaggio"msgid "Search conversations"msgstr "Cerca conversazioni"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "Seleziona una conversazione"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "A:"diff --git a/po/ja.po b/po/ja.poindex 97e5ba9..dcd4a1f 100644--- a/po/ja.po+++ b/po/ja.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Japanese\n"@@ -913,6 +913,10 @@ msgstr "まだ接続していません。"msgid "Bluetooth is unavailable on this machine."msgstr "このマシンでは Bluetooth を利用できません。"+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "近くのデバイスを検索しています..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "フルモード — メッセージ、連絡先、通知。"@@ -1045,10 +1049,6 @@ msgstr ""msgid "Unknown Device"msgstr "不明なデバイス"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "近くのデバイスを検索しています..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "接続済み"@@ -1061,6 +1061,10 @@ msgstr "オフライン"msgid "Nearby (Tap to Pair)"msgstr "近くにあります (タップしてペアリング)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "部分的に接続"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "ペアリング済み"@@ -1272,6 +1276,14 @@ msgstr "昨日"msgid "Today"msgstr "今日"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "メッセージの同期にはBluetooth接続が必要です。"++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "会話を選択"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "送信中…"@@ -1310,10 +1322,6 @@ msgstr "新規メッセージ"msgid "Search conversations"msgstr "会話を検索"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "会話を選択"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "宛先:"diff --git a/po/ko.po b/po/ko.poindex 94f1488..731b598 100644--- a/po/ko.po+++ b/po/ko.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Korean\n"@@ -907,6 +907,10 @@ msgstr "아직 연결되지 않았습니다."msgid "Bluetooth is unavailable on this machine."msgstr "이 컴퓨터에서는 Bluetooth를 사용할 수 없습니다."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "근처 기기를 검색하는 중..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "전체 모드 — 메시지, 연락처, 알림."@@ -1035,10 +1039,6 @@ msgstr "연결된 페어링 iPhone이 없습니다. iPhone에서 Tether 앱을msgid "Unknown Device"msgstr "알 수 없는 기기"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "근처 기기를 검색하는 중..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "연결됨"@@ -1051,6 +1051,10 @@ msgstr "오프라인"msgid "Nearby (Tap to Pair)"msgstr "근처 (탭하여 페어링)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "부분적으로 연결됨"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "페어링됨"@@ -1260,6 +1264,14 @@ msgstr "어제"msgid "Today"msgstr "오늘"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "메시지를 동기화하려면 Bluetooth 연결이 필요합니다."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "대화 선택"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "보내는 중…"@@ -1296,10 +1308,6 @@ msgstr "새 메시지"msgid "Search conversations"msgstr "대화 검색"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "대화 선택"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "받는 사람:"diff --git a/po/nl.po b/po/nl.poindex bc2bec2..d9a4a49 100644--- a/po/nl.po+++ b/po/nl.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Dutch\n"@@ -937,6 +937,10 @@ msgstr "Nog niet verbonden."msgid "Bluetooth is unavailable on this machine."msgstr "Bluetooth is niet beschikbaar op deze machine."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "Zoeken naar apparaten in de buurt..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "Volledige modus — berichten, contacten en meldingen."@@ -1069,10 +1073,6 @@ msgstr ""msgid "Unknown Device"msgstr "Onbekend apparaat"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "Zoeken naar apparaten in de buurt..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "Verbonden"@@ -1085,6 +1085,10 @@ msgstr "Offline"msgid "Nearby (Tap to Pair)"msgstr "In de buurt (tik om te koppelen)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "Gedeeltelijk verbonden"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "Gekoppeld"@@ -1299,6 +1303,14 @@ msgstr "Gisteren"msgid "Today"msgstr "Vandaag"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "Er is een Bluetooth-verbinding nodig om berichten te synchroniseren."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "Selecteer een gesprek"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Versturen…"@@ -1335,10 +1347,6 @@ msgstr "Nieuw bericht"msgid "Search conversations"msgstr "Gesprekken doorzoeken"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "Selecteer een gesprek"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "Aan:"diff --git a/po/pl.po b/po/pl.poindex cf51407..9ec25a8 100644--- a/po/pl.po+++ b/po/pl.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Polish\n"@@ -940,6 +940,10 @@ msgstr "Jeszcze nie połączono."msgid "Bluetooth is unavailable on this machine."msgstr "Bluetooth jest niedostępny na tej maszynie."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "Wyszukiwanie urządzeń w pobliżu..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "Tryb pełny — wiadomości, kontakty i powiadomienia."@@ -1071,10 +1075,6 @@ msgstr ""msgid "Unknown Device"msgstr "Nieznane urządzenie"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "Wyszukiwanie urządzeń w pobliżu..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "Połączono"@@ -1087,6 +1087,10 @@ msgstr "Offline"msgid "Nearby (Tap to Pair)"msgstr "W pobliżu (dotknij, aby sparować)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "Częściowo połączono"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "Sparowano"@@ -1303,6 +1307,14 @@ msgstr "Wczoraj"msgid "Today"msgstr "Dzisiaj"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "Do synchronizacji wiadomości wymagane jest połączenie Bluetooth."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "Wybierz rozmowę"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Wysyłanie…"@@ -1341,10 +1353,6 @@ msgstr "Nowa wiadomość"msgid "Search conversations"msgstr "Szukaj rozmów"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "Wybierz rozmowę"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "Do:"diff --git a/po/pt_BR.po b/po/pt_BR.poindex 7b94fd7..9fbebc6 100644--- a/po/pt_BR.po+++ b/po/pt_BR.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Brazilian Portuguese\n"@@ -937,6 +937,10 @@ msgstr "Ainda não conectado."msgid "Bluetooth is unavailable on this machine."msgstr "O Bluetooth está indisponível nesta máquina."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "Procurando dispositivos por perto..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "Modo completo — mensagens, contatos e notificações."@@ -1067,10 +1071,6 @@ msgstr "Nenhum iPhone pareado está conectado. Abra o app Tether no telefone."msgid "Unknown Device"msgstr "Dispositivo desconhecido"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "Procurando dispositivos por perto..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "Conectado"@@ -1083,6 +1083,10 @@ msgstr "Offline"msgid "Nearby (Tap to Pair)"msgstr "Por perto (toque para parear)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "Parcialmente conectado"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "Pareado"@@ -1297,6 +1301,14 @@ msgstr "Ontem"msgid "Today"msgstr "Hoje"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "É necessária uma conexão Bluetooth para sincronizar as mensagens."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "Selecione uma conversa"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Enviando…"@@ -1334,10 +1346,6 @@ msgstr "Nova mensagem"msgid "Search conversations"msgstr "Pesquisar conversas"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "Selecione uma conversa"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "Para:"diff --git a/po/ru.po b/po/ru.poindex a92b6cd..6c4235b 100644--- a/po/ru.po+++ b/po/ru.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Russian\n"@@ -938,6 +938,10 @@ msgstr "Ещё не подключено."msgid "Bluetooth is unavailable on this machine."msgstr "Bluetooth недоступен на этой машине."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "Поиск устройств поблизости..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "Полный режим — сообщения, контакты и уведомления."@@ -1071,10 +1075,6 @@ msgstr ""msgid "Unknown Device"msgstr "Неизвестное устройство"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "Поиск устройств поблизости..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "Подключено"@@ -1087,6 +1087,10 @@ msgstr "Не в сети"msgid "Nearby (Tap to Pair)"msgstr "Поблизости (нажмите, чтобы создать пару)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "Подключено частично"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "Сопряжено"@@ -1303,6 +1307,14 @@ msgstr "Вчера"msgid "Today"msgstr "Сегодня"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "Для синхронизации сообщений требуется подключение Bluetooth."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "Выберите переписку"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Отправка…"@@ -1339,10 +1351,6 @@ msgstr "Новое сообщение"msgid "Search conversations"msgstr "Поиск переписок"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "Выберите переписку"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "Кому:"diff --git a/po/sv.po b/po/sv.poindex d70162b..0ba4cea 100644--- a/po/sv.po+++ b/po/sv.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Swedish\n"@@ -925,6 +925,10 @@ msgstr "Inte ansluten ännu."msgid "Bluetooth is unavailable on this machine."msgstr "Bluetooth är otillgängligt på den här maskinen."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "Söker efter enheter i närheten..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "Fullt läge — meddelanden, kontakter och aviseringar."@@ -1054,10 +1058,6 @@ msgstr "Ingen parkopplad iPhone är ansluten. Öppna Tether-appen på telefonen.msgid "Unknown Device"msgstr "Okänd enhet"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "Söker efter enheter i närheten..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "Ansluten"@@ -1070,6 +1070,10 @@ msgstr "Offline"msgid "Nearby (Tap to Pair)"msgstr "I närheten (tryck för att parkoppla)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "Delvis ansluten"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "Parkopplad"@@ -1285,6 +1289,14 @@ msgstr "Igår"msgid "Today"msgstr "Idag"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "En Bluetooth-anslutning krävs för att synkronisera meddelanden."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "Välj en konversation"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Skickar…"@@ -1321,10 +1333,6 @@ msgstr "Nytt meddelande"msgid "Search conversations"msgstr "Sök konversationer"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "Välj en konversation"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "Till:"diff --git a/po/tether.pot b/po/tether.potindex 4afc9f8..02fb176 100644--- a/po/tether.pot+++ b/po/tether.pot@@ -6,9 +6,9 @@#, fuzzymsgid ""msgstr ""-"Project-Id-Version: tether 0.2.18\n"+"Project-Id-Version: tether 0.2.19\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Language-Team: LANGUAGE <[email protected]>\n"@@ -837,6 +837,10 @@ msgstr ""msgid "Bluetooth is unavailable on this machine."msgstr ""+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr ""+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr ""@@ -960,10 +964,6 @@ msgstr ""msgid "Unknown Device"msgstr ""-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr ""-#: src/gtk/devices_view.cppmsgid "Connected"msgstr ""@@ -976,6 +976,10 @@ msgstr ""msgid "Nearby (Tap to Pair)"msgstr ""+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr ""+#: src/gtk/devices_view.cppmsgid "Paired"msgstr ""@@ -1166,6 +1170,14 @@ msgstr ""msgid "Today"msgstr ""+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr ""++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr ""+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr ""@@ -1202,10 +1214,6 @@ msgstr ""msgid "Search conversations"msgstr ""-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr ""-#: src/gtk/messages_view.cppmsgid "To:"msgstr ""diff --git a/po/tr.po b/po/tr.poindex 0e21737..33d5d57 100644--- a/po/tr.po+++ b/po/tr.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Turkish\n"@@ -924,6 +924,10 @@ msgstr "Henüz bağlanmadı."msgid "Bluetooth is unavailable on this machine."msgstr "Bu makinede Bluetooth kullanılamıyor."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "Yakındaki aygıtlar taranıyor..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "Tam kip — mesajlar, kişiler ve bildirimler."@@ -1052,10 +1056,6 @@ msgstr ""msgid "Unknown Device"msgstr "Bilinmeyen aygıt"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "Yakındaki aygıtlar taranıyor..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "Bağlandı"@@ -1068,6 +1068,10 @@ msgstr "Çevrimdışı"msgid "Nearby (Tap to Pair)"msgstr "Yakında (eşleşmek için dokunun)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "Kısmen bağlı"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "Eşleşti"@@ -1282,6 +1286,14 @@ msgstr "Dün"msgid "Today"msgstr "Bugün"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "Mesajları eşitlemek için Bluetooth bağlantısı gerekli."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "Bir konuşma seçin"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Gönderiliyor…"@@ -1318,10 +1330,6 @@ msgstr "Yeni mesaj"msgid "Search conversations"msgstr "Konuşmalarda ara"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "Bir konuşma seçin"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "Kime:"diff --git a/po/uk.po b/po/uk.poindex c4fc407..fb7aa5c 100644--- a/po/uk.po+++ b/po/uk.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Ukrainian\n"@@ -935,6 +935,10 @@ msgstr "Ще не під'єднано."msgid "Bluetooth is unavailable on this machine."msgstr "Bluetooth недоступний на цій машині."+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "Пошук пристроїв поблизу..."+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "Повний режим — повідомлення, контакти та сповіщення."@@ -1067,10 +1071,6 @@ msgstr ""msgid "Unknown Device"msgstr "Невідомий пристрій"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "Пошук пристроїв поблизу..."-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "Під'єднано"@@ -1083,6 +1083,10 @@ msgstr "Не в мережі"msgid "Nearby (Tap to Pair)"msgstr "Поблизу (торкніться, щоб створити пару)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "Під'єднано частково"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "Спарено"@@ -1299,6 +1303,14 @@ msgstr "Учора"msgid "Today"msgstr "Сьогодні"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "Для синхронізації повідомлень потрібне з’єднання Bluetooth."++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "Виберіть розмову"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "Надсилання…"@@ -1336,10 +1348,6 @@ msgstr "Нове повідомлення"msgid "Search conversations"msgstr "Пошук розмов"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "Виберіть розмову"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "Кому:"diff --git a/po/zh_CN.po b/po/zh_CN.poindex b8318fa..b5330aa 100644--- a/po/zh_CN.po+++ b/po/zh_CN.po@@ -8,7 +8,7 @@ msgid ""msgstr """Project-Id-Version: tether\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-30 11:33-0700\n"+"POT-Creation-Date: 2026-08-31 19:04-0700\n""PO-Revision-Date: 2026-08-23\n""Last-Translator: Tether project\n""Language-Team: Simplified Chinese\n"@@ -886,6 +886,10 @@ msgstr "尚未连接。"msgid "Bluetooth is unavailable on this machine."msgstr "这台机器上蓝牙不可用。"+#: src/gtk/devices_view.cpp+msgid "Scanning for nearby devices..."+msgstr "正在搜索附近的设备……"+#: src/gtk/devices_view.cppmsgid "Full mode — messages, contacts, and notifications."msgstr "完整模式 —— 信息、通讯录和通知。"@@ -1013,10 +1017,6 @@ msgstr "没有已配对的 iPhone 处于连接状态。请在 iPhone 上打开 Tmsgid "Unknown Device"msgstr "未知设备"-#: src/gtk/devices_view.cpp-msgid "Scanning for nearby devices..."-msgstr "正在搜索附近的设备……"-#: src/gtk/devices_view.cppmsgid "Connected"msgstr "已连接"@@ -1029,6 +1029,10 @@ msgstr "离线"msgid "Nearby (Tap to Pair)"msgstr "附近(轻点以配对)"+#: src/gtk/devices_view.cpp+msgid "Partially connected"+msgstr "部分连接"+#: src/gtk/devices_view.cppmsgid "Paired"msgstr "已配对"@@ -1236,6 +1240,14 @@ msgstr "昨天"msgid "Today"msgstr "今天"+#: src/gtk/messages_view.cpp+msgid "Bluetooth connection needed to sync messages."+msgstr "需要蓝牙连接才能同步消息。"++#: src/gtk/messages_view.cpp+msgid "Select a conversation"+msgstr "选择一个会话"+#: src/gtk/messages_view.cppmsgid "Sending…"msgstr "正在发送……"@@ -1272,10 +1284,6 @@ msgstr "新信息"msgid "Search conversations"msgstr "搜索会话"-#: src/gtk/messages_view.cpp-msgid "Select a conversation"-msgstr "选择一个会话"-#: src/gtk/messages_view.cppmsgid "To:"msgstr "收件人:"diff --git a/src/cli/main.cpp b/src/cli/main.cppindex 4266246..ddb775e 100644--- a/src/cli/main.cpp+++ b/src/cli/main.cpp@@ -787,10 +787,6 @@ int main(int argc, char* argv[]) {if (action == "list") {debug::log(INFO, "{}", client.list_devices());return 0;- } else if (action == "accept") {- client.accept_device(arg_val);- debug::log(INFO, "Successfully paired device: {}", arg_val);- return 0;} else if (action == "discover") {debug::log(INFO, "Scanning for tetherd instances on the local network...\n\n");@@ -840,7 +836,13 @@ int main(int argc, char* argv[]) {}std::string err;- if (action == "pair") {+ if (action == "accept") {+ if (arg_val.empty() || !client.accept_device(arg_val)) {+ debug::log(ERR, _("Could not reach the daemon.\n"));+ return 1;+ }+ debug::log(INFO, "Successfully paired device: {}", arg_val);+ } else if (action == "pair") {char hostname[256] = {};gethostname(hostname, sizeof(hostname) - 1);std::string resp = client.pair(hostname, err);diff --git a/src/core/include/tether/bluetooth/advert.hpp b/src/core/include/tether/bluetooth/advert.hppindex f713aff..f2e6cbd 100644--- a/src/core/include/tether/bluetooth/advert.hpp+++ b/src/core/include/tether/bluetooth/advert.hpp@@ -23,7 +23,7 @@ namespace tether::bluetooth {// Registration is two-phase, and the phases must run on different threads.bool export_object();- bool register_with_bluez();+ bool register_with_bluez(std::string* error = nullptr);void unregister_with_bluez();void unexport_object();diff --git a/src/core/include/tether/bluetooth/monitor.hpp b/src/core/include/tether/bluetooth/monitor.hppindex e898255..45b95b0 100644--- a/src/core/include/tether/bluetooth/monitor.hpp+++ b/src/core/include/tether/bluetooth/monitor.hpp@@ -2,9 +2,11 @@#include "tether/bluetooth/objects.hpp"+#include <chrono>#include <functional>#include <gio/gio.h>#include <memory>+#include <optional>namespace tether::bluetooth {@@ -19,8 +21,9 @@ namespace tether::bluetooth {BluezMonitor(const BluezMonitor&) = delete;BluezMonitor& operator=(const BluezMonitor&) = delete;- // Connects to the system bus and starts the watcher thread. Returns false- // if BlueZ is unreachable; the daemon runs on without Bluetooth support.+ // Connects to the system bus and starts the watcher thread. BlueZ object+ // and controller capability reads happen on that thread so daemon startup+ // and the network event loop never wait for Bluetooth tooling.bool start();void stop();bool running() const;@@ -45,4 +48,11 @@ namespace tether::bluetooth {extern BluezMonitor* g_bluez;+ // BlueZ exposes Secure Connections only through the management interface.+ // Runs btmgmt without a shell and returns no value if it fails or exceeds the+ // deadline. Public so the process boundary and timeout can be tested directly.+ std::optional<bool> probe_secure_connections(+ const std::string& adapter_id,+ std::chrono::milliseconds timeout = std::chrono::seconds(1));+} // namespace tether::bluetoothdiff --git a/src/core/include/tether/bluetooth/objects.hpp b/src/core/include/tether/bluetooth/objects.hppindex 3e4f982..dac5feb 100644--- a/src/core/include/tether/bluetooth/objects.hpp+++ b/src/core/include/tether/bluetooth/objects.hpp@@ -3,6 +3,7 @@#include <cstdint>#include <glib.h>#include <nlohmann/json.hpp>+#include <optional>#include <string>#include <vector>@@ -131,7 +132,12 @@ namespace tether::bluetooth {// result for null or unexpected input rather than throwing.BluezObjects parse_managed_objects(GVariant* reply);- Capability resolve_capability(const BluezObjects& objects);+ // Resolves the pure ObjectManager snapshot plus the optional controller+ // setting read by BluezMonitor. Keeping the external btmgmt probe out of+ // this function makes capability resolution deterministic and prevents a+ // stalled controller query from blocking unrelated callers.+ Capability resolve_capability(const BluezObjects& objects,+ std::optional<bool> secure_connections = std::nullopt);nlohmann::json to_json(const Adapter& adapter);nlohmann::json to_json(const Device& device);diff --git a/src/core/include/tether/net.hpp b/src/core/include/tether/net.hppindex d39c38e..6096d19 100644--- a/src/core/include/tether/net.hpp+++ b/src/core/include/tether/net.hpp@@ -48,7 +48,7 @@ namespace tether {class UnixServer {public:- UnixServer(EpollEventLoop& loop);+ UnixServer(EpollEventLoop& loop, TcpServer& tcp_server);~UnixServer();bool start();@@ -59,6 +59,7 @@ namespace tether {void handle_client(int client_fd);EpollEventLoop& loop_;+ TcpServer& tcp_server_;int server_fd_ = -1;std::string socket_path_;std::map<int, std::string> client_buffers_;@@ -73,6 +74,10 @@ namespace tether {bool start();void stop();+ // Trusts a fingerprint and promotes every matching live TLS session.+ // Returns true when at least one connected client was promoted.+ bool accept_device(const std::string& fingerprint, const std::string& fallback_name = "Paired Device");+private:struct ConnectedClientInfo {std::string address;diff --git a/src/core/src/bluetooth/advert.cpp b/src/core/src/bluetooth/advert.cppindex cf2e429..0b78913 100644--- a/src/core/src/bluetooth/advert.cpp+++ b/src/core/src/bluetooth/advert.cpp@@ -18,8 +18,8 @@ namespace tether::bluetooth {constexpr const char* ADVERT_MANAGER = "org.bluez.LEAdvertisingManager1";// Private/test identifiers that claim no Apple or hardware-vendor- // identity, following the convention ancs4linux established. No meaning; they exist because the advert iOS- // responds to carries them.+ // identity, following the convention ancs4linux established. No meaning;+ // they exist because the advert iOS responds to carries them.constexpr guint16 INERT_MANUFACTURER_ID = 0xffff;constexpr const char* INERT_SERVICE_UUID = "00009999-0000-1000-8000-00805f9b34fb";@@ -144,7 +144,7 @@ namespace tether::bluetooth {return true;}- bool AncsAdvertisement::register_with_bluez() {+ bool AncsAdvertisement::register_with_bluez(std::string* failure) {if (state_->registered_with_bluez)return true;if (state_->registration_id == 0)@@ -165,7 +165,10 @@ namespace tether::bluetooth {nullptr,&error);if (!reply) {- debug::log(ERR, "bluetooth: RegisterAdvertisement failed: {}", error ? error->message : "unknown");+ const std::string message = error && error->message ? error->message : "unknown error";+ debug::log(ERR, "bluetooth: RegisterAdvertisement failed: {}", message);+ if (failure)+ *failure = message;g_clear_error(&error);return false;}diff --git a/src/core/src/bluetooth/monitor.cpp b/src/core/src/bluetooth/monitor.cppindex 3ffa86a..2ac440d 100644--- a/src/core/src/bluetooth/monitor.cpp+++ b/src/core/src/bluetooth/monitor.cpp@@ -1,13 +1,21 @@#include "tether/bluetooth/monitor.hpp"#include "tether/log.hpp"+#include <algorithm>+#include <array>#include <atomic>#include <chrono>#include <condition_variable>+#include <cerrno>+#include <csignal>+#include <fcntl.h>#include <filesystem>#include <fstream>#include <gio/gio.h>#include <mutex>+#include <optional>+#include <poll.h>+#include <sys/wait.h>#include <sys/eventfd.h>#include <thread>#include <unistd.h>@@ -40,11 +48,15 @@ namespace tether::bluetooth {mutable std::mutex mutex;BluezObjects objects;Capability cap;+ std::string secure_adapter;+ std::optional<bool> secure_connections;+ std::chrono::steady_clock::time_point secure_checked_at{};void run();void refresh();void schedule_refresh();void notify();+ std::optional<bool> read_secure_connections(const std::string& adapter_id);};namespace {@@ -129,6 +141,145 @@ namespace tether::bluetooth {return value;}+ std::optional<bool> probe_secure_connections(const std::string& adapter_id,+ std::chrono::milliseconds timeout) {+ if (adapter_id.empty())+ return std::nullopt;++ std::array<gchar*, 5> argv = {+ const_cast<gchar*>("btmgmt"),+ const_cast<gchar*>("--index"),+ const_cast<gchar*>(adapter_id.c_str()),+ const_cast<gchar*>("info"),+ nullptr,+ };++ GPid child = 0;+ gint output_fd = -1;+ GError* error = nullptr;+ const auto flags = static_cast<GSpawnFlags>(G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD |+ G_SPAWN_STDERR_TO_DEV_NULL | G_SPAWN_CLOEXEC_PIPES);+ if (!g_spawn_async_with_pipes(nullptr,+ argv.data(),+ nullptr,+ flags,+ nullptr,+ nullptr,+ &child,+ nullptr,+ &output_fd,+ nullptr,+ &error)) {+ debug::log(WARN,+ "bluetooth: cannot start btmgmt for {}: {}",+ adapter_id,+ error ? error->message : "unknown error");+ g_clear_error(&error);+ return std::nullopt;+ }++ const int old_flags = fcntl(output_fd, F_GETFL, 0);+ if (old_flags >= 0)+ fcntl(output_fd, F_SETFL, old_flags | O_NONBLOCK);++ std::string output;+ output.reserve(2048);+ int status = 0;+ bool exited = false;+ const auto started = std::chrono::steady_clock::now();+ const auto deadline = started + std::max(timeout, std::chrono::milliseconds::zero());++ auto drain_output = [&] {+ char buffer[1024];+ for (;;) {+ const ssize_t count = read(output_fd, buffer, sizeof(buffer));+ if (count > 0) {+ if (output.size() < 64 * 1024)+ output.append(buffer, std::min<size_t>(static_cast<size_t>(count), 64 * 1024 - output.size()));+ continue;+ }+ if (count < 0 && errno == EINTR)+ continue;+ break;+ }+ };++ while (std::chrono::steady_clock::now() < deadline) {+ drain_output();+ const pid_t waited = waitpid(child, &status, WNOHANG);+ if (waited == child) {+ exited = true;+ break;+ }+ if (waited < 0 && errno != EINTR)+ break;++ const auto remaining = std::chrono::duration_cast<std::chrono::milliseconds>(+ deadline - std::chrono::steady_clock::now());+ pollfd watched{output_fd, POLLIN | POLLHUP, 0};+ poll(&watched, 1, static_cast<int>(std::clamp<int64_t>(remaining.count(), 1, 50)));+ }++ if (!exited) {+ kill(child, SIGTERM);+ const auto grace_deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(100);+ while (std::chrono::steady_clock::now() < grace_deadline) {+ const pid_t waited = waitpid(child, &status, WNOHANG);+ if (waited == child) {+ exited = true;+ break;+ }+ if (waited < 0 && errno != EINTR)+ break;+ std::this_thread::sleep_for(std::chrono::milliseconds(5));+ }+ if (!exited) {+ kill(child, SIGKILL);+ while (waitpid(child, &status, 0) < 0 && errno == EINTR) {+ }+ }++ const auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(+ std::chrono::steady_clock::now() - started);+ debug::log(WARN, "bluetooth: btmgmt info for {} timed out after {}ms", adapter_id, elapsed.count());+ close(output_fd);+ g_spawn_close_pid(child);+ return std::nullopt;+ }++ drain_output();+ close(output_fd);+ g_spawn_close_pid(child);+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)+ return std::nullopt;++ const size_t settings = output.find("current settings:");+ if (settings == std::string::npos)+ return std::nullopt;+ const size_t line_end = output.find('\n', settings);+ const std::string line = output.substr(settings, line_end - settings);+ return line.find("secure-conn") != std::string::npos;+ }++ std::optional<bool> MonitorState::read_secure_connections(const std::string& adapter_id) {+ constexpr auto RECHECK_AFTER = std::chrono::seconds(30);+ if (adapter_id.empty()) {+ secure_adapter.clear();+ secure_connections.reset();+ secure_checked_at = {};+ return std::nullopt;+ }++ const auto now = std::chrono::steady_clock::now();+ if (adapter_id != secure_adapter || secure_checked_at == std::chrono::steady_clock::time_point{} ||+ now - secure_checked_at >= RECHECK_AFTER) {+ secure_adapter = adapter_id;+ secure_connections = probe_secure_connections(adapter_id);+ secure_checked_at = std::chrono::steady_clock::now();+ }+ return secure_connections;+ }+void MonitorState::refresh() {GError* error = nullptr;GVariant* reply = g_dbus_connection_call_sync(conn,@@ -152,6 +303,7 @@ namespace tether::bluetooth {g_variant_unref(reply);parsed.experimental_api = bluetoothd_has_experimental();Capability resolved = resolve_capability(parsed);+ resolved = resolve_capability(parsed, read_secure_connections(resolved.adapter_id));{std::lock_guard<std::mutex> lock(mutex);@@ -223,29 +375,6 @@ namespace tether::bluetooth {return false;}- // fail fast when bluetoothd is not present- GVariant* probe = g_dbus_connection_call_sync(impl_->conn,- BLUEZ_NAME,- "/",- OBJECT_MANAGER,- "GetManagedObjects",- nullptr,- G_VARIANT_TYPE("(a{oa{sa{sv}}})"),- G_DBUS_CALL_FLAGS_NONE,- 5000,- nullptr,- &error);- if (!probe) {- debug::log(WARN, "bluetooth: BlueZ unavailable: {}", error ? error->message : "unknown");- g_clear_error(&error);- g_clear_object(&impl_->conn);- return false;- }- impl_->objects = parse_managed_objects(probe);- impl_->objects.experimental_api = bluetoothd_has_experimental();- impl_->cap = resolve_capability(impl_->objects);- g_variant_unref(probe);-impl_->efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);if (impl_->efd < 0) {debug::log(ERR, "bluetooth: eventfd() failed");diff --git a/src/core/src/bluetooth/objects.cpp b/src/core/src/bluetooth/objects.cppindex be6683c..810a25f 100644--- a/src/core/src/bluetooth/objects.cpp+++ b/src/core/src/bluetooth/objects.cpp@@ -2,7 +2,6 @@#include <tether/i18n.hpp>#include <algorithm>-#include <cstdio>#include <cstring>#include <filesystem>@@ -284,35 +283,6 @@ namespace tether::bluetooth {return "/usr/lib/bluetooth/bluetoothd";}- // Reads the controller's current mgmt settings. BlueZ exposes Secure- // Connections nowhere on D-Bus, and it is the precondition for the- // cross-transport key derivation that gives a BR/EDR bond its LE half.- // without it the bond is Classic-only and ANCS is unreachable, which is- // otherwise indistinguishable from a dozen other failures.- //- // TODO: shelling out to btmgmt, which reads the mgmt socket- // unprivileged. Only worth opening an AF_BLUETOOTH mgmt socket here if- // this ever needs to run somewhere btmgmt is not installed.- bool read_secure_connections(const std::string& adapter_id, bool& enabled) {- const std::string cmd = "btmgmt --index " + adapter_id + " info 2>/dev/null";- FILE* pipe = popen(cmd.c_str(), "r");- if (!pipe)- return false;-- bool found = false;- char line[1024];- while (std::fgets(line, sizeof(line), pipe)) {- const std::string text(line);- if (text.find("current settings:") == std::string::npos)- continue;- enabled = text.find("secure-conn") != std::string::npos;- found = true;- break;- }- pclose(pipe);- return found;- }-// The package ships the drop-in for the user to copy.std::string enable_experimental_command() {const std::string shipped = std::string(TETHER_DATADIR) + "/bluetooth-experimental.conf";@@ -334,7 +304,7 @@ namespace tether::bluetooth {} // namespace- Capability resolve_capability(const BluezObjects& objects) {+ Capability resolve_capability(const BluezObjects& objects, std::optional<bool> secure_connections) {Capability cap;// prefer powered adapter, fall back to the first so the reasons below@@ -380,7 +350,10 @@ namespace tether::bluetooth {if (cap.bearer_api != BearerApi::Confirmed)cap.bearer_api = objects.experimental_api ? BearerApi::Unknown : BearerApi::Absent;- cap.secure_connections_known = read_secure_connections(cap.adapter_id, cap.secure_connections);+ if (secure_connections.has_value()) {+ cap.secure_connections_known = true;+ cap.secure_connections = *secure_connections;+ }if (!cap.powered) {cap.reasons.emplace_back(_("Bluetooth adapter is powered off."));diff --git a/src/core/src/bluetooth/pairing.cpp b/src/core/src/bluetooth/pairing.cppindex 809a2fc..20d099a 100644--- a/src/core/src/bluetooth/pairing.cpp+++ b/src/core/src/bluetooth/pairing.cpp@@ -330,14 +330,16 @@ namespace tether::bluetooth {monitor.invoke_sync([&] { exported = advert->export_object(); });// BlueZ reads the advertisement's properties back before returning, so// this call must stay off the thread that answers those reads.- if (exported && advert->register_with_bluez()) {+ std::string registration_error;+ if (exported && advert->register_with_bluez(®istration_error)) {g_advert = advert;return true;}monitor.invoke_sync([&] { advert->unexport_object(); });delete advert;- err = "Could not advertise for ANCS. The controller may have no free LE advertising instance.";+ err = registration_error.empty() ? "Could not prepare the ANCS advertisement."+ : "Could not advertise for ANCS: " + registration_error;return false;}diff --git a/src/core/src/client.cpp b/src/core/src/client.cppindex 302bd37..4575dd8 100644--- a/src/core/src/client.cpp+++ b/src/core/src/client.cpp@@ -240,32 +240,17 @@ namespace tether {}bool Client::accept_device(const std::string& fingerprint, const std::string& name) {- tether::Crypto::instance().init();-- // Check if the daemon stored a name from the pair_request- std::string resolved_name = name;- std::string pending_path = tether::get_runtime_dir() + "/pending_pairs.json";- nlohmann::json pending;-- std::ifstream ifs(pending_path);- if (ifs.is_open()) {- try {- pending = nlohmann::json::parse(ifs);- } catch (...) {- }- ifs.close();- }+ if (!is_connected() || ssl_ || fingerprint.empty())+ return false;- if (pending.contains(fingerprint) && pending[fingerprint].is_string()) {- resolved_name = pending[fingerprint].get<std::string>();- // Remove the accepted entry- pending.erase(fingerprint);- std::ofstream ofs(pending_path);- ofs << pending.dump(4);+ nlohmann::json request{{"command", "accept_device"}, {"fingerprint", fingerprint}, {"device_name", name}};+ const std::string response = send_and_wait(request.dump() + "\n");+ try {+ const auto parsed = nlohmann::json::parse(response);+ return parsed.value("command", "") == "accept_device_result" && parsed.value("accepted", false);+ } catch (...) {+ return false;}-- tether::Crypto::instance().add_known_host(resolved_name, fingerprint);- return true;}std::string Client::pair(const std::string& device_name, std::string& err_out) {diff --git a/src/core/src/net.cpp b/src/core/src/net.cppindex bc57587..67b3a1d 100644--- a/src/core/src/net.cpp+++ b/src/core/src/net.cpp@@ -258,6 +258,11 @@ namespace tether {return pending;}+ static void save_pending_pairs(const nlohmann::json& pending) {+ std::ofstream ofs(get_runtime_dir() + "/pending_pairs.json");+ ofs << pending.dump(4);+ }+static std::string lookup_known_host_name(const std::string& fingerprint) {try {auto known = nlohmann::json::parse(Crypto::instance().get_known_hosts_dump());@@ -671,7 +676,9 @@ namespace tether {// --- UnixServer ---- UnixServer::UnixServer(EpollEventLoop& loop) : loop_(loop) { socket_path_ = get_runtime_dir() + "/tetherd.sock"; }+ UnixServer::UnixServer(EpollEventLoop& loop, TcpServer& tcp_server) : loop_(loop), tcp_server_(tcp_server) {+ socket_path_ = get_runtime_dir() + "/tetherd.sock";+ }UnixServer::~UnixServer() { stop(); }@@ -1066,31 +1073,14 @@ namespace tether {write_plain_packet(client_fd, payload);continue;} else if (j.contains("command") && j["command"] == "accept_device" && j.contains("fingerprint")) {- std::string print = j["fingerprint"];- std::string resolved_name = "Unknown Device";- std::string pending_path = get_runtime_dir() + "/pending_pairs.json";- nlohmann::json pending;- std::ifstream ifs(pending_path);- if (ifs.is_open()) {- try {- pending = nlohmann::json::parse(ifs);- } catch (...) {- }- ifs.close();- }- if (pending.contains(print) && pending[print].is_string()) {- resolved_name = pending[print].get<std::string>();- pending.erase(print);- std::ofstream ofs(pending_path);- ofs << pending.dump(4);- }- Crypto::instance().add_known_host(resolved_name, print);-- nlohmann::json event;- event["command"] = "pair_accepted";- event["fingerprint"] = print;- event["device_name"] = resolved_name;- broadcast_local_event(event.dump());+ const std::string print = j.value("fingerprint", "");+ const std::string fallback_name = j.value("device_name", "Paired Device");+ const bool connected = !print.empty() && tcp_server_.accept_device(print, fallback_name);+ nlohmann::json response{{"command", "accept_device_result"},+ {"accepted", !print.empty()},+ {"connected", connected}};+ write_plain_packet(client_fd, response.dump() + "\n");+ continue;} else if (j.contains("command") && j["command"] == "pair_request" && j.contains("host")) {std::string target_host = j["host"];int target_port = j.value("port", 5134);@@ -1537,6 +1527,79 @@ namespace tether {}}+ bool TcpServer::accept_device(const std::string& fingerprint, const std::string& fallback_name) {+ if (fingerprint.empty())+ return false;++ auto pending = load_pending_pairs();+ std::string device_name = lookup_known_host_name(fingerprint);+ if (device_name.empty())+ device_name = fallback_name.empty() ? "Paired Device" : fallback_name;+ if (pending.contains(fingerprint) && pending[fingerprint].is_string()) {+ device_name = pending[fingerprint].get<std::string>();+ pending.erase(fingerprint);+ save_pending_pairs(pending);+ }++ Crypto::instance().add_known_host(device_name, fingerprint);++ bool promoted = false;+ std::string address;+ for (auto& [client_fd, remote] : connected_remote_clients) {+ if (remote.fingerprint != fingerprint)+ continue;++ auto ssl_it = active_ssl_.find(client_fd);+ auto paired_it = client_paired_.find(client_fd);+ auto info_it = client_info_.find(client_fd);+ if (ssl_it == active_ssl_.end() || paired_it == client_paired_.end() || info_it == client_info_.end())+ continue;++ paired_it->second = true;+ info_it->second.paired = true;+ info_it->second.device_name = device_name;+ remote.paired = true;+ remote.device_name = device_name;+ address = remote.address;+ register_client_ssl(client_fd, ssl_it->second);+ promoted = true;++ nlohmann::json connected_event{{"command", "client_connected"},+ {"fingerprint", fingerprint},+ {"device_name", device_name},+ {"address", remote.address},+ {"paired", true}};+ broadcast_local_event(connected_event.dump());++ nlohmann::json response{{"command", "pair_accepted"}};+ const std::string payload = response.dump() + "\n";+ robust_ssl_write(ssl_it->second, payload.c_str(), payload.size());+ }++ nlohmann::json event{{"command", "pair_accepted"},+ {"fingerprint", fingerprint},+ {"device_name", device_name},+ {"address", address},+ {"connected", promoted}};+ broadcast_local_event(event.dump());++ // An external acceptance supersedes any dialog for the same request.+ // Its exit callback observes the promoted session and ignores the stale+ // non-zero result rather than sending pair_rejected to the phone.+ for (const auto& [read_fd, dialog] : pending_dialogs_) {+ (void)read_fd;+ if (dialog.fingerprint == fingerprint)+ kill(dialog.pid, SIGTERM);+ }++ debug::log(INFO,+ promoted ? "[Pairing Accepted] {} ({}) and live session promoted"+ : "[Pairing Accepted] {} ({}) for the next connection",+ device_name,+ fingerprint);+ return promoted;+ }+void TcpServer::spawn_pair_dialog(int client_fd,SSL* ssl,const std::string& fingerprint,@@ -1645,70 +1708,9 @@ namespace tether {int exit_code = WIFEXITED(status) ? WEXITSTATUS(status) : 3;if (exit_code == 0) {- Crypto::instance().add_known_host(info.device_name, info.fingerprint);- debug::log(INFO, "[Pairing Accepted] {} ({})", info.device_name, info.fingerprint);-- auto remote_it = connected_remote_clients.find(info.client_fd);- auto ssl_it = active_ssl_.find(info.client_fd);-- if (client_paired_.find(info.client_fd) != client_paired_.end()) {- client_paired_[info.client_fd] = true;- }- auto info_it = client_info_.find(info.client_fd);- if (info_it != client_info_.end()) {- info_it->second.paired = true;- info_it->second.device_name = info.device_name;- }- if (remote_it != connected_remote_clients.end()) {- remote_it->second.paired = true;- remote_it->second.device_name = info.device_name;- }-- if (ssl_it != active_ssl_.end()) {- register_client_ssl(info.client_fd, ssl_it->second);- }-- nlohmann::json event;- event["command"] = "pair_accepted";- event["fingerprint"] = info.fingerprint;- event["device_name"] = info.device_name;- if (remote_it != connected_remote_clients.end()) {- event["address"] = remote_it->second.address;- }- broadcast_local_event(event.dump());-- nlohmann::json connected_event;- connected_event["command"] = "client_connected";- connected_event["fingerprint"] = info.fingerprint;- connected_event["device_name"] = info.device_name;- connected_event["paired"] = true;- if (remote_it != connected_remote_clients.end()) {- connected_event["address"] = remote_it->second.address;- }- broadcast_local_event(connected_event.dump());-- if (ssl_it != active_ssl_.end()) {- nlohmann::json resp;- resp["command"] = "pair_accepted";- std::string payload = resp.dump() + "\n";- robust_ssl_write(ssl_it->second, payload.c_str(), payload.size());- }-- std::string pending_path = get_runtime_dir() + "/pending_pairs.json";- nlohmann::json pending;- std::ifstream ifs(pending_path);- if (ifs.is_open()) {- try {- pending = nlohmann::json::parse(ifs);- } catch (...) {- }- ifs.close();- }- if (pending.contains(info.fingerprint)) {- pending.erase(info.fingerprint);- std::ofstream ofs(pending_path);- ofs << pending.dump(4);- }+ accept_device(info.fingerprint, info.device_name);+ } else if (client_paired_.contains(info.client_fd) && client_paired_[info.client_fd]) {+ debug::log(INFO, "Pairing dialog dismissed after {} was accepted elsewhere", info.device_name);} else {if (!bluetooth::dialog_answered(status))diff --git a/src/daemon/main.cpp b/src/daemon/main.cppindex 0fdc7da..2c7aa1a 100644--- a/src/daemon/main.cpp+++ b/src/daemon/main.cpp@@ -71,13 +71,13 @@ int main(int argc, char** argv) {tether::EpollEventLoop loop;g_loop = &loop;- tether::UnixServer unix_srv(loop);+ tether::TcpServer tcp_srv(loop, 5134);+ tether::UnixServer unix_srv(loop, tcp_srv);if (!unix_srv.start()) {debug::log(ERR, "Failed to start Unix server");return 1;}- tether::TcpServer tcp_srv(loop, 5134);if (!tcp_srv.start()) {debug::log(ERR, "Failed to start TCP server");return 1;diff --git a/src/gtk/devices_view.cpp b/src/gtk/devices_view.cppindex ec6dbf3..f1089d0 100644--- a/src/gtk/devices_view.cpp+++ b/src/gtk/devices_view.cpp@@ -41,6 +41,8 @@ namespace tether::ui {GtkWidget* lbl_action_name = nullptr;GtkWidget* lbl_action_status = nullptr;GtkWidget* btn_grid = nullptr;+ GtkWidget* btn_action_bt_pair = nullptr;+ bool select_bt_after_scan = false;GtkWidget* lbl_unpaired_name = nullptr;GtkWidget* lbl_unpaired_ip = nullptr;@@ -135,6 +137,20 @@ namespace tether::ui {void on_bt_ancs_toggled(GtkWidget* widget, gpointer);void on_bt_content_toggled(GtkWidget* widget, gpointer);+ void update_action_bt_scan_controls() {+ if (g_devices.btn_action_bt_pair)+ gtk_widget_set_sensitive(g_devices.btn_action_bt_pair, !g_devices.select_bt_after_scan);+ }++ void on_action_bt_pair_clicked(GtkWidget*, gpointer) {+ g_devices.select_bt_after_scan = true;+ update_action_bt_scan_controls();+ set_status_action(_("Scanning for nearby devices..."));+ set_status_main(_("Scanning for nearby devices..."));+ daemon_send({{"command", "bt_status"}});+ daemon_send({{"command", "bt_scan"}});+ }+void update_bt_pane() {const std::string address = g_devices.selected_bt_address;const nlohmann::json* device = find_bt_device(address);@@ -293,12 +309,20 @@ namespace tether::ui {bool online = std::find(g_devices.connected_fps.begin(),g_devices.connected_fps.end(),g_devices.selected_device_fp) != g_devices.connected_fps.end();- set_status_action(- online ? _("Connected and ready.")- : _("Device is offline. Open the Tether app on iPhone while on the same network."));+ if (g_devices.select_bt_after_scan)+ set_status_action(_("Scanning for nearby devices..."));+ else+ set_status_action(+ online ? _("Connected and ready.")+ : _("Device is offline. Open the Tether app on iPhone while on the same network."));if (g_devices.btn_grid) {gtk_widget_set_visible(g_devices.btn_grid, online);}+ if (g_devices.btn_action_bt_pair) {+ const std::string supervised = g_devices.bt_status.value("device_address", "");+ gtk_widget_set_visible(g_devices.btn_action_bt_pair, supervised.empty());+ }+ update_action_bt_scan_controls();} else {gtk_stack_set_visible_child_name(GTK_STACK(g_devices.right_pane_stack), "pair");set_markup(g_devices.lbl_unpaired_name,@@ -672,6 +696,9 @@ namespace tether::ui {const std::string name = device.value("name", "").empty() ? address : device.value("name", "");const bool paired = device.value("paired", false);const bool connected = device.value("connected", false);+ const bool route_ready = is_supervised_bt_device(address) &&+ (g_devices.bt_connection.value("map_open", false) ||+ g_devices.bt_connection.value("ancs_ready", false));GtkWidget* row = gtk_list_box_row_new();g_object_set_data_full(G_OBJECT(row), "bt_address", g_strdup(address.c_str()), g_free);@@ -690,8 +717,11 @@ namespace tether::ui {gtk_label_set_xalign(GTK_LABEL(title), 0.0);gtk_box_pack_start(GTK_BOX(labels), title, FALSE, FALSE, 0);- GtkWidget* subtitle =- gtk_label_new(connected ? _("Connected") : (paired ? _("Paired") : _("Nearby (Tap to Pair)")));+ const char* subtitle_text = route_ready ? _("Connected")+ : connected ? _("Partially connected")+ : paired ? _("Paired")+ : _("Nearby (Tap to Pair)");+ GtkWidget* subtitle = gtk_label_new(subtitle_text);gtk_label_set_xalign(GTK_LABEL(subtitle), 0.0);gtk_style_context_add_class(gtk_widget_get_style_context(subtitle), "muted");gtk_box_pack_start(GTK_BOX(labels), subtitle, FALSE, FALSE, 0);@@ -866,7 +896,10 @@ namespace tether::ui {std::string fp = event.value("fingerprint", "");std::string name = event.value("device_name", "");if (!fp.empty()) {- g_devices.connected_fps.push_back(fp);+ if (event.value("connected", false) &&+ std::find(g_devices.connected_fps.begin(), g_devices.connected_fps.end(), fp) ==+ g_devices.connected_fps.end())+ g_devices.connected_fps.push_back(fp);// Ensure it's in the paired devices list so the UI transitionsbool already_paired = false;@@ -962,6 +995,20 @@ namespace tether::ui {for (const auto& device : event["devices"])g_devices.bt_devices.push_back(device);}++ if (g_devices.select_bt_after_scan) {+ const auto iphone = std::find_if(g_devices.bt_devices.begin(),+ g_devices.bt_devices.end(),+ [](const nlohmann::json& device) {+ return device.value("iphone", false);+ });+ if (iphone != g_devices.bt_devices.end()) {+ g_devices.selected_bt_address = iphone->value("address", "");+ g_devices.selected_bt_name = iphone->value("name", "iPhone");+ g_devices.selected_device_fp.clear();+ g_devices.select_bt_after_scan = false;+ }+ }devices_view_refresh();update_right_pane();return true;@@ -984,12 +1031,20 @@ namespace tether::ui {set_text(g_devices.lbl_bt_progress, message);// A failed scan already carries the reason; only a scan that really// ran and found nothing wants the "check the phone" advice.- if (event.value("success", false) && g_devices.bt_devices.empty())- set_text(g_devices.lbl_welcome_bt,- _("No iPhone found. Unlock the phone and open Settings > Bluetooth so it advertises, "- "then scan again."));- else if (!event.value("success", false))+ if (event.value("success", false) && g_devices.select_bt_after_scan) {+ const char* advice = _("No iPhone found. Unlock the phone and open Settings > Bluetooth so it "+ "advertises, then scan again.");+ set_text(g_devices.lbl_welcome_bt, advice);+ set_status_action(advice);+ g_devices.select_bt_after_scan = false;+ update_action_bt_scan_controls();+ } else if (!event.value("success", false)) {set_text(g_devices.lbl_welcome_bt, message);+ if (g_devices.select_bt_after_scan)+ set_status_action(message);+ g_devices.select_bt_after_scan = false;+ update_action_bt_scan_controls();+ }return true;}if (command == "bt_solicit_result") {@@ -1306,6 +1361,19 @@ namespace tether::ui {gtk_box_pack_start(GTK_BOX(action_box), btn_grid, FALSE, FALSE, 0);+ g_devices.btn_action_bt_pair = gtk_button_new_with_label(_("Pair over Bluetooth"));+ gtk_button_set_image(GTK_BUTTON(g_devices.btn_action_bt_pair),+ gtk_image_new_from_icon_name("bluetooth-symbolic", GTK_ICON_SIZE_BUTTON));+ gtk_button_set_always_show_image(GTK_BUTTON(g_devices.btn_action_bt_pair), TRUE);+ gtk_widget_set_halign(g_devices.btn_action_bt_pair, GTK_ALIGN_CENTER);+ g_signal_connect(g_devices.btn_action_bt_pair, "clicked", G_CALLBACK(on_action_bt_pair_clicked), nullptr);+ gtk_box_pack_start(GTK_BOX(action_box), g_devices.btn_action_bt_pair, FALSE, FALSE, 0);++ GtkSizeGroup* action_button_sizes = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);+ gtk_size_group_add_widget(action_button_sizes, btn_send_clip);+ gtk_size_group_add_widget(action_button_sizes, g_devices.btn_action_bt_pair);+ g_object_unref(action_button_sizes);+g_devices.lbl_action_status = gtk_label_new(_("Ready"));gtk_widget_set_halign(g_devices.lbl_action_status, GTK_ALIGN_CENTER);gtk_style_context_add_class(gtk_widget_get_style_context(g_devices.lbl_action_status), "muted");diff --git a/src/gtk/messages_view.cpp b/src/gtk/messages_view.cppindex 13b656d..3017c22 100644--- a/src/gtk/messages_view.cpp+++ b/src/gtk/messages_view.cpp@@ -33,6 +33,8 @@ namespace tether::ui {GtkWidget* composer = nullptr;GtkWidget* send_button = nullptr;GtkWidget* placeholder_stack = nullptr;+ GtkWidget* placeholder_icon = nullptr;+ GtkWidget* placeholder_label = nullptr;GtkWidget* paned = nullptr;GtkWidget* thread_scroll = nullptr;GtkWidget* search_entry = nullptr;@@ -43,6 +45,8 @@ namespace tether::ui {std::string selected_name;bool visible = false;bool map_open = false;+ bool threads_known = false;+ size_t thread_count = 0;bool sending = false;GtkWidget* composer_notice = nullptr;// Rebuilding the thread list destroys and recreates the selected row.@@ -108,6 +112,7 @@ namespace tether::ui {enum ComposeColumn { COMPOSE_COL_DISPLAY, COMPOSE_COL_ADDRESS, COMPOSE_COL_SEARCH, COMPOSE_COL_COUNT };void update_composer_sensitivity();+ void update_placeholder();void apply_row_selection(GtkWidget* row);void clear_selection();void switch_thread(const std::string& key);@@ -413,6 +418,10 @@ namespace tether::ui {clear_list_box(g_messages.thread_list);+ g_messages.threads_known = true;+ g_messages.thread_count = event["threads"].size();+ update_placeholder();+GtkWidget* reselect = nullptr;for (const auto& thread : event["threads"]) {GtkWidget* row = build_thread_row(thread);@@ -556,6 +565,7 @@ namespace tether::ui {void update_connection(const nlohmann::json& event) {const bool map_open = event.value("map_open", false);g_messages.map_open = map_open;+ update_placeholder();update_composer_sensitivity();if (map_open) {set_banner("");@@ -578,6 +588,20 @@ namespace tether::ui {set_banner(reason, map_error == "forbidden" || map_error == "no_record");}+ void update_placeholder() {+ if (!g_messages.placeholder_icon || !g_messages.placeholder_label)+ return;++ const bool bluetooth_needed =+ g_messages.threads_known && g_messages.thread_count == 0 && !g_messages.map_open;+ gtk_image_set_from_icon_name(GTK_IMAGE(g_messages.placeholder_icon),+ bluetooth_needed ? "bluetooth-disabled-symbolic" : "mail-unread-symbolic",+ GTK_ICON_SIZE_DIALOG);+ set_text(g_messages.placeholder_label,+ bluetooth_needed ? _("Bluetooth connection needed to sync messages.")+ : _("Select a conversation"));+ }+// Replying needs an open conversation and a live MAP session. A group// thread has no reply routing yet, and the daemon refuses one anyway, so// the composer stays shut rather than accepting text that will bounce.@@ -1137,11 +1161,12 @@ namespace tether::ui {GtkWidget* placeholder = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);gtk_widget_set_valign(placeholder, GTK_ALIGN_CENTER);gtk_widget_set_halign(placeholder, GTK_ALIGN_CENTER);- GtkWidget* placeholder_icon = gtk_image_new_from_icon_name("mail-unread-symbolic", GTK_ICON_SIZE_DIALOG);- gtk_box_pack_start(GTK_BOX(placeholder), placeholder_icon, FALSE, FALSE, 0);- GtkWidget* placeholder_label = gtk_label_new(_("Select a conversation"));- gtk_style_context_add_class(gtk_widget_get_style_context(placeholder_label), "muted");- gtk_box_pack_start(GTK_BOX(placeholder), placeholder_label, FALSE, FALSE, 0);+ g_messages.placeholder_icon =+ gtk_image_new_from_icon_name("mail-unread-symbolic", GTK_ICON_SIZE_DIALOG);+ gtk_box_pack_start(GTK_BOX(placeholder), g_messages.placeholder_icon, FALSE, FALSE, 0);+ g_messages.placeholder_label = gtk_label_new(_("Select a conversation"));+ gtk_style_context_add_class(gtk_widget_get_style_context(g_messages.placeholder_label), "muted");+ gtk_box_pack_start(GTK_BOX(placeholder), g_messages.placeholder_label, FALSE, FALSE, 0);gtk_stack_add_named(GTK_STACK(g_messages.placeholder_stack), placeholder, "placeholder");GtkWidget* conversation_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);diff --git a/test/CMakeLists.txt b/test/CMakeLists.txtindex f855b41..a5b767e 100644--- a/test/CMakeLists.txt+++ b/test/CMakeLists.txt@@ -1,6 +1,7 @@add_executable(tether_testtest_base64.cpptest_bluetooth_objects.cpp+ test_bluetooth_monitor.cpptest_bluetooth_pairing.cpptest_bluetooth_supervisor.cpptest_bmessage.cppdiff --git a/test/test_bluetooth_monitor.cpp b/test/test_bluetooth_monitor.cppnew file mode 100644index 0000000..93e9ee2--- /dev/null+++ b/test/test_bluetooth_monitor.cpp@@ -0,0 +1,94 @@+#include <gtest/gtest.h>+#include <tether/bluetooth/monitor.hpp>++#include <chrono>+#include <cstdlib>+#include <filesystem>+#include <fstream>+#include <fcntl.h>+#include <string>+#include <sys/types.h>+#include <unistd.h>++using namespace std::chrono_literals;+using tether::bluetooth::probe_secure_connections;++namespace {++ class FakeBtmgmt {+ public:+ explicit FakeBtmgmt(const std::string& body) {+ const char* path = std::getenv("PATH");+ old_path_ = path ? path : "";+ dir_ = std::filesystem::path("/var/tmp") /+ ("tether-monitor-test-" + std::to_string(getpid()));+ std::filesystem::remove_all(dir_);+ std::filesystem::create_directories(dir_);++ const auto executable = dir_ / "btmgmt";+ std::ofstream script(executable);+ script << "#!/bin/sh\n" << body;+ script.close();+ std::filesystem::permissions(executable,+ std::filesystem::perms::owner_read |+ std::filesystem::perms::owner_write |+ std::filesystem::perms::owner_exec,+ std::filesystem::perm_options::replace);+ setenv("PATH", dir_.c_str(), 1);+ }++ ~FakeBtmgmt() {+ setenv("PATH", old_path_.c_str(), 1);+ std::filesystem::remove_all(dir_);+ }++ FakeBtmgmt(const FakeBtmgmt&) = delete;+ FakeBtmgmt& operator=(const FakeBtmgmt&) = delete;++ private:+ std::filesystem::path dir_;+ std::string old_path_;+ };++} // namespace++TEST(SecureConnectionsProbe, ParsesEnabledAndDisabledSettings) {+ {+ FakeBtmgmt fake("printf 'current settings: powered secure-conn bondable\\n'\n");+ const auto result = probe_secure_connections("hci0", 250ms);+ ASSERT_TRUE(result.has_value());+ EXPECT_TRUE(*result);+ }+ {+ FakeBtmgmt fake("printf 'current settings: powered bondable\\n'\n");+ const auto result = probe_secure_connections("hci0", 250ms);+ ASSERT_TRUE(result.has_value());+ EXPECT_FALSE(*result);+ }+}++TEST(SecureConnectionsProbe, TimesOutAndTerminatesTheExactChild) {+ FakeBtmgmt fake("exec /bin/sleep 5\n");+ const auto started = std::chrono::steady_clock::now();+ const auto result = probe_secure_connections("hci0", 50ms);+ const auto elapsed = std::chrono::steady_clock::now() - started;++ EXPECT_FALSE(result.has_value());+ EXPECT_LT(elapsed, 500ms);+}++TEST(SecureConnectionsProbe, DoesNotLeakParentDescriptorsIntoBtmgmt) {+ constexpr int sentinel_fd = 99;+ const int source = open("/dev/null", O_RDONLY);+ ASSERT_GE(source, 0);+ ASSERT_EQ(dup2(source, sentinel_fd), sentinel_fd);+ close(source);++ FakeBtmgmt fake("if [ -e /proc/self/fd/99 ]; then exit 9; fi\n"+ "printf 'current settings: secure-conn\\n'\n");+ const auto result = probe_secure_connections("hci0", 250ms);+ close(sentinel_fd);++ ASSERT_TRUE(result.has_value());+ EXPECT_TRUE(*result);+}diff --git a/test/test_bluetooth_objects.cpp b/test/test_bluetooth_objects.cppindex 4d068c5..1d7b872 100644--- a/test/test_bluetooth_objects.cpp+++ b/test/test_bluetooth_objects.cpp@@ -187,6 +187,22 @@ TEST(Capability, FullModeWhenBearerConfirmed) {EXPECT_TRUE(cap.setup.empty());}+TEST(Capability, SecureConnectionsStateIsInjectedRatherThanReadDuringResolution) {+ Payload p(join(ADAPTER_FULL, IPHONE_BONDED).c_str());+ const auto objects = parse_managed_objects(p.v);++ const auto unknown = resolve_capability(objects);+ EXPECT_FALSE(unknown.secure_connections_known);++ const auto enabled = resolve_capability(objects, true);+ EXPECT_TRUE(enabled.secure_connections_known);+ EXPECT_TRUE(enabled.secure_connections);++ const auto disabled = resolve_capability(objects, false);+ EXPECT_TRUE(disabled.secure_connections_known);+ EXPECT_FALSE(disabled.secure_connections);+}+// Without --experimental the bearer interface can never appear, so its absence// is conclusive.TEST(Capability, CompatibilityWhenExperimentalIsOff) {