Skip to content

https-dns-proxy: fix dnsmasq server entries left after a stop - #13

Open
strrs wants to merge 2 commits into
mossdef-org:mainfrom
strrs:fix-dnsmasq-leftovers
Open

strrs wants to merge 2 commits into
mossdef-org:mainfrom
strrs:fix-dnsmasq-leftovers

Conversation

@strrs

@strrs strrs commented Nov 20, 2026

Copy link
Copy Markdown

Two cases where a stop leaves entries in the dnsmasq server list, one commit each.

  1. With the service stopped and the default dhcp and https-dns-proxy configs:

    1. service https-dns-proxy start: doh_backup_server=''
    2. service https-dns-proxy restart: doh_backup_server='' '/mask.icloud.com/' '/mask-h2.icloud.com/' '/use-application-dns.net/' '127.0.0.1#5053' '127.0.0.1#5054'
    3. service https-dns-proxy stop: server='/mask.icloud.com/' '/mask-h2.icloud.com/' '/use-application-dns.net/' '127.0.0.1#5053' '127.0.0.1#5054' stays in the dnsmasq section

    uci_get prints nothing for the single empty doh_backup_server element, so the second start takes it for a missing backup and saves the proxy's own entries. The first commit tests whether the option exists, as the restore side already does.

  2. From the same starting state:

    1. service https-dns-proxy start
    2. uci set https-dns-proxy.config.canary_domains_icloud='0', uci set https-dns-proxy.config.canary_domains_mozilla='0', uci commit https-dns-proxy
    3. service https-dns-proxy stop: server='/mask.icloud.com/' '/mask-h2.icloud.com/' '/use-application-dns.net/' stays in the dnsmasq section

    The stop removes the canary entries only for the options that are on at that moment. The second commit records them in doh_server like the listeners, so the stop removes them either way.

A settings change that only reloads the service, such as saving in LuCI, still leaves the canary entries in place until the next stop. Entries that earlier stops already left in the server list stay there and have to be removed once by hand.

Tested: tests/run_tests.sh passes, and each new case fails without its commit. The same steps through start_service and stop_service, with the uci and /lib/functions.sh of OpenWrt snapshot r37187, give the output above without the commits and leave no server entries with them. The first case was also seen on a router running 2026.05.06-r1, after a restart.

Same symptoms as openwrt/packages#23469 (issue 2), openwrt/packages#26169 and #2.

When the dnsmasq instance has no server entries, the first start
stores a single empty doh_backup_server element. A second start
without a stop in between (restart, reload, a config change from
LuCI) gets an empty string from uci_get and treats that as no backup.
It then copies the current server list, the canary entries and the
proxy listeners, into doh_backup_server. The next stop restores them
into the dnsmasq server list, so dnsmasq keeps forwarding to the
stopped listeners and keeps answering the canary domains locally.

Test whether doh_backup_server exists, as the restore side already
does, so an empty backup stays empty.

Add a test that creates the backup twice without a restore and checks
that the restore leaves no server entries.

Signed-off-by: Semih Baskan <strst.gs@gmail.com>
The start adds the canary entries to the dnsmasq server list, but
unlike the proxy listeners it does not record them in doh_server. The
stop removes them only for the canary options that are on at that
moment. When canary_domains_icloud or canary_domains_mozilla is turned
off while the service runs, the next stop leaves those entries in
place and dnsmasq keeps answering the canary domains locally.

Record the canary entries in doh_server as well, like the listeners,
so the stop removes everything the start added. The loop over the
enabled canary domains on the remove side stays, for entries that
older versions added.

Add a test that turns the canary domains off between start and stop,
with the user's own canary entry in the original server list, and
checks that the stop leaves only that entry.

Signed-off-by: Semih Baskan <strst.gs@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant