fix: recognise the tunnel device OpenVPN opened #15
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/dco-device-detection"
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?
Problem
aqomui learns the tunnel's interface by matching
TUN/TAP devicein OpenVPN'soutput. DCO -- kernel offload, the default data path since 2.6 -- never prints
that line, so on any current OpenVPN
self.tunstayedNoneand everythingkeyed to it was quietly skipped: DNS never reached the tunnel, and the bypass
has no interface to give dnsmasq.
The parse was already unsound where the line does appear. It stripped the
timestamp with
line.replace(time.asctime(), '')-- which matches only whileOpenVPN's format agrees with Python's
asctimeand the second has notticked over between logging and parsing -- then took a fixed field index. With
2.7's timestamp format the strip does nothing and index
[3]lands on theliteral word
device, soself.tunbecame"device"rather than"tun0".That affects the userspace path too, not only DCO.
Fix
Match the device name by pattern, removing the dependency on both the timestamp
and the field position. Covers
DCO device tun0 openedandovpn-dco device [tun0] openedalongside the original form.Applying DNS needed a second change to go with it. OpenVPN configures the
tunnel's servers itself (2.7 ships
/usr/lib/openvpn/dns-updown), and thepushed-DNS parse keys off
PUSH: Received control message, which 2.7 does notprint either. So with the device name known, aqomui would have overwritten
the servers actually in use with its configured fallbacks. It now only routes
queries into the tunnel when it never saw a push and no alternative servers were
requested -- which is exactly what was missing: the servers were already right,
the routing domain was absent.
Verification
Added
tests/test_tun_device.py-- no root, network or account needed. Both DCOforms are taken verbatim from a 2.7.6 connection log, alongside the userspace
forms and lines that mention a device but do not announce one
(
net_iface_up: set tun0 up,net_addr_v4_add: ... dev tun0).Observed directly on a live 2.7.6 + DCO connection:
TUN/TAP deviceappearszero times in the whole session log, as do
PUSH: Received control messageand
dhcp-option DNS.tun0carried Proton's10.96.0.1-- set by OpenVPN,not aqomui -- and no routing domain at all.
Known trade-off, please read before merging
~.sends every lookup into the tunnel. That is what closes the leak, andit also breaks split-horizon DNS: on this machine an internal host that resolves
to a LAN address via the local resolver started resolving to its public address
instead, and became unreachable. Confirmed by setting
~.by hand.resolved picks the most specific matching domain, so the remedy is a narrower
routing domain on the physical link (
~internal.exampleonenp5s0) which thenoutranks
~.for that suffix. That is per-network configuration aqomui has nobusiness guessing, but it does mean this fix can break LAN name resolution for
anyone with a split-horizon setup and no such override.
Worth deciding whether aqomui should expose a "keep these domains off the
tunnel" setting rather than leaving users to discover this. Raised as an audit
item, not addressed here.
Underlying weakness
Both halves of this are the same defect: reading state out of human-readable log
output that upstream is free to change, and has. OpenVPN's management
interface reports device, state and pushed options as structured events
instead. That is the durable fix and a substantially larger change -- flagged
for the audit as a concrete, bounded modernisation target rather than a vague
refactor.
changing to actual interface instead of log reading, don't need this change anymore
Pull request closed