diff options
-rw-r--r-- | include/inspsocket.h | 5 | ||||
-rw-r--r-- | include/modules/ssl.h | 7 | ||||
-rw-r--r-- | src/inspsocket.cpp | 12 |
3 files changed, 21 insertions, 3 deletions
diff --git a/include/inspsocket.h b/include/inspsocket.h index fef76ae4e..16d2cdbce 100644 --- a/include/inspsocket.h +++ b/include/inspsocket.h @@ -365,6 +365,11 @@ class CoreExport StreamSocket : public EventHandler * @return IOHook belonging to the module or NULL if the module haven't attached an IOHook to this socket */ IOHook* GetModHook(Module* mod) const; + + /** Get the last IOHook attached to this socket + * @return The last IOHook attached to this socket or NULL if no IOHooks are attached + */ + IOHook* GetLastHook() const; }; /** * BufferedSocket is an extendable socket class which modules diff --git a/include/modules/ssl.h b/include/modules/ssl.h index 2227c4b13..ac2e367fd 100644 --- a/include/modules/ssl.h +++ b/include/modules/ssl.h @@ -186,9 +186,10 @@ class SSLIOHook : public IOHook public: static SSLIOHook* IsSSL(StreamSocket* sock) { - IOHook* const iohook = sock->GetIOHook(); - if ((iohook) && ((iohook->prov->type == IOHookProvider::IOH_SSL))) - return static_cast<SSLIOHook*>(iohook); + IOHook* const lasthook = sock->GetLastHook(); + if (lasthook && (lasthook->prov->type == IOHookProvider::IOH_SSL)) + return static_cast<SSLIOHook*>(lasthook); + return NULL; } diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 6cf3e3008..6172aebe2 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -510,6 +510,18 @@ IOHook* StreamSocket::GetModHook(Module* mod) const return NULL; } +IOHook* StreamSocket::GetLastHook() const +{ + IOHook* curr = GetIOHook(); + IOHook* last = curr; + + for (; curr; curr = GetNextHook(curr)) + last = curr; + + return last; +} + + void StreamSocket::AddIOHook(IOHook* newhook) { IOHook* curr = GetIOHook(); |