0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-24 17:38:54 +02:00

ircd::net: Add hostport construction from explicit rfc3986::uri.

This commit is contained in:
Jason Volk 2020-03-24 12:13:32 -07:00
parent f092b4214b
commit 180963ca22

View file

@ -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