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:
parent
e640e6ac62
commit
138b7bff65
2 changed files with 18 additions and 3 deletions
|
@ -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
|
||||
|
|
19
ircd/net.cc
19
ircd/net.cc
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue