pub struct LocalSubnets { /* private fields */ }connect-server only.Expand description
The subnets this host is on.
Enumerated once, at construction: interfaces do change, but re-reading them on every
request turns a GET into a syscall storm, and a device whose address changes is going
to be restarted or re-paired anyway.
Implementations§
Source§impl LocalSubnets
impl LocalSubnets
Sourcepub fn detect() -> Result<Self>
pub fn detect() -> Result<Self>
Read this host’s interfaces.
§Errors
When the interfaces cannot be enumerated at all. A host in that state cannot make the check the specification requires, and the caller must decide whether to serve the LAN-only routes without it — this crate will not decide that quietly.
Loopback interfaces are left out: behind a local reverse proxy that terminates TLS,
every request arrives from 127.0.0.1, and counting that as the same subnet would
serve the unauthenticated LAN routes to the internet. A host that really serves
clients on loopback says so with allowing_loopback.
Sourcepub fn from_prefixes(nets: impl IntoIterator<Item = (IpAddr, u8)>) -> Self
pub fn from_prefixes(nets: impl IntoIterator<Item = (IpAddr, u8)>) -> Self
A fixed set of subnets, for a host that knows its own topology better than we do.
Sourcepub fn allowing_loopback(self) -> Self
pub fn allowing_loopback(self) -> Self
Also admit peers on loopback — a test, or a host whose clients really are local processes. Not for a host behind a reverse proxy on the same machine.