diff options
author | Sadie Powell <sadie@witchery.services> | 2021-06-01 01:33:10 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2021-06-01 01:36:13 +0100 |
commit | 2688cfbad5e121945f61e0f5f023c904a19c7009 (patch) | |
tree | 53110b1b39148c240b7ef45b31b4b07579959c84 | |
parent | 83bb6951fe4a6d3e394327b18badfc846d2e8204 (diff) |
Refactor the sslqueries mode handler.
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.
-rw-r--r-- | src/modules/m_sslmodes.cpp | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp index bc5cb5675..fda90c3d8 100644 --- a/src/modules/m_sslmodes.cpp +++ b/src/modules/m_sslmodes.cpp @@ -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; } }; |