VPN: WireGuard-Config bei jedem Verbinden vom Server auffrischen - #19
Merged
Conversation
After the server moved hosts, the stored config still carried the old Endpoint: the tunnel came up but routed nowhere, and changing the server URL in the app did not help because the config itself was never re-fetched. TunnelConnector now calls config/check right after the DNS pre-resolve — the last moment with working internet before the tunnel starts — and adopts a changed config after validating it. Every failure path (no peer id, unreachable server, rejected token, invalid config) falls back to the stored config, so a config check can never block a connect. This also makes the stored config hash useful; it was written but never read.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Nach dem Serverumzug (OVH → collabtive.cloud) hing das Pixel Fold: Tunnel verbunden, aber kein Internet. Ursache war nicht die Server-URL in den Einstellungen, sondern die gespeicherte WireGuard-Config — sie trug weiterhin den alten
Endpoint. Die App hat die Config seit der Registrierung nie wieder abgeglichen; der beim Setup gespeicherteconfigHashwurde geschrieben, aber nirgends gelesen.Lösung
TunnelConnector.connectWithUserSettings()ruft direkt nach dem DNS-Pre-Resolve — dem letzten Moment mit funktionierendem Internet vor dem Tunnel-Start —GET api/v1/client/config/checkmitpeerId+ gespeichertem Hash auf:updated == false→ nichts tun, gespeicherte Config verbindenupdated == true→ neue Config durchWgConfigValidator; gültig → speichern (Config + Hash) und diese verbinden, ungültig → verwerfen und mit der alten verbindenAlle Einstiegspunkte (VPN-Screen, Quick-Settings-Tile, Auto-Connect) laufen durch diese Methode, der Abgleich gilt damit überall. Der Server liefert bei geändertem Hash die Config in derselben Antwort mit — es bleibt ein Request.
Tests
Neu:
TunnelConnectorTest(5 Fälle) — unverändert / geändert+gültig / geändert+ungültig / Server nicht erreichbar / nicht registriert../gradlew test lintReleaselokal grün (101 App-Unit-Tests, 0 Fehler).Hinweis fürs Gerät
Das Pixel Fold braucht die neue Config einmalig noch von Hand (QR/Datei) oder eine App-Version mit diesem Stand. Ab dann heilt sich der Fall selbst — auch nach QR-Import ohne Hash, weil ein fehlender Hash den Server-Abgleich auslöst.