oa_gateway::addr

Function resolve_addr

Source
pub(crate) async fn resolve_addr(
    key: &str,
    value: &str,
) -> Result<SocketAddr, String>
Expand description

Resolves a configured address string to a socket address.

Accepts a literal address or a host:port that needs a lookup, so localhost:9000 works as naturally as 127.0.0.1:9000.

When a name offers both families, IPv4 wins. localhost resolves to ::1 first on some hosts, and binding there alone would refuse the documented 127.0.0.1:9000 clients.

key is the config field name used in error messages and the resolution log line, not part of the lookup.

ยงErrors

Returns an error if value is not a usable address, the lookup fails, or the name resolves to no addresses.