diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/inspircd.h | 2 | ||||
-rw-r--r-- | include/modules.h | 13 | ||||
-rw-r--r-- | include/socket.h | 52 | ||||
-rw-r--r-- | include/usermanager.h | 2 |
4 files changed, 21 insertions, 48 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index ab815dd10..4198864ca 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -458,7 +458,7 @@ class CoreExport InspIRCd /** List of the open ports */ - std::vector<ListenSocketBase *> ports; + std::vector<ListenSocket*> ports; /** Set to the current signal recieved */ diff --git a/include/modules.h b/include/modules.h index a066d104a..08f1a2dc0 100644 --- a/include/modules.h +++ b/include/modules.h @@ -303,7 +303,7 @@ enum Implementation I_OnSendSnotice, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo, I_OnWhois, I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreNick, I_OnUserMessage, I_OnUserNotice, I_OnMode, I_OnGetServerDescription, I_OnSyncUser, - I_OnSyncChannel, I_OnDecodeMetaData, I_OnWallops, + I_OnSyncChannel, I_OnDecodeMetaData, I_OnWallops, I_OnAcceptConnection, I_OnChangeHost, I_OnChangeName, I_OnAddLine, I_OnDelLine, I_OnExpireLine, I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule, I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite, @@ -1149,7 +1149,16 @@ class CoreExport Module : public classbase * @param user The item to possibly install the I/O hook on * @param via The port that <user> connected on */ - virtual void OnHookIO(StreamSocket*, ListenSocketBase* via); + virtual void OnHookIO(StreamSocket*, ListenSocket* via); + + /** Called when a port accepts a connection + * Return MOD_RES_ACCEPT if you have used the file descriptor. + * @param fd The file descriptor returned from accept() + * @param from The local port the user connected to + * @param client The client IP address and port + * @param server The server IP address and port + */ + virtual ModResult OnAcceptConnection(int fd, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server); /** Called immediately after any connection is accepted. This is intended for raw socket * processing (e.g. modules which wrap the tcp connection within another library) and provides diff --git a/include/socket.h b/include/socket.h index a42696379..a9b0a472e 100644 --- a/include/socket.h +++ b/include/socket.h @@ -124,68 +124,32 @@ namespace irc } } +struct ConfigTag; /** This class handles incoming connections on client ports. * It will create a new User for every valid connection * and assign it a file descriptor. */ -class CoreExport ListenSocketBase : public EventHandler +class CoreExport ListenSocket : public EventHandler { - protected: - /** Raw address socket is bound to */ + public: + const reference<ConfigTag> bind_tag; std::string bind_addr; - /** Human-readable address/port socket is bound to */ + int bind_port; + /** Human-readable bind description */ std::string bind_desc; - - /** The client address if the most recently connected client. - * Should only be used when accepting a new client. - */ - static irc::sockets::sockaddrs client; - /** The server address used by the most recently connected client. - * This may differ from the bind address by having a nonzero address, - * if the port is wildcard bound, or being IPv4 on a 6to4 IPv6 port. - * The address family will always match that of "client" - */ - static irc::sockets::sockaddrs server; - - public: - /** Socket type (client/server) */ - const std::string type; - /** Socket hook (plain/gnutls/openssl/zip) */ - const std::string hook; - /** Port socket is bound to */ - const int bind_port; /** Create a new listening socket */ - ListenSocketBase(int port, const std::string &addr, const std::string &type, const std::string &hook); + ListenSocket(ConfigTag* tag, const std::string& addr, int port); /** Handle an I/O event */ void HandleEvent(EventType et, int errornum = 0); /** Close the socket */ - ~ListenSocketBase(); - - /** Get IP address socket is bound to - */ - const std::string &GetIP() { return bind_addr; } - - const std::string &GetBindDesc() { return bind_desc; } + ~ListenSocket(); /** Handles sockets internals crap of a connection, convenience wrapper really */ void AcceptInternal(); - - /** Called when a new connection has successfully been accepted on this listener. - * @param fd The file descriptor of the new connection - */ - virtual void OnAcceptReady(int fd) = 0; -}; - -class CoreExport ClientListenSocket : public ListenSocketBase -{ - virtual void OnAcceptReady(int fd); - public: - ClientListenSocket(int port, const std::string &addr, const std::string &Type, const std::string &Hook) - : ListenSocketBase(port, addr, Type, Hook) { } }; #endif diff --git a/include/usermanager.h b/include/usermanager.h index 885394f76..97277f3fb 100644 --- a/include/usermanager.h +++ b/include/usermanager.h @@ -74,7 +74,7 @@ class CoreExport UserManager * @param server The server IP address and port used by the user * @return This function has no return value, but a call to AddClient may remove the user. */ - void AddUser(int socket, ClientListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server); + void AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server); /** Disconnect a user gracefully * @param user The user to remove |