From d03d2c1944344e785e258ba6a06d98172576805d Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 18 Mar 2019 17:40:16 -0700 Subject: [PATCH] ircd::net::hostport: Add non-canonicalizing constructor. --- include/ircd/net/hostport.h | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/include/ircd/net/hostport.h b/include/ircd/net/hostport.h index 709c0997d..094339d7d 100644 --- a/include/ircd/net/hostport.h +++ b/include/ircd/net/hostport.h @@ -54,6 +54,8 @@ namespace ircd /// struct ircd::net::hostport { + IRCD_OVERLOAD(verbatim) + string_view host {"0.0.0.0"}; string_view service {canon_service}; uint16_t port {canon_port}; @@ -64,6 +66,7 @@ struct ircd::net::hostport hostport(const string_view &host, const string_view &service, const uint16_t &port = canon_port); hostport(const string_view &host, const uint16_t &port); hostport(const string_view &amalgam); + hostport(const string_view &amalgam, verbatim_t); hostport() = default; }; @@ -76,12 +79,10 @@ inline ircd::net::hostport::hostport(const string_view &host, const string_view &service, const uint16_t &port) -:host{host} +:host{rfc3986::host(host)} ,service{service} ,port{port} -{ - rfc3986::valid_host(host); -} +{} /// 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 @@ -136,6 +137,25 @@ ircd::net::hostport::hostport(const string_view &amalgam) this->port = canon_port; } +inline +ircd::net::hostport::hostport(const string_view &amalgam, + verbatim_t) +:host +{ + rfc3986::host(amalgam) +} +,service +{ + amalgam != host && !rfc3986::port(amalgam)? + rsplit(amalgam, ':').second: + string_view{} +} +,port +{ + rfc3986::port(amalgam) +} +{} + inline ircd::net::hostport::operator bool()