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:
parent
499e322e83
commit
b0427fbb91
2 changed files with 21 additions and 2 deletions
|
@ -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 &);
|
||||
|
|
21
ircd/net.cc
21
ircd/net.cc
|
@ -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;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in a new issue