diff --git a/include/ircd/net/hostport.h b/include/ircd/net/hostport.h index cb87c6f35..b30bda3ae 100644 --- a/include/ircd/net/hostport.h +++ b/include/ircd/net/hostport.h @@ -67,6 +67,7 @@ struct ircd::net::hostport hostport(const string_view &host, const uint16_t &port); hostport(const string_view &amalgam); hostport(const string_view &amalgam, verbatim_t); + explicit hostport(const rfc3986::uri &); hostport() = default; }; @@ -91,6 +92,23 @@ ircd::net::hostport::hostport(const string_view &host, } {} +/// Constructs from an rfc3986 URI i.e https://foo.com or https://foo.com:8080 +inline +ircd::net::hostport::hostport(const rfc3986::uri &uri) +:host +{ + rfc3986::host(uri.remote) +} +,service +{ + uri.scheme +} +,port +{ + rfc3986::port(uri.remote) +} +{} + /// Creates a host:port pair from a hostname and a port number. When /// passed to net::dns() no SRV resolution will be done because no /// service name has been given. (unless manually optioned when using