Repository navigation
Conversation
…r did
`Bind` had three values — `loopback`, `lan`, `all` — and **two of them
were the same thing**. `lan` and `all` both resolved to `0.0.0.0`; the
only difference between them was the default contents of `allow_from`.
That made `lan` a whitelist concept wearing a network-interface costume.
Someone picking "LAN" reasonably believes the gateway is listening on
their local network interface. It is listening on **every** interface,
including whichever one faces the internet, and the only thing standing
between the two is a CIDR list they never saw. The field's own doc
comment has always read `loopback | lan | all | 具体 IP`, so a concrete
address was the intent; the enum just never grew one.
So: `Loopback | All | Addr(IpAddr)`, with the serde impl written by hand
because all three are plain strings in YAML.
bind: loopback # 127.0.0.1
bind: 192.168.1.5 # one interface
bind: all # 0.0.0.0
`lan` is gone rather than aliased. It is one of two names for the same
address, and keeping it would preserve the confusion this commit exists
to remove. Any config still carrying it now fails to load with an error
that names the three valid forms — a bad `bind` takes the whole config
down, so that message has to arrive with the answer in it.
**`is_exposed` now asks the address, not the variant.** `bind: 127.0.0.1`
written out longhand is loopback, and should not force key checking or
auto-fill the private-range whitelist just because it took a different
spelling to get there.
## `GET /interfaces`
New, and the reason the above is usable: it lists this machine's
interfaces so a picker can offer them. Without it, choosing an interface
means reading `ifconfig` and copying an address into a YAML file by
hand, where a typo surfaces as "Can't assign requested address" at
startup.
`getifaddrs` through `libc`, which is already a workspace dependency —
the whole thing is under fifty lines, well below the cost of a crate.
Interfaces that are down or have no address are skipped, because they
cannot be bound and listing them only produces a choice that fails.
IPv6 link-local is skipped too: it needs a scope id (`fe80::1%en0`) to
be usable at all, and that spelling in a config file is a trap.
Nothing is cached. Interfaces change when a cable moves, a different
Wi-Fi connects, or a VPN comes up, and a cached list means offering an
address that no longer exists.
The tests assert only what holds on any machine — that a loopback entry
exists, that no entry is malformed, that loopback sorts last so it never
heads a picker whose other option already means "this machine only".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The
lanthat never didBindhad three values —loopback,lan,all— and two of them were the same thing.lanandallboth resolved to0.0.0.0; the only difference between them was the default contents ofallow_from.That made
lana whitelist concept wearing a network-interface costume. Someone picking "LAN" reasonably believes the gateway is listening on their local network interface. It is listening on every interface, including whichever one faces the internet, and the only thing between the two is a CIDR list they never saw.The field's own doc comment has always read
loopback | lan | all | 具体 IP, so a concrete address was the intent — the enum just never grew one.Loopback | All | Addr(IpAddr), with the serde impl written by hand because all three are plain strings in YAML.lanis removed, not aliased. It is one of two names for the same address, and keeping it would preserve the exact confusion this change exists to remove. A config still carrying it now fails to load, with an error that names the three valid forms — a badbindtakes the whole config down, so that message has to arrive with the answer in it.is_exposednow asks the address, not the variant.bind: 127.0.0.1written out longhand is loopback, and should not force key checking or auto-fill the private-range whitelist just because it took a different spelling to get there.GET /interfacesNew, and the reason the above is usable: it lists this machine's interfaces so a picker can offer them. Without it, choosing an interface means reading
ifconfigand copying an address into YAML by hand, where a typo surfaces asCan't assign requested addressat startup.getifaddrsthroughlibc, already a workspace dependency — the whole module is under fifty lines, well below the cost of taking on a crate for it.fe80::1%en0) to be usable at all, and that spelling in a config file is a trap.The tests assert only what holds on any machine — a loopback entry exists, no entry is malformed, and loopback sorts last so it never heads a picker whose other option already means "this machine only".
Verification
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings, 1072 tests (5 new onBind, 2 on interface listing), andscripts/smoke.sh— 46 checks, 0 failures.Checked live against a running gateway over the control socket:
🤖 Generated with Claude Code