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

ircd::server: Add avail() convenience to interface.

This commit is contained in:
Jason Volk 2020-04-21 21:05:33 -07:00
parent 0568719030
commit 5ecc9f99d8
2 changed files with 20 additions and 0 deletions

View file

@ -51,6 +51,7 @@ namespace ircd::server
string_view errmsg(const net::hostport &) noexcept;
bool errant(const net::hostport &) noexcept;
bool exists(const net::hostport &) noexcept;
bool avail(const net::hostport &) noexcept; // exists() && !errant()
peer &find(const net::hostport &);
// mutable utils

View file

@ -216,6 +216,25 @@ ircd::server::errclear(const net::hostport &hostport)
return peer.err_clear();
}
bool
ircd::server::avail(const net::hostport &hostport)
noexcept
{
const auto hostcanon
{
server::canonize(hostport)
};
const auto it
{
peers.find(hostcanon)
};
return it != end(peers)?
!it->second->err_has():
false;
}
bool
ircd::server::errant(const net::hostport &hostport)
noexcept