Skip to content

Linux + iPhone Continuity / iMessage / SMS

feat: firewall instructions

Zack Bartel0252cd0cd5cf
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8e6da66..e819e27 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -145,6 +145,15 @@ set(SYSTEMD_UNIT_DIR "lib/systemd/system" CACHE PATH "systemd system unit direct
install(FILES packaging/systemd/[email protected]
DESTINATION "${SYSTEMD_UNIT_DIR}")
+ # firewall profiles for the mTLS listener (5134/tcp) and mDNS (5353/udp) installed but not applied (user's call).
+set(UFW_APPLICATIONS_DIR "/etc/ufw/applications.d" CACHE PATH "ufw application profile directory")
+set(FIREWALLD_SERVICE_DIR "lib/firewalld/services" CACHE PATH "firewalld service directory")
+install(FILES packaging/firewall/tether.ufw
+ DESTINATION "${UFW_APPLICATIONS_DIR}"
+ RENAME tether)
+install(FILES packaging/firewall/tether.xml
+ DESTINATION "${FIREWALLD_SERVICE_DIR}")
+
# Extension Building only if npm is available
option(TETHER_BUILD_EXTENSIONS "Build browser and mail extensions automatically" ON)
diff --git a/README.md b/README.md
index 82724b1..63c313c 100644
--- a/README.md
+++ b/README.md
@@ -298,16 +298,52 @@ make install
- A controller with BR/EDR, LE, and advertising support.
- Notification mirroring does not work on iOS 18 and earlier.
-## Roadmap
-
-- [x] Complete iOS app development
-- [x] Add end-to-end encryption for file transfers
-- [x] Release browser extension for Firefox
-- [x] Release mail extension for Thunderbird
-- [x] Read and reply to iPhone messages over Bluetooth
-- [x] Bluetooth for messages and notifications
-- [ ] Implement TOTP/OTP vault with Safari autofill
-- [ ] Explore macOS support
+#### Network ports
+
+WiFi features need two inbound ports on the Linux machine:
+
+| Port | Why |
+|------|-----|
+| 5134/tcp | The `tetherd` mTLS listener the iPhone connects to |
+| 5353/udp | mDNS service discovery `avahi-daemon` |
+
+## Troubleshooting
+
+### The iPhone finds this PC but never connects
+
+Probably firewall. Most firewalls allow mDNS through, so discovery works, but then the iPhone can't get through on it's port (5134/tcp). Open the ports in your firewall.
+
+```bash
+sudo ufw allow Tether # ufw
+sudo firewall-cmd --permanent --add-service=tether # firewalld
+sudo firewall-cmd --reload
+```
+
+AppImage or the Flatpak, open the ports directly:
+
+```bash
+sudo ufw allow 5134/tcp && sudo ufw allow 5353/udp
+sudo firewall-cmd --permanent --add-port=5134/tcp --add-port=5353/udp
+sudo firewall-cmd --reload
+```
+
+On NixOS, set `programs.tether.wifi.openFirewall = true;` instead (see the [NixOS module](#use-the-nixos-module) above.
+
+### The iPhone does not appear at all
+
+`avahi-daemon` is not running, so nothing can discover this machine:
+
+```bash
+sudo systemctl enable --now avahi-daemon
+```
+
+### Bluetooth
+
+Messages and notifications need one-time system setup. See [docs/BLUETOOTH.md](docs/BLUETOOTH.md), or run:
+
+```bash
+tether --bt-setup
+```
## Security
diff --git a/docs/man/man8/tetherd.8.in b/docs/man/man8/tetherd.8.in
index 0269fdd..3e8ee5e 100644
--- a/docs/man/man8/tetherd.8.in
+++ b/docs/man/man8/tetherd.8.in
@@ -13,8 +13,23 @@ The daemon advertises its presence on the local network using mDNS (Bonjour)
and listens for incoming connections on TCP port 5134 by default. It also
provides a UNIX domain socket at \fB$XDG_RUNTIME_DIR/tether/tetherd.sock\fR
for local communication with the \fBtether\fR(1) CLI and \fBtether-gtk\fR(1) GUI.
+.SH FIREWALL
+Inbound \fB5134/tcp\fR must be reachable for the iPhone to connect, and
+\fB5353/udp\fR for mDNS discovery, which \fBavahi-daemon\fR(8) owns. A
+default-deny firewall commonly passes mDNS while dropping 5134, so the phone
+discovers this machine and then cannot reach it.
+
+Profiles for \fBufw\fR(8) and \fBfirewalld\fR(1) are installed but never
+applied; run \fBufw allow Tether\fR or
+\fBfirewall-cmd --permanent --add-service=tether\fR to use them.
.SH FILES
.TP
+\fB/etc/ufw/applications.d/tether\fR
+ufw application profile. Inert until allowed.
+.TP
+\fB/usr/lib/firewalld/services/tether.xml\fR
+firewalld service definition. Inert until added to a zone.
+.TP
\fB$XDG_RUNTIME_DIR/tether/tetherd.sock\fR
The UNIX domain socket used for local communication.
.TP
diff --git a/packaging/firewall/tether.ufw b/packaging/firewall/tether.ufw
new file mode 100644
index 0000000..237e6a8
--- /dev/null
+++ b/packaging/firewall/tether.ufw
@@ -0,0 +1,4 @@
+[Tether]
+title=Tether
+description=Bridge an iPhone to the Linux desktop: clipboard, files, messages, and notifications
+ports=5134/tcp|5353/udp
diff --git a/packaging/firewall/tether.xml b/packaging/firewall/tether.xml
new file mode 100644
index 0000000..44c31f5
--- /dev/null
+++ b/packaging/firewall/tether.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<service>
+ <short>Tether</short>
+ <description>Bridge an iPhone to the Linux desktop: clipboard, files, messages, and notifications. TCP 5134 is the mTLS peer listener; UDP 5353 is mDNS service discovery.</description>
+ <port protocol="tcp" port="5134"/>
+ <port protocol="udp" port="5353"/>
+</service>
diff --git a/packaging/tether.install b/packaging/tether.install
index 6ab13ac..852085f 100644
--- a/packaging/tether.install
+++ b/packaging/tether.install
@@ -14,6 +14,12 @@ To see exactly what is left, and the commands to run:
tether --bt-setup
+WiFi needs inbound 5134/tcp, and 5353/udp for mDNS discovery. Profiles for ufw
+and firewalld are installed but NOT applied, for the same reason:
+
+ sudo ufw allow Tether
+ sudo firewall-cmd --permanent --add-service=tether && sudo firewall-cmd --reload
+
MSG
}
diff --git a/po/cs.po b/po/cs.po
index d5143cd..fd9c330 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Czech\n"
@@ -1136,6 +1136,14 @@ msgstr ""
"avahi-daemon neběží, takže iPhone tento počítač nenajde. Spusťte jej "
"příkazem: sudo systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"iPhone je v síti, ale nemůže se připojit k tomuto PC. Běží firewall; Tether "
+"potřebuje příchozí TCP 5134. Povolte jej příkazem: sudo ufw allow 5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr ""
@@ -1170,6 +1178,26 @@ msgstr "Spárováno"
msgid "Waiting for approval on {0}..."
msgstr "Čeká se na schválení na {0}…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"Toto zařízení není dostupné. Pokud běží firewall, Tether potřebuje na druhém "
+"počítači příchozí TCP 5134."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "Toto zařízení odmítlo připojení. Běží na něm Tether?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "Tuto adresu se nepodařilo přeložit."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "K tomuto zařízení se nepodařilo připojit."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "Žádost o spárování byla odmítnuta."
diff --git a/po/de.po b/po/de.po
index d518063..f22a456 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-22\n"
"Last-Translator: Tether project\n"
"Language-Team: German\n"
@@ -1162,6 +1162,15 @@ msgstr ""
"avahi-daemon läuft nicht, daher kann das iPhone diesen PC nicht finden. "
"Starten Sie ihn mit: sudo systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"Ein iPhone ist im Netzwerk, erreicht diesen PC aber nicht. Eine Firewall ist "
+"aktiv; Tether benötigt eingehendes TCP 5134. Erlauben mit: sudo ufw allow "
+"5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr ""
@@ -1197,6 +1206,26 @@ msgstr "Gekoppelt"
msgid "Waiting for approval on {0}..."
msgstr "Warten auf die Bestätigung auf {0}…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"Dieses Gerät war nicht erreichbar. Wenn eine Firewall läuft, benötigt Tether "
+"eingehendes TCP 5134 auf dem anderen Rechner."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "Dieses Gerät hat die Verbindung abgelehnt. Läuft Tether darauf?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "Diese Adresse konnte nicht aufgelöst werden."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "Verbindung zu diesem Gerät nicht möglich."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "Die Kopplungsanfrage wurde abgelehnt."
diff --git a/po/es.po b/po/es.po
index 82392ea..8d1e662 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-22\n"
"Last-Translator: Tether project\n"
"Language-Team: Spanish\n"
@@ -1155,6 +1155,15 @@ msgstr ""
"avahi-daemon no se está ejecutando, por lo que el iPhone no puede encontrar "
"este equipo. Inícielo con: sudo systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"Hay un iPhone en la red, pero no puede llegar a este PC. Hay un cortafuegos "
+"activo; Tether necesita TCP 5134 entrante. Permítelo con: sudo ufw allow "
+"5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr ""
@@ -1189,6 +1198,26 @@ msgstr "Emparejado"
msgid "Waiting for approval on {0}..."
msgstr "Esperando la aprobación en {0}…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"No se pudo llegar a ese dispositivo. Si hay un cortafuegos activo, Tether "
+"necesita TCP 5134 entrante en la otra máquina."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "Ese dispositivo rechazó la conexión. ¿Está Tether en ejecución en él?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "No se pudo resolver esa dirección."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "No se pudo conectar con ese dispositivo."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "La solicitud de emparejamiento fue rechazada."
diff --git a/po/fr.po b/po/fr.po
index be5a0e2..966bae1 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-22\n"
"Last-Translator: Tether project\n"
"Language-Team: French\n"
@@ -1162,6 +1162,15 @@ msgstr ""
"trouver cet ordinateur. Démarrez-le avec : sudo systemctl enable --now avahi-"
"daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"Un iPhone est sur le réseau mais ne peut pas joindre ce PC. Un pare-feu est "
+"actif ; Tether a besoin du port TCP 5134 entrant. Autorisez-le avec : sudo "
+"ufw allow 5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr ""
@@ -1196,6 +1205,26 @@ msgstr "Appairé"
msgid "Waiting for approval on {0}..."
msgstr "En attente de l'approbation sur {0}…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"Impossible de joindre cet appareil. Si un pare-feu est actif, Tether a "
+"besoin du port TCP 5134 entrant sur l'autre machine."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "Cet appareil a refusé la connexion. Tether y est-il lancé ?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "Cette adresse n'a pas pu être résolue."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "Impossible de se connecter à cet appareil."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "La demande d'appairage a été refusée."
diff --git a/po/it.po b/po/it.po
index fbfef6a..af3cee8 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Italian\n"
@@ -1152,6 +1152,15 @@ msgstr ""
"avahi-daemon non è in esecuzione, quindi l'iPhone non riesce a trovare "
"questo computer. Avvialo con: sudo systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"Un iPhone è in rete ma non riesce a raggiungere questo PC. È attivo un "
+"firewall; Tether richiede la porta TCP 5134 in ingresso. Consentila con: "
+"sudo ufw allow 5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr "Nessun iPhone accoppiato è connesso. Apri l'app Tether sul telefono."
@@ -1185,6 +1194,28 @@ msgstr "Accoppiato"
msgid "Waiting for approval on {0}..."
msgstr "In attesa dell'approvazione su {0}…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"Impossibile raggiungere quel dispositivo. Se è attivo un firewall, Tether "
+"richiede la porta TCP 5134 in ingresso sull'altra macchina."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr ""
+"Quel dispositivo ha rifiutato la connessione. Tether è in esecuzione su di "
+"esso?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "Impossibile risolvere quell'indirizzo."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "Impossibile connettersi a quel dispositivo."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "La richiesta di accoppiamento è stata rifiutata."
diff --git a/po/ja.po b/po/ja.po
index 5efde53..f00763e 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Japanese\n"
@@ -1123,6 +1123,15 @@ msgstr ""
"avahi-daemon が実行されていないため、iPhone はこのパソコンを見つけられませ"
"ん。次のコマンドで起動してください: sudo systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"iPhone はネットワーク上にありますが、この PC に到達できません。ファイアウォー"
+"ルが有効です。Tether は受信 TCP 5134 が必要です。次のコマンドで許可してくださ"
+"い: sudo ufw allow 5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr ""
@@ -1158,6 +1167,26 @@ msgstr "ペアリング済み"
msgid "Waiting for approval on {0}..."
msgstr "{0} での承認を待っています…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"そのデバイスに到達できませんでした。ファイアウォールが有効な場合、相手のマシ"
+"ンで受信 TCP 5134 が必要です。"
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "そのデバイスは接続を拒否しました。Tether は動作していますか?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "そのアドレスを解決できませんでした。"
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "そのデバイスに接続できませんでした。"
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "ペアリング要求は拒否されました。"
diff --git a/po/ko.po b/po/ko.po
index 5eb3edf..abc1a85 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Korean\n"
@@ -1113,6 +1113,15 @@ msgstr ""
"avahi-daemon이 실행되고 있지 않아 iPhone이 이 PC를 찾을 수 없습니다. 다음 명"
"령으로 시작하십시오: sudo systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"네트워크에 iPhone이 있지만 이 PC에 연결할 수 없습니다. 방화벽이 실행 중입니"
+"다. Tether에는 인바운드 TCP 5134가 필요합니다. 다음 명령으로 허용하세요: "
+"sudo ufw allow 5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr "연결된 페어링 iPhone이 없습니다. iPhone에서 Tether 앱을 여십시오."
@@ -1146,6 +1155,26 @@ msgstr "페어링됨"
msgid "Waiting for approval on {0}..."
msgstr "{0}에서 승인을 기다리는 중입니다…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"해당 기기에 연결할 수 없습니다. 방화벽이 실행 중이라면 상대 컴퓨터에서 인바운"
+"드 TCP 5134가 필요합니다."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "해당 기기가 연결을 거부했습니다. 그 기기에서 Tether가 실행 중입니까?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "해당 주소를 확인할 수 없습니다."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "해당 기기에 연결할 수 없습니다."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "페어링 요청이 거부되었습니다."
diff --git a/po/nl.po b/po/nl.po
index 61439cf..895ecf5 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Dutch\n"
@@ -1147,6 +1147,15 @@ msgstr ""
"avahi-daemon draait niet, dus de iPhone kan deze pc niet vinden. Start het "
"met: sudo systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"Er is een iPhone op het netwerk, maar die kan deze pc niet bereiken. Er "
+"draait een firewall; Tether heeft inkomend TCP 5134 nodig. Sta het toe met: "
+"sudo ufw allow 5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr ""
@@ -1181,6 +1190,26 @@ msgstr "Gekoppeld"
msgid "Waiting for approval on {0}..."
msgstr "Wachten op goedkeuring op {0}…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"Dat apparaat was niet bereikbaar. Als er een firewall draait, heeft Tether "
+"inkomend TCP 5134 nodig op de andere machine."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "Dat apparaat heeft de verbinding geweigerd. Draait Tether daarop?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "Dat adres kon niet worden omgezet."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "Kon geen verbinding maken met dat apparaat."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "Het koppelverzoek is geweigerd."
diff --git a/po/pl.po b/po/pl.po
index ddbea60..cfb58af 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Polish\n"
@@ -1147,6 +1147,15 @@ msgstr ""
"avahi-daemon nie działa, więc iPhone nie może znaleźć tego komputera. "
"Uruchom go poleceniem: sudo systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"iPhone jest w sieci, ale nie może połączyć się z tym komputerem. Działa "
+"zapora; Tether wymaga przychodzącego TCP 5134. Zezwól poleceniem: sudo ufw "
+"allow 5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr ""
@@ -1182,6 +1191,26 @@ msgstr "Sparowano"
msgid "Waiting for approval on {0}..."
msgstr "Oczekiwanie na zatwierdzenie na {0}…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"Nie można było połączyć się z tym urządzeniem. Jeśli działa zapora, Tether "
+"wymaga przychodzącego TCP 5134 na drugim komputerze."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "To urządzenie odrzuciło połączenie. Czy działa na nim Tether?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "Nie udało się rozwiązać tego adresu."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "Nie udało się połączyć z tym urządzeniem."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "Żądanie parowania zostało odrzucone."
diff --git a/po/pt_BR.po b/po/pt_BR.po
index d18391d..dfcc7b8 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Brazilian Portuguese\n"
@@ -1148,6 +1148,15 @@ msgstr ""
"encontrar este computador. Inicie-o com: sudo systemctl enable --now avahi-"
"daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"Há um iPhone na rede, mas ele não consegue alcançar este PC. Há um firewall "
+"ativo; o Tether precisa de TCP 5134 de entrada. Libere com: sudo ufw allow "
+"5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr "Nenhum iPhone pareado está conectado. Abra o app Tether no telefone."
@@ -1181,6 +1190,26 @@ msgstr "Pareado"
msgid "Waiting for approval on {0}..."
msgstr "Aguardando a aprovação em {0}…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"Não foi possível alcançar esse dispositivo. Se houver um firewall ativo, o "
+"Tether precisa de TCP 5134 de entrada na outra máquina."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "Esse dispositivo recusou a conexão. O Tether está em execução nele?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "Não foi possível resolver esse endereço."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "Não foi possível conectar a esse dispositivo."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "A solicitação de pareamento foi recusada."
diff --git a/po/ru.po b/po/ru.po
index b042a73..8fb743b 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Russian\n"
@@ -1147,6 +1147,15 @@ msgstr ""
"avahi-daemon не запущен, поэтому iPhone не может найти этот компьютер. "
"Запустите его командой: sudo systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"iPhone есть в сети, но не может подключиться к этому ПК. Работает "
+"брандмауэр; Tether требуется входящий TCP 5134. Разрешите его командой: sudo "
+"ufw allow 5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr ""
@@ -1182,6 +1191,26 @@ msgstr "Сопряжено"
msgid "Waiting for approval on {0}..."
msgstr "Ожидание подтверждения на {0}…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"Не удалось связаться с этим устройством. Если работает брандмауэр, Tether "
+"требуется входящий TCP 5134 на другой машине."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "Это устройство отклонило подключение. Запущен ли на нём Tether?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "Не удалось разрешить этот адрес."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "Не удалось подключиться к этому устройству."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "Запрос на сопряжение отклонён."
diff --git a/po/sv.po b/po/sv.po
index 8c09635..5186ee6 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Swedish\n"
@@ -1133,6 +1133,15 @@ msgstr ""
"avahi-daemon körs inte, så iPhone kan inte hitta den här datorn. Starta den "
"med: sudo systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"En iPhone finns i nätverket men når inte den här datorn. En brandvägg är "
+"aktiv; Tether behöver inkommande TCP 5134. Tillåt det med: sudo ufw allow "
+"5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr "Ingen parkopplad iPhone är ansluten. Öppna Tether-appen på telefonen."
@@ -1166,6 +1175,26 @@ msgstr "Parkopplad"
msgid "Waiting for approval on {0}..."
msgstr "Väntar på godkännande på {0}…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"Kunde inte nå den enheten. Om en brandvägg är aktiv behöver Tether "
+"inkommande TCP 5134 på den andra maskinen."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "Enheten nekade anslutningen. Körs Tether på den?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "Adressen kunde inte slås upp."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "Kunde inte ansluta till den enheten."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "Parkopplingsförfrågan avvisades."
diff --git a/po/tether.pot b/po/tether.pot
index fd3df4f..9d4f9a5 100644
--- a/po/tether.pot
+++ b/po/tether.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tether 0.2.22\n"
"Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2026-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-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"
@@ -1028,6 +1028,12 @@ msgid ""
"sudo systemctl enable --now avahi-daemon"
msgstr ""
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr ""
@@ -1061,6 +1067,24 @@ msgstr ""
msgid "Waiting for approval on {0}..."
msgstr ""
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr ""
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr ""
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr ""
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr ""
diff --git a/po/tr.po b/po/tr.po
index 57d0af3..2c78f6b 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Turkish\n"
@@ -1131,6 +1131,15 @@ msgstr ""
"avahi-daemon çalışmıyor, bu yüzden iPhone bu bilgisayarı bulamıyor. Şu "
"komutla başlatın: sudo systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"Ağda bir iPhone var ancak bu bilgisayara ulaşamıyor. Bir güvenlik duvarı "
+"çalışıyor; Tether gelen TCP 5134 bağlantı noktasına ihtiyaç duyar. Şu "
+"komutla izin verin: sudo ufw allow 5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr ""
@@ -1165,6 +1174,26 @@ msgstr "Eşleşti"
msgid "Waiting for approval on {0}..."
msgstr "{0} aygıtında onay bekleniyor…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"Bu aygıta ulaşılamadı. Bir güvenlik duvarı çalışıyorsa Tether'in diğer "
+"makinede gelen TCP 5134 bağlantı noktasına ihtiyacı var."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "Bu aygıt bağlantıyı reddetti. Üzerinde Tether çalışıyor mu?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "Bu adres çözümlenemedi."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "Bu aygıta bağlanılamadı."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "Eşleşme isteği reddedildi."
diff --git a/po/uk.po b/po/uk.po
index 5136b63..0fc1d97 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Ukrainian\n"
@@ -1144,6 +1144,15 @@ msgstr ""
"avahi-daemon не запущено, тому iPhone не може знайти цей комп'ютер. "
"Запустіть його командою: sudo systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"iPhone є в мережі, але не може під'єднатися до цього ПК. Працює брандмауер; "
+"Tether потребує вхідного TCP 5134. Дозвольте його командою: sudo ufw allow "
+"5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr ""
@@ -1179,6 +1188,26 @@ msgstr "Спарено"
msgid "Waiting for approval on {0}..."
msgstr "Очікування підтвердження на {0}…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"Не вдалося зв'язатися з цим пристроєм. Якщо працює брандмауер, Tether "
+"потребує вхідного TCP 5134 на іншій машині."
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "Цей пристрій відхилив з'єднання. Чи запущено на ньому Tether?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "Не вдалося розпізнати цю адресу."
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "Не вдалося під'єднатися до цього пристрою."
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "Запит на створення пари відхилено."
diff --git a/po/zh_CN.po b/po/zh_CN.po
index 8a690fc..69c4459 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-09-02 10:09-0700\n"
+"POT-Creation-Date: 2026-09-02 11:40-0700\n"
"PO-Revision-Date: 2026-08-23\n"
"Last-Translator: Tether project\n"
"Language-Team: Simplified Chinese\n"
@@ -1089,6 +1089,14 @@ msgstr ""
"avahi-daemon 未运行,因此 iPhone 无法找到此电脑。请使用以下命令启动:sudo "
"systemctl enable --now avahi-daemon"
+#: src/gtk/devices_view.cpp
+msgid ""
+"An iPhone is on the network but cannot reach this PC. A firewall is running; "
+"Tether needs inbound TCP 5134. Allow it with: sudo ufw allow 5134/tcp"
+msgstr ""
+"网络中有一部 iPhone,但无法连接到这台电脑。防火墙正在运行;Tether 需要入站 "
+"TCP 5134。请使用以下命令放行:sudo ufw allow 5134/tcp"
+
#: src/gtk/devices_view.cpp
msgid "No paired iPhone is connected. Open the Tether app on the phone."
msgstr "没有已配对的 iPhone 处于连接状态。请在 iPhone 上打开 Tether App。"
@@ -1122,6 +1130,25 @@ msgstr "已配对"
msgid "Waiting for approval on {0}..."
msgstr "正在等待 {0} 上的批准…"
+#: src/gtk/devices_view.cpp
+msgid ""
+"Could not reach that device. If a firewall is running, Tether needs inbound "
+"TCP 5134 on the other machine."
+msgstr ""
+"无法连接到该设备。如果防火墙正在运行,Tether 需要对方机器上的入站 TCP 5134。"
+
+#: src/gtk/devices_view.cpp
+msgid "That device refused the connection. Is Tether running on it?"
+msgstr "该设备拒绝了连接。它上面运行着 Tether 吗?"
+
+#: src/gtk/devices_view.cpp
+msgid "That address could not be resolved."
+msgstr "无法解析该地址。"
+
+#: src/gtk/devices_view.cpp
+msgid "Could not connect to that device."
+msgstr "无法连接到该设备。"
+
#: src/gtk/devices_view.cpp
msgid "Pair request was rejected."
msgstr "配对请求被拒绝。"
diff --git a/src/core/include/tether/net.hpp b/src/core/include/tether/net.hpp
index c0e5496..e360a1a 100644
--- a/src/core/include/tether/net.hpp
+++ b/src/core/include/tether/net.hpp
@@ -6,6 +6,7 @@
#include <nlohmann/json.hpp>
#include <openssl/ssl.h>
#include <string>
+#include <string_view>
#include <sys/types.h>
namespace tether {
@@ -46,6 +47,10 @@ namespace tether {
bool mdns_available();
nlohmann::json build_mdns_status();
+ // Whether a host firewall is running.
+ bool ufw_enabled(std::string_view ufw_conf);
+ bool firewall_active();
+
class UnixServer {
public:
UnixServer(EpollEventLoop& loop, TcpServer& tcp_server);
diff --git a/src/core/src/net.cpp b/src/core/src/net.cpp
index 7e66ae8..ee68fc7 100644
--- a/src/core/src/net.cpp
+++ b/src/core/src/net.cpp
@@ -5,6 +5,7 @@
#include <csignal>
#include <errno.h>
#include <fcntl.h>
+#include <gio/gio.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/file.h>
@@ -26,7 +27,9 @@
#include "tether/file_transfer.hpp"
#include "tether/otp.hpp"
#include "tether/wayland.hpp"
+#include <algorithm>
#include <atomic>
+#include <cctype>
#include <chrono>
#include <condition_variable>
#include <cstring>
@@ -37,6 +40,7 @@
#include <openssl/err.h>
#include <optional>
#include <set>
+#include <sstream>
#include <tether/log.hpp>
#include <thread>
#include <vector>
@@ -329,6 +333,90 @@ namespace tether {
broadcast_local_event(build_mdns_status().dump());
}
+ bool ufw_enabled(std::string_view ufw_conf) {
+ std::istringstream lines{std::string(ufw_conf)};
+ for (std::string line; std::getline(lines, line);) {
+ const auto begin = line.find_first_not_of(" \t");
+ if (begin == std::string::npos || line[begin] == '#')
+ continue;
+ const auto eq = line.find('=', begin);
+ if (eq == std::string::npos)
+ continue;
+
+ auto trim = [](std::string_view v) {
+ const auto first = v.find_first_not_of(" \t\r");
+ if (first == std::string_view::npos)
+ return std::string_view{};
+ return v.substr(first, v.find_last_not_of(" \t\r") - first + 1);
+ };
+ const std::string_view key = trim(std::string_view(line).substr(begin, eq - begin));
+ if (key != "ENABLED")
+ continue;
+
+ std::string value(trim(std::string_view(line).substr(eq + 1)));
+ std::transform(value.begin(), value.end(), value.begin(), [](unsigned char c) {
+ return static_cast<char>(std::tolower(c));
+ });
+ return value == "yes";
+ }
+ return false;
+ }
+
+ // True when firewalld owns its well-known name on the system bus.
+ static bool firewalld_running() {
+ GError* error = nullptr;
+ GDBusConnection* bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error);
+ if (!bus) {
+ g_clear_error(&error);
+ return false;
+ }
+
+ GVariant* reply = g_dbus_connection_call_sync(bus,
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus",
+ "NameHasOwner",
+ g_variant_new("(s)", "org.fedoraproject.FirewallD1"),
+ G_VARIANT_TYPE("(b)"),
+ G_DBUS_CALL_FLAGS_NONE,
+ 1000,
+ nullptr,
+ &error);
+ g_object_unref(bus);
+ if (!reply) {
+ g_clear_error(&error);
+ return false;
+ }
+
+ gboolean owned = FALSE;
+ g_variant_get(reply, "(b)", &owned);
+ g_variant_unref(reply);
+ return owned == TRUE;
+ }
+
+ bool firewall_active() {
+ constexpr auto TTL = std::chrono::seconds(30);
+ static std::mutex mutex;
+ static std::chrono::steady_clock::time_point checked_at;
+ static bool cached = false;
+
+ std::lock_guard<std::mutex> lock(mutex);
+ const auto now = std::chrono::steady_clock::now();
+ if (checked_at != std::chrono::steady_clock::time_point{} && now - checked_at < TTL)
+ return cached;
+
+ cached = false;
+ std::ifstream conf("/etc/ufw/ufw.conf");
+ if (conf) {
+ std::string contents((std::istreambuf_iterator<char>(conf)), std::istreambuf_iterator<char>());
+ cached = ufw_enabled(contents);
+ }
+ if (!cached)
+ cached = firewalld_running();
+ checked_at = now;
+ return cached;
+ }
+
// Guards against two pairing transactions racing for the same agent and
// advertisement object paths.
static std::atomic<bool> g_bt_pair_busy{false};
@@ -585,6 +673,7 @@ namespace tether {
snapshot["mdns_available"] = g_mdns_available.load();
snapshot["clipboard_available"] = g_wayland && g_wayland->clipboard_available();
+ snapshot["firewall_active"] = firewall_active();
return snapshot;
}
@@ -1313,6 +1402,9 @@ namespace tether {
loop_.addFd(client_fd, [this](int cfd) { handle_client(cfd); });
}
+ // How long a dial waits before calling the peer unreachable.
+ constexpr int DIAL_TIMEOUT_SECONDS = 5;
+
bool TcpServer::connect_peer(const std::string& host, int port, const std::string& peer_name) {
if (host.empty())
return false;
@@ -1327,6 +1419,15 @@ namespace tether {
// connect() blocks, and the loop watches EPOLLIN only
std::thread([this, host, port, peer_name]() {
+ auto fail = [&](const char* reason) {
+ nlohmann::json event{{"command", "pair_rejected"},
+ {"fingerprint", ""},
+ {"device_name", peer_name},
+ {"address", host},
+ {"reason", reason}};
+ broadcast_local_event(event.dump());
+ };
+
addrinfo hints{};
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
@@ -1336,27 +1437,52 @@ namespace tether {
const std::string service = std::to_string(port);
if (int err = getaddrinfo(host.c_str(), service.c_str(), &hints, &results); err != 0 || !results) {
debug::log(ERR, "TcpServer: Cannot resolve {}: {}", host, gai_strerror(err));
+ fail("unresolved");
return;
}
int sock = -1;
+ int connect_errno = 0;
for (addrinfo* ai = results; ai; ai = ai->ai_next) {
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if (sock < 0)
+ if (sock < 0) {
+ connect_errno = errno;
continue;
+ }
+
+ timeval timeout{DIAL_TIMEOUT_SECONDS, 0};
+ setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout));
if (::connect(sock, ai->ai_addr, ai->ai_addrlen) == 0)
break;
+ connect_errno = errno;
close(sock);
sock = -1;
}
- const int connect_errno = errno;
freeaddrinfo(results);
if (sock < 0) {
debug::log(ERR, "TcpServer: Failed to dial {}:{}: {}", host, port, std::strerror(connect_errno));
+ switch (connect_errno) {
+ case ECONNREFUSED:
+ fail("refused");
+ break;
+ case EINPROGRESS:
+ case EAGAIN:
+ case ETIMEDOUT:
+ case EHOSTUNREACH:
+ case ENETUNREACH:
+ fail("unreachable");
+ break;
+ default:
+ fail("failed");
+ break;
+ }
return;
}
+ timeval none{0, 0};
+ setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &none, sizeof(none));
+
loop_.post([this, sock, host, peer_name]() { adopt_peer(sock, host, peer_name); });
}).detach();
diff --git a/src/gtk/devices_view.cpp b/src/gtk/devices_view.cpp
index 4046233..bb158b8 100644
--- a/src/gtk/devices_view.cpp
+++ b/src/gtk/devices_view.cpp
@@ -27,6 +27,7 @@ namespace tether::ui {
// false when the compositor withholds data-control (flatpak)
bool clipboard_ok = true;
+ bool firewall_active = false;
// The Bluetooth route
std::vector<nlohmann::json> bt_devices;
@@ -614,6 +615,15 @@ namespace tether::ui {
"with: sudo systemctl enable --now avahi-daemon"));
return;
}
+
+ if (g_devices.firewall_active && !g_devices.discovered_devices.empty()) {
+ set_route_status(Route::WiFi,
+ false,
+ _("An iPhone is on the network but cannot reach this PC. A firewall is "
+ "running; Tether needs inbound TCP 5134. Allow it with: sudo ufw allow "
+ "5134/tcp"));
+ return;
+ }
set_route_status(Route::WiFi, false, _("No paired iPhone is connected. Open the Tether app on the phone."));
}
@@ -621,6 +631,7 @@ namespace tether::ui {
g_devices.mdns_ok = j.value("mdns_available", true);
g_devices.clipboard_ok = j.value("clipboard_available", true);
+ g_devices.firewall_active = j.value("firewall_active", false);
g_devices.connected_fps.clear();
if (j.contains("connected_clients") && j["connected_clients"].is_array()) {
for (auto& c : j["connected_clients"]) {
@@ -909,8 +920,22 @@ namespace tether::ui {
return true;
}
if (command == "pair_rejected") {
- set_text(g_devices.lbl_unpaired_ip, _("Pair request was rejected."));
- set_status_main(_("Pair request was rejected."));
+
+ const std::string reason = event.value("reason", "");
+ std::string message;
+ if (reason == "unreachable")
+ message = _("Could not reach that device. If a firewall is running, Tether needs inbound TCP "
+ "5134 on the other machine.");
+ else if (reason == "refused")
+ message = _("That device refused the connection. Is Tether running on it?");
+ else if (reason == "unresolved")
+ message = _("That address could not be resolved.");
+ else if (reason == "failed")
+ message = _("Could not connect to that device.");
+ else
+ message = _("Pair request was rejected.");
+ set_text(g_devices.lbl_unpaired_ip, message);
+ set_status_main(message);
return true;
}
if (command == "pair_request_received" || command == "untrusted_client_connected") {
diff --git a/test/test_net.cpp b/test/test_net.cpp
index c1f8ac8..dae79a3 100644
--- a/test/test_net.cpp
+++ b/test/test_net.cpp
@@ -374,6 +374,99 @@ namespace {
EXPECT_LE(open_fd_count(), before);
}
+ // A dial that lands nowhere must still reach the UI. Without a verdict the
+ // GTK pair spinner runs forever, which is what a firewalled peer looks like.
+ TEST(TcpServerTest, DialFailureReportsAReason) {
+ const std::string home = unique_test_dir("tether_dial_reason_test");
+ CleanupGuard cleanup_guard(home);
+ std::filesystem::remove_all(home);
+ std::filesystem::create_directories(home);
+ ScopedEnvVar home_env("HOME", home);
+ ASSERT_TRUE(tether::Crypto::instance().init());
+
+ constexpr int port = 45139;
+ constexpr int dead_port = 45140;
+ tether::EpollEventLoop loop;
+ tether::TcpServer server(loop, port);
+ if (!server.start())
+ GTEST_SKIP() << "port " << port << " is unavailable";
+
+ int pair[2];
+ ASSERT_EQ(socketpair(AF_UNIX, SOCK_STREAM, 0, pair), 0);
+ tether::register_local_subscriber(pair[1]);
+
+ std::thread loop_thread([&loop] { loop.run(); });
+ EXPECT_TRUE(server.connect_peer("127.0.0.1", dead_port, "ghost"));
+
+ // Nothing listens on dead_port, so the kernel answers RST: "refused",
+ // which is the case a firewall is NOT responsible for.
+ std::string event;
+ char buf[4096];
+ timeval read_timeout{10, 0};
+ setsockopt(pair[0], SOL_SOCKET, SO_RCVTIMEO, &read_timeout, sizeof(read_timeout));
+ const ssize_t n = read(pair[0], buf, sizeof(buf));
+ if (n > 0)
+ event.assign(buf, static_cast<size_t>(n));
+
+ loop.post([&loop] { loop.stop(); });
+ loop_thread.join();
+ tether::unregister_local_subscriber(pair[1]);
+ close(pair[0]);
+ close(pair[1]);
+
+ ASSERT_FALSE(event.empty()) << "no pair_rejected reached local subscribers";
+ const auto parsed = nlohmann::json::parse(event);
+ EXPECT_EQ(parsed.value("command", ""), "pair_rejected");
+ EXPECT_EQ(parsed.value("reason", ""), "refused");
+ EXPECT_EQ(parsed.value("address", ""), "127.0.0.1");
+ }
+
+ // A firewall that DROPs the SYN gives no answer at all. connect() must give
+ // up on Tether's schedule, not the kernel's multi-minute retry budget.
+ TEST(TcpServerTest, DialToABlackHoleGivesUpQuickly) {
+ const std::string home = unique_test_dir("tether_dial_blackhole_test");
+ CleanupGuard cleanup_guard(home);
+ std::filesystem::remove_all(home);
+ std::filesystem::create_directories(home);
+ ScopedEnvVar home_env("HOME", home);
+ ASSERT_TRUE(tether::Crypto::instance().init());
+
+ constexpr int port = 45141;
+ tether::EpollEventLoop loop;
+ tether::TcpServer server(loop, port);
+ if (!server.start())
+ GTEST_SKIP() << "port " << port << " is unavailable";
+
+ int pair[2];
+ ASSERT_EQ(socketpair(AF_UNIX, SOCK_STREAM, 0, pair), 0);
+ tether::register_local_subscriber(pair[1]);
+
+ std::thread loop_thread([&loop] { loop.run(); });
+ const auto started = std::chrono::steady_clock::now();
+ // Reserved for documentation (RFC 5737); routers drop it rather than reply.
+ EXPECT_TRUE(server.connect_peer("192.0.2.1", 5134, "black hole"));
+
+ std::string event;
+ char buf[4096];
+ timeval read_timeout{60, 0};
+ setsockopt(pair[0], SOL_SOCKET, SO_RCVTIMEO, &read_timeout, sizeof(read_timeout));
+ const ssize_t n = read(pair[0], buf, sizeof(buf));
+ if (n > 0)
+ event.assign(buf, static_cast<size_t>(n));
+ const auto elapsed = std::chrono::steady_clock::now() - started;
+
+ loop.post([&loop] { loop.stop(); });
+ loop_thread.join();
+ tether::unregister_local_subscriber(pair[1]);
+ close(pair[0]);
+ close(pair[1]);
+
+ ASSERT_FALSE(event.empty()) << "no verdict reached local subscribers";
+ EXPECT_EQ(nlohmann::json::parse(event).value("command", ""), "pair_rejected");
+ // Upper bound only: a network that answers immediately is still a pass.
+ EXPECT_LT(std::chrono::duration_cast<std::chrono::seconds>(elapsed).count(), 30);
+ }
+
// The dialling side owns the pair request: it sends one unprompted once TLS is up,
// which is what makes a desktop-initiated pair reach the peer's approval prompt.
// The peer here is a bare TLS socket, not a second TcpServer, so nothing forks a
@@ -444,3 +537,26 @@ namespace {
}
} // namespace
+
+TEST(FirewallTest, UfwEnabledReadsTheEnabledKey) {
+ EXPECT_TRUE(tether::ufw_enabled("ENABLED=yes\n"));
+ EXPECT_FALSE(tether::ufw_enabled("ENABLED=no\n"));
+}
+
+TEST(FirewallTest, UfwEnabledIgnoresCommentsAndWhitespace) {
+ EXPECT_FALSE(tether::ufw_enabled("# ENABLED=yes\n"));
+ EXPECT_TRUE(tether::ufw_enabled(" ENABLED = yes \n"));
+ EXPECT_TRUE(tether::ufw_enabled("ENABLED=YES\r\n"));
+}
+
+TEST(FirewallTest, UfwEnabledIgnoresOtherKeysAndTakesTheFirstMatch) {
+ EXPECT_FALSE(tether::ufw_enabled("LOGLEVEL=low\nIPV6=yes\n"));
+ EXPECT_TRUE(tether::ufw_enabled("LOGLEVEL=low\nENABLED=yes\nIPV6=no\n"));
+ EXPECT_FALSE(tether::ufw_enabled("ENABLED=no\nENABLED=yes\n"));
+}
+
+TEST(FirewallTest, UfwEnabledIsFalseWhenTheKeyIsAbsent) {
+ EXPECT_FALSE(tether::ufw_enabled(""));
+ EXPECT_FALSE(tether::ufw_enabled("ENABLED\n"));
+ EXPECT_FALSE(tether::ufw_enabled("ENABLEDX=yes\n"));
+}