X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fsocket.h;h=5ca9fc18fc967e199ae7d74d450ba0d0f1e6bdda;hb=01c23b31f7d0ea87052cd22814af826ecb11f0f3;hp=5935500180637128f0ad06c17aa771e3badfd693;hpb=16b8e22615e6b3351b47d13e0540600fa590d0cb;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/socket.h b/include/socket.h index 593550018..5ca9fc18f 100644 --- a/include/socket.h +++ b/include/socket.h @@ -115,6 +115,12 @@ namespace irc * @return true if the conversion was successful, false if unknown address family */ CoreExport bool satoap(const irc::sockets::sockaddrs* sa, std::string& addr, int &port); + /** Convert a binary sockaddr to a user-readable string. + * This means IPv6 addresses are written as [::1]:6667, and *:6668 is used for 0.0.0.0:6668 + * @param sa The structure to convert + * @return The string; "" if not a valid address + */ + CoreExport std::string satouser(const irc::sockets::sockaddrs* sa); } } @@ -133,10 +139,12 @@ class CoreExport ListenSocketBase : public EventHandler /** Socket description (shown in stats p) */ std::string desc; - /** Address socket is bound to */ + /** Raw address socket is bound to */ std::string bind_addr; /** Port socket is bound to */ int bind_port; + /** Human-readable address/port socket is bound to */ + std::string bind_desc; /** The client address if the most recently connected client. * Should only be used when accepting a new client. @@ -167,18 +175,17 @@ class CoreExport ListenSocketBase : public EventHandler } /** Get description for socket */ - const std::string& GetDescription() - { - return desc; - } + const std::string& GetDescription() { return desc; } /** Get port number for socket */ - int GetPort() { return bind_port; } + int GetPort() const { return bind_port; } /** Get IP address socket is bound to */ const std::string &GetIP() { return bind_addr; } + const std::string &GetBindDesc() { return bind_desc; } + /** Handles sockets internals crap of a connection, convenience wrapper really */ void AcceptInternal();