summaryrefslogtreecommitdiff
path: root/include/iohook.h
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2013-09-24 20:40:20 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-01-22 19:10:01 +0100
commit99f79a4e5c3abbe91a03216824e7659051872054 (patch)
tree629ed4d4cccb115e95f53c582047bc239d213624 /include/iohook.h
parent282138ad0e9ef483ec2a1606376fc5cb6d5f4cbc (diff)
Split IOHook into IOHook and IOHookProvider
Create one IOHook instance for each hooked socket which contains all the hook specific data and read/write/close functions, removing the need for the "issl_session" array in SSL modules. Register instances of the IOHookProvider class in the core and use them to create specialized IOHook instances (OnConnect/OnAccept). Remove the OnHookIO hook, add a dynamic reference to ListenSocket that points to the hook provider (if any) to use for incoming connections on that socket. For outgoing connections modules still have to find the IOHookProvider they want to use themselves but instead of calling AddIOHook(hookprov), now they have to call IOHookProvider::OnConnect() after the connection has been established.
Diffstat (limited to 'include/iohook.h')
-rw-r--r--include/iohook.h34
1 files changed, 22 insertions, 12 deletions
diff --git a/include/iohook.h b/include/iohook.h
index 7c3a0faee..ce7ca2a1b 100644
--- a/include/iohook.h
+++ b/include/iohook.h
@@ -21,7 +21,7 @@
class StreamSocket;
-class IOHook : public ServiceProvider
+class IOHookProvider : public ServiceProvider
{
public:
enum Type
@@ -32,19 +32,35 @@ class IOHook : public ServiceProvider
const Type type;
- IOHook(Module* mod, const std::string& Name, Type hooktype = IOH_UNKNOWN)
+ IOHookProvider(Module* mod, const std::string& Name, Type hooktype = IOH_UNKNOWN)
: ServiceProvider(mod, Name, SERVICE_IOHOOK), type(hooktype) { }
- /** Called immediately after any connection is accepted. This is intended for raw socket
+ /** 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
@@ -62,12 +78,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