]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Refactor the sslqueries mode handler.
authorSadie Powell <sadie@witchery.services>
Tue, 1 Jun 2021 00:33:10 +0000 (01:33 +0100)
committerSadie Powell <sadie@witchery.services>
Tue, 1 Jun 2021 00:36:13 +0000 (01:36 +0100)
This fixes a rare desync where a server with the sslmodes module
but without the sslinfo module could desync when a remote user on
a server with both enables the sslqueries mode.

src/modules/m_sslmodes.cpp

index bc5cb56752314693c108ad697e0f9500454d2403..fda90c3d8278c9b77cb934c6690cfec7be84cf0b 100644 (file)
@@ -34,6 +34,8 @@ enum
 {
        // From UnrealIRCd.
        ERR_SECUREONLYCHAN = 489,
+
+       // InspIRCd-specific.
        ERR_ALLMUSTSSL = 490
 };
 
@@ -120,27 +122,14 @@ class SSLModeUser : public ModeHandler
 
        ModeAction OnModeChange(User* user, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE
        {
-               if (adding)
-               {
-                       if (!dest->IsModeSet(this))
-                       {
-                               if (!API || !API->GetCertificate(user))
-                                       return MODEACTION_DENY;
+               if (adding == dest->IsModeSet(this))
+                       return MODEACTION_DENY;
 
-                               dest->SetMode(this, true);
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else
-               {
-                       if (dest->IsModeSet(this))
-                       {
-                               dest->SetMode(this, false);
-                               return MODEACTION_ALLOW;
-                       }
-               }
+               if (adding && IS_LOCAL(user) && (!API || !API->GetCertificate(user)))
+                       return MODEACTION_DENY;
 
-               return MODEACTION_DENY;
+               dest->SetMode(this, adding);
+               return MODEACTION_ALLOW;
        }
 };