pub fn holds_address(ip: IpAddr) -> boolExpand description
Whether this host holds ip, meaning a socket of this process may be bound
to it.
One bind(2) on a UDP socket at an ephemeral port, and the socket is dropped
on the way out. The kernel answers EADDRNOTAVAIL for an address no local
interface carries and succeeds for one it does, on both Linux and macOS, so
this asks the kernel the question directly. There is no interface
enumeration in std to ask instead.
Nothing is cached. The call is on the tunnel-open path, which is per request and never per packet, an interface can come and go while the server runs, and a cache would need invalidating by an event this process has no portable way to see.
An error that is not “this address is not ours”, an empty descriptor table
or an exhausted ephemeral port range, answers false as well. That is D89’s
rule: local exhaustion is this proxy’s own fault and must not turn into a
verdict about the target. The tunnel that follows fails on its own socket a
moment later and reports proxy_internal_error, which is the truthful
answer.