mirror of
https://github.com/matrix-construct/construct
synced 2024-10-02 13:48:53 +02:00
ircd::net: Add util to detect usable ipv6 interface.
This commit is contained in:
parent
672e9dd712
commit
c0cbfd2d23
2 changed files with 24 additions and 0 deletions
|
@ -24,6 +24,8 @@ namespace ircd::net::addrs
|
|||
|
||||
bool for_each(const raw_closure &);
|
||||
bool for_each(const closure &);
|
||||
|
||||
bool has_usable_ipv6_interface();
|
||||
}
|
||||
|
||||
struct ircd::net::addrs::addr
|
||||
|
|
22
ircd/net.cc
22
ircd/net.cc
|
@ -690,6 +690,28 @@ ircd::net::open(socket &socket,
|
|||
// net/addrs.h
|
||||
//
|
||||
|
||||
bool
|
||||
ircd::net::addrs::has_usable_ipv6_interface()
|
||||
{
|
||||
return !for_each([](const addr &a)
|
||||
{
|
||||
if(a.family != AF_INET6)
|
||||
return true;
|
||||
|
||||
if(a.scope_id != 0) // global scope
|
||||
return true;
|
||||
|
||||
if(~a.flags & IFF_UP) // not up
|
||||
return true;
|
||||
|
||||
if(a.flags & IFF_LOOPBACK) // not usable
|
||||
return true;
|
||||
|
||||
// return false to break
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::net::addrs::for_each(const closure &closure)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue