diff --git a/include/ircd/net/remote.h b/include/ircd/net/remote.h index 8cb04714c..a478b41ef 100644 --- a/include/ircd/net/remote.h +++ b/include/ircd/net/remote.h @@ -66,6 +66,8 @@ namespace ircd::net struct ircd::net::hostport :std::pair { + static const hostport null; + hostport(std::string s, const uint16_t &port = 8448); friend std::ostream &operator<<(std::ostream &, const hostport &); @@ -97,8 +99,8 @@ struct ircd::net::ipport ipport(const uint128_t &ip, const uint16_t &port); // DNS lookup! May yield ircd::ctx! - explicit ipport(const std::string &hostname, const std::string &port); - explicit ipport(const std::string &hostname, const uint16_t &port); + ipport(const std::string &hostname, const std::string &port); + ipport(const std::string &hostname, const uint16_t &port); ipport(const string_view &hostname, const string_view &port = "8448"); ipport(const string_view &hostname, const uint16_t &port); ipport(const hostport &); @@ -120,10 +122,12 @@ struct ircd::net::remote operator bool() const; bool operator!() const { return !static_cast(*this); } - explicit remote(std::string hostname, const std::string &port = "8448"s); + remote(std::string hostname, const std::string &port); remote(std::string hostname, const uint16_t &port); - remote(const string_view &hostname, const string_view &port = "8448"); - remote(const string_view &hostname, const uint16_t &port); + remote(std::string hostname); + explicit remote(const string_view &hostname, const string_view &port); + explicit remote(const string_view &hostname, const uint16_t &port); + remote(const string_view &hostname); explicit remote(const ipport &); remote(hostport); remote() = default; diff --git a/ircd/client.cc b/ircd/client.cc index a84f1731f..98cb3427e 100644 --- a/ircd/client.cc +++ b/ircd/client.cc @@ -106,7 +106,7 @@ ircd::hostport ircd::local(const client &client) { if(!client.sock) - return { "0.0.0.0"s, 0 }; + return hostport::null; return net::local_hostport(*client.sock); } @@ -115,7 +115,7 @@ ircd::hostport ircd::remote(const client &client) { if(!client.sock) - return { "0.0.0.0"s, 0 }; + return hostport::null; return net::remote_hostport(*client.sock); } diff --git a/ircd/net.cc b/ircd/net.cc index 65311a6f8..fb82cf7af 100644 --- a/ircd/net.cc +++ b/ircd/net.cc @@ -1643,6 +1643,14 @@ ircd::net::remote::remote(hostport hp) { } +ircd::net::remote::remote(const string_view &host) +:remote +{ + std::string(host), "8448"s +} +{ +} + ircd::net::remote::remote(const string_view &host, const uint16_t &port) :remote @@ -1661,6 +1669,14 @@ ircd::net::remote::remote(const string_view &host, { } +ircd::net::remote::remote(std::string host) +:remote +{ + std::move(host), "8448"s +} +{ +} + ircd::net::remote::remote(std::string host, const uint16_t &port) :ipport{host, port} @@ -1772,6 +1788,12 @@ ircd::net::ipport::ipport(const std::string &host, // hostport // +const ircd::net::hostport +ircd::net::hostport::null +{ + "0.0.0.0"s, 0 +}; + ircd::net::hostport::hostport(std::string s, const uint16_t &port) try