InspIRCd  4.0
Classes | Functions
irc::sockets Namespace Reference


union  sockaddrs
struct  cidr_mask


bool MatchCIDR (const std::string &address, const std::string &cidr_mask, bool match_with_username)
bool aptosa (const std::string &addr, int port, irc::sockets::sockaddrs &sa)
bool untosa (const std::string &path, irc::sockets::sockaddrs &sa)
bool isunix (const std::string &file)

Detailed Description

This namespace contains various protocol-independent helper classes. It also contains some types which are often used by the core and modules in place of inet_* functions and types.

Function Documentation

◆ aptosa()

bool irc::sockets::aptosa ( const std::string &  addr,
int  port,
irc::sockets::sockaddrs sa 

Convert an address-port pair into a binary sockaddr

addrThe IP address, IPv4 or IPv6
portThe port, 0 for unspecified
saThe structure to place the result in. Will be zeroed prior to conversion
true if the conversion was successful, false if not.

◆ isunix()

bool irc::sockets::isunix ( const std::string &  file)

Determines whether the specified file is a UNIX socket.

fileThe path to the file to check.
True if the file is a UNIX socket; otherwise, false.

◆ MatchCIDR()

bool irc::sockets::MatchCIDR ( const std::string &  address,
const std::string &  cidr_mask,
bool  match_with_username 

Match CIDR, including an optional username/nickname part.

This function will compare a human-readable address (plus optional username and nickname) against a human-readable CIDR mask, for example [email protected] against *[email protected]/16. This method supports both IPV4 and IPV6 addresses.

addressThe human readable address, e.g. [email protected]
cidr_maskThe human readable mask, e.g. *@
match_with_usernameDoes the mask include a nickname segment?
True if the mask matches the address

◆ untosa()

bool irc::sockets::untosa ( const std::string &  path,
irc::sockets::sockaddrs sa 

Convert a UNIX socket path to a binary sockaddr.

pathThe path to the UNIX socket.
saThe structure to place the result in. Will be zeroed prior to conversion.
True if the conversion was successful; otherwise, false.