]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_websocket.cpp
Update copyright headers.
[user/henk/code/inspircd.git] / src / modules / m_websocket.cpp
index ee1c00e97fe7b0bfd7473efb9687a686eded5b64..863362a07b3e71221fdfde8b8fdc3060b2b4f166 100644 (file)
@@ -1,7 +1,9 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2019 iwalkalone <iwalkalone69@gmail.com>
+ *   Copyright (C) 2017-2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2016-2017 Attila Molnar <attilamolnar@hush.com>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
 
 #include <utf8.h>
 
-typedef std::vector<std::string> OriginList;
-
 static const char MagicGUID[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
 static const char whitespace[] = " \t\r\n";
 static dynamic_reference_nocheck<HashProvider>* sha1;
 
 struct WebSocketConfig
 {
+       typedef std::vector<std::string> OriginList;
        typedef std::vector<std::string> ProxyRanges;
 
        // The HTTP origins that can connect to the server.
@@ -329,7 +330,7 @@ class WebSocketHook : public IOHookMiddle
                if (originheader.Find(recvq, "Origin:", 7, reqend))
                {
                        const std::string origin = originheader.ExtractValue(recvq);
-                       for (OriginList::const_iterator iter = config.allowedorigins.begin(); iter != config.allowedorigins.end(); ++iter)
+                       for (WebSocketConfig::OriginList::const_iterator iter = config.allowedorigins.begin(); iter != config.allowedorigins.end(); ++iter)
                        {
                                if (InspIRCd::Match(origin, *iter, ascii_case_insensitive_map))
                                {
@@ -364,10 +365,10 @@ class WebSocketHook : public IOHookMiddle
 
                        for (WebSocketConfig::ProxyRanges::const_iterator iter = config.proxyranges.begin(); iter != config.proxyranges.end(); ++iter)
                        {
-                               if (InspIRCd::MatchCIDR(*iter, luser->GetIPString(), ascii_case_insensitive_map))
+                               if (InspIRCd::MatchCIDR(luser->GetIPString(), *iter, ascii_case_insensitive_map))
                                {
                                        // Give the user their real IP address.
-                                       if (realsa == luser->client_sa)
+                                       if (realsa != luser->client_sa)
                                                luser->SetClientIP(realsa);
                                        break;
                                }