X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fiohook.h;h=cf27fcb0cfc4876b7fdba0312fd3aea0d34d6141;hb=da29af8cba49d51e53d6e68237ccbf6370b6dd1f;hp=87403681d1f530c4925ac86531064f8236eb5804;hpb=79db1cf848c64ba50bebadef4c683ae4237080b7;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/iohook.h b/include/iohook.h index 87403681d..cf27fcb0c 100644 --- a/include/iohook.h +++ b/include/iohook.h @@ -21,32 +21,55 @@ class StreamSocket; -class IOHook : public ServiceProvider +class IOHookProvider : public ServiceProvider { public: - IOHook(Module* mod, const std::string& Name) - : ServiceProvider(mod, Name, SERVICE_IOHOOK) { } + enum Type + { + IOH_UNKNOWN, + IOH_SSL + }; - /** Called immediately after any connection is accepted. This is intended for raw socket + const Type type; + + IOHookProvider(Module* mod, const std::string& Name, Type hooktype = IOH_UNKNOWN) + : ServiceProvider(mod, Name, SERVICE_IOHOOK), type(hooktype) { } + + /** Called immediately after a connection is accepted. This is intended for raw socket * processing (e.g. modules which wrap the tcp connection within another library) and provides * no information relating to a user record as the connection has not been assigned yet. - * There are no return values from this call as all modules get an opportunity if required to - * process the connection. * @param sock The socket in question * @param client The client IP address and port * @param server The server IP address and port */ - virtual void OnStreamSocketAccept(StreamSocket* sock, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) = 0; + virtual void OnAccept(StreamSocket* sock, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) = 0; + + /** Called immediately upon connection of an outbound BufferedSocket which has been hooked + * by a module. + * @param sock The socket in question + */ + virtual void OnConnect(StreamSocket* sock) = 0; +}; + +class IOHook : public classbase +{ + public: + /** The IOHookProvider for this hook, contains information about the hook, + * such as the module providing it and the hook type. + */ + IOHookProvider* const prov; + + IOHook(IOHookProvider* provider) + : prov(provider) { } /** * Called when a hooked stream has data to write, or when the socket * engine returns it as writable * @param sock The socket in question - * @param sendq Data to send to the socket * @return 1 if the sendq has been completely emptied, 0 if there is * still data to send, and -1 if there was an error */ - virtual int OnStreamSocketWrite(StreamSocket* sock, std::string& sendq) = 0; + virtual int OnStreamSocketWrite(StreamSocket* sock) = 0; /** Called immediately before any socket is closed. When this event is called, shutdown() * has not yet been called on the socket. @@ -54,12 +77,6 @@ class IOHook : public ServiceProvider */ virtual void OnStreamSocketClose(StreamSocket* sock) = 0; - /** Called immediately upon connection of an outbound BufferedSocket which has been hooked - * by a module. - * @param sock The socket in question - */ - virtual void OnStreamSocketConnect(StreamSocket* sock) = 0; - /** * Called when the stream socket has data to read * @param sock The socket that is ready