]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix secure websocket users not being seen as secure.
authorMatt Schatz <genius3000@g3k.solutions>
Tue, 21 Jul 2020 02:37:20 +0000 (20:37 -0600)
committerSadie Powell <sadie@witchery.services>
Mon, 27 Jul 2020 08:38:11 +0000 (09:38 +0100)
Since a TLS (SSL) module will always be the last IOHook attached
to a socket, IsSSL() needs to ignore any Middle IOHooks that may
also be attached.

include/inspsocket.h
include/modules/ssl.h
src/inspsocket.cpp

index fef76ae4ea420319b2fb4f59a0dbd6fc83d6623e..16d2cdbce9a686912761f09b6ef3781014a7f0fb 100644 (file)
@@ -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
index 2227c4b13246893fd492d361256c9aff63a8fc74..ac2e367fd00eb04e92320d1c7241c53140015e37 100644 (file)
@@ -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;
        }
 
index 6cf3e3008023a5b18e830c37dfb62ef48e5287c7..6172aebe2b7c8143d3a3ed7fa620871ea4dd8499 100644 (file)
@@ -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();