Skip to content

fix(dns): refuse a --proxy host name instead of NODATA'ing every live name - #298

Merged
ralyodio merged 1 commit into
moshcoder:mainfrom
clawedassistant26:fix/dns-proxy-host-name-nodata-outage
Aug 5, 2026
Merged

fix(dns): refuse a --proxy host name instead of NODATA'ing every live name#298
ralyodio merged 1 commit into
moshcoder:mainfrom
clawedassistant26:fix/dns-proxy-host-name-nodata-outage

Conversation

@clawedassistant26

Copy link
Copy Markdown
Contributor

What

moshcode dns start --proxy <host> (#296) accepts a host name where it can only use an IP address, and the failure is silent.

The bug

The parse takes any non-flag token after --proxy as the host and hands it to the reachability gate:

const host = given && !given.startsWith("-") ? given : null;
const candidates = host ? [host] : ["127.0.0.1", "::1"];

A name like localhost passes proxyReachable() because net.connect("localhost", 443) resolves and connects. But an A/AAAA answer can only carry an address, so:

proxyAddress = { v4: reachable.find(a => isIP(a) === 4), v6: reachable.find(a => isIP(a) === 6) }
             = { v4: null, v6: null }   // isIP("localhost") === 0

The command then prints proxying every live name to localhost:443 — certificates are verified there and, in addressAnswer, every live name hits forFamily = null and returns NODATA. That is precisely the total silent outage ("the sites are down" while dig looks healthy) that the reachability gate was added to refuse — it just walks straight past the gate for a host name.

Reproduced against v0.22.1 driving the real dnsCommand/addressAnswer exports: the CLI prints the success line, and a live name resolves to NODATA for both A and AAAA.

The fix

Refuse a non-IP --proxy host up front, before any probe, with a clear message — the same "refuse rather than silently misconfigure" stance the gate below it already takes. IP hosts (--proxy 10.0.0.5) and the default loopback probe are unchanged.

Tests

Adds --proxy with a host name refuses instead of NODATA'ing every live name to test/dns-proxy-mode.test.mjs. Fails before (name is accepted, no refusal), passes after. Full suite green: 1280 tests, 1066 pass, 0 fail, 214 skip.

… name

A host name like `localhost` passes proxyReachable() (connect resolves it)
but isIP() cannot place it in an A/AAAA answer, so proxyAddress ends up
{v4:null, v6:null}. The mode then prints "proxying every live name ..." and
answers every live name with NODATA — the exact silent outage the
reachability gate exists to refuse. Reject a non-IP --proxy host up front
with a clear message, before any probe, for the same reason the gate does.

Adds a regression test (fails before / passes after).
@ralyodio
ralyodio merged commit 51be4eb into moshcoder:main Aug 5, 2026
4 checks passed
@ralyodio ralyodio mentioned this pull request Aug 5, 2026
ralyodio added a commit that referenced this pull request Aug 5, 2026
Bump moshcode to v0.24.0, releasing third-level Moshpit names (#301), JSON agent status (#300), and the --proxy host refusal fix (#298).
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.

2 participants