0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 07:23:53 +01:00

ircd::net: ipport string contructions.

This commit is contained in:
Jason Volk 2018-01-07 17:44:49 -08:00
parent 499e322e83
commit b0427fbb91
2 changed files with 21 additions and 2 deletions

View file

@ -75,6 +75,8 @@ struct ircd::net::ipport
ipport(const uint32_t &ip, const uint16_t &port);
ipport(const uint128_t &ip, const uint16_t &port);
ipport(const boost::asio::ip::address &, const uint16_t &port);
ipport(const string_view &ip, const uint16_t &port);
ipport(const string_view &ip, const string_view &port);
ipport();
friend std::ostream &operator<<(std::ostream &, const ipport &);

View file

@ -2218,10 +2218,29 @@ ircd::net::make_endpoint(const ipport &ipport)
// ipport
//
ircd::net::ipport::ipport(const string_view &ip,
const string_view &port)
:ipport
{
ip, lex_cast<uint16_t>(port)
}
{
}
ircd::net::ipport::ipport(const string_view &ip,
const uint16_t &port)
:ipport
{
asio::ip::make_address(ip), port
}
{
}
ircd::net::ipport::ipport(const boost::asio::ip::address &address,
const uint16_t &port)
{
std::get<TYPE>(*this) = address.is_v6();
std::get<PORT>(*this) = port;
if(is_v6(*this))
{
@ -2229,8 +2248,6 @@ ircd::net::ipport::ipport(const boost::asio::ip::address &address,
std::reverse(std::get<IP>(*this).begin(), std::get<IP>(*this).end());
}
else host4(*this) = address.to_v4().to_ulong();
net::port(*this) = port;
}
///////////////////////////////////////////////////////////////////////////////