0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 02:02:38 +01:00

ircd::net: Interface wrap boost::asio::ip::make_address().

This commit is contained in:
Jason Volk 2019-03-24 15:59:46 -07:00
parent e640e6ac62
commit 138b7bff65
2 changed files with 18 additions and 3 deletions

View file

@ -33,6 +33,8 @@ namespace ircd::net
string_view string_ip4(const mutable_buffer &out, const uint32_t &);
string_view string_ip6(const mutable_buffer &out, const uint128_t &);
string_view string(const mutable_buffer &out, const ipaddr &);
boost::asio::ip::address make_address(const string_view &ip);
}
union ircd::net::ipaddr

View file

@ -1222,7 +1222,7 @@ try
}
,ep
{
ip::address::from_string(unquote(opts.get("host", "0.0.0.0"s))),
make_address(unquote(opts.get("host", "*"_sv))),
opts.get<uint16_t>("port", 8448L)
}
,a
@ -1962,7 +1962,7 @@ try
}
,ep
{
ip::address::from_string(unquote(opts.get("host", "0.0.0.0"s))),
make_address(unquote(opts.get("host", "*"_sv))),
opts.get<uint16_t>("port", 8448L)
}
,a
@ -3725,7 +3725,7 @@ ircd::net::ipport::ipport(const string_view &ip,
const uint16_t &port)
:ipport
{
asio::ip::make_address(ip), port
make_address(ip), port
}
{
}
@ -3784,6 +3784,19 @@ ircd::net::ipport::ipport(const uint128_t &ip,
// net/ipaddr.h
//
boost::asio::ip::address
ircd::net::make_address(const string_view &ip)
try
{
return ip && ip != "*"?
boost::asio::ip::make_address(ip):
boost::asio::ip::address{};
}
catch(const boost::system::system_error &e)
{
throw_system_error(e);
}
ircd::string_view
ircd::net::string(const mutable_buffer &buf,
const ipaddr &ipaddr)