one typed tunnel-state object between service and GUI #79
Loading…
Reference in a new issue
No description provided.
Delete branch "change/tunnel-state"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #24.
Problem
The tunnel state (device names, DNS servers) lived twice: the service held it as instance attributes set via two thread signals, addressed by string concatenation (
getattr(self, "tun{}".format(add))), and the GUI pulled each value back one string at a time withreturn_tun_device. State in two processes with no reconciliation after a service restart — and the string-concat addressing is how the DNS-to-the-wrong-variable bug happened.Fix
aqomui/state.py: a frozenTunnelRole(dev/dns/dns_2) per tunnel role (main/hop/bypass), collected in oneTunnelStateowned by the service.TunnelThreadkeeps a per-role copy and pushes(role, TunnelRole)over a singlerole_updatesignal, replacing thedev+dnsservertuple signals. Role names replace theadd-suffix addressing inmgmt_events/tunnel_up/dns_updown_disabled; suffixes survive only where status names and socket paths need them.tunnel_state_changed, and answersget_tunnel_statewith a snapshot (used at GUI startup — and the re-sync hook a #73 fix will need).return_tun_device,set_tunandset_dnsare deleted.self.tunnel_state.<role>.devwhere it used to issue pulls.Related fixes
The refactor removes several string-concat casualties in passing:
disconnect("main")containedself.tun is None— a no-op comparison where an assignment was meant. The main role's device reset now actually happens (previously a WireGuard disconnect left the stale device behind forever).dns{add}_2→dns_bypass_2, a junk attribute; the realdns_2_bypasskept its stale value.tunnel_upran the provider's custom "up" script on hop connects too:h != 1compared a string to an int, so it was always true. Only the main tunnel runs it now. (The sameh != 1pattern still guards the "pre"/"down" scripts inovpn()— deliberately untouched here.)interface_bypassassignment incgroup_vpnand the deadconnect_statusservice attribute removed.Verification
tests/test_state.py(JSON round trip, role-name validation, frozen roles),test_tunnel.pyupdated to the role-based API.ruff check --select E9,F63,F7,F82andcompileall -W error::SyntaxWarningclean.wg_aqomuipath and double-hop display are the least-covered spots.🤖 Generated with Claude Code
9ff0dddb16da4f67c373