0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

ircd::net: Tweak net::remote ctor related.

This commit is contained in:
Jason Volk 2017-11-15 17:26:13 -08:00
parent 78e8a3668d
commit 08469eb2a0
3 changed files with 33 additions and 7 deletions

View file

@ -66,6 +66,8 @@ namespace ircd::net
struct ircd::net::hostport
:std::pair<std::string, uint16_t>
{
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<bool>(*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;

View file

@ -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);
}

View file

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