diff options
author | Peter Powell <petpow@saberuk.com> | 2017-10-12 15:55:21 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2017-10-12 15:55:21 +0100 |
commit | a3e0768758ca68429a29d9c78ce672f2d938c6e7 (patch) | |
tree | a66b4c4f917d56e1cef8ffda450d535ea532be35 /src | |
parent | c46f8a368c42f64284244f3d2dfc022a383294fa (diff) | |
parent | 0337b92c158fa662f04056343affd59315da78db (diff) |
Merge the latest changes from insp20 into master.
Diffstat (limited to 'src')
-rw-r--r-- | src/coremods/core_xline/cmd_zline.cpp | 2 | ||||
-rw-r--r-- | src/coremods/core_xline/core_xline.cpp | 4 | ||||
-rw-r--r-- | src/dynamic.cpp | 15 | ||||
-rw-r--r-- | src/inspircd.cpp | 7 | ||||
-rw-r--r-- | src/modules/m_blockcaps.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_cgiirc.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_noctcp.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_sasl.cpp | 1 | ||||
-rw-r--r-- | src/modules/m_timedbans.cpp | 4 | ||||
-rw-r--r-- | src/xline.cpp | 12 |
10 files changed, 24 insertions, 27 deletions
diff --git a/src/coremods/core_xline/cmd_zline.cpp b/src/coremods/core_xline/cmd_zline.cpp index 1bc7e8afd..af9d54a5b 100644 --- a/src/coremods/core_xline/cmd_zline.cpp +++ b/src/coremods/core_xline/cmd_zline.cpp @@ -103,5 +103,5 @@ CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User bool CommandZline::IPMatcher::Check(User* user, const std::string& ip) const { - return InspIRCd::Match(user->GetIPString(), ip, ascii_case_insensitive_map); + return InspIRCd::MatchCIDR(user->GetIPString(), ip, ascii_case_insensitive_map); } diff --git a/src/coremods/core_xline/core_xline.cpp b/src/coremods/core_xline/core_xline.cpp index 93ac1db31..d6c804748 100644 --- a/src/coremods/core_xline/core_xline.cpp +++ b/src/coremods/core_xline/core_xline.cpp @@ -46,8 +46,8 @@ bool InsaneBan::MatchesEveryone(const std::string& mask, MatcherBase& test, User bool InsaneBan::IPHostMatcher::Check(User* user, const std::string& mask) const { - return ((InspIRCd::Match(user->MakeHost(), mask, ascii_case_insensitive_map)) || - (InspIRCd::Match(user->MakeHostIP(), mask, ascii_case_insensitive_map))); + return ((InspIRCd::MatchCIDR(user->MakeHost(), mask, ascii_case_insensitive_map)) || + (InspIRCd::MatchCIDR(user->MakeHostIP(), mask, ascii_case_insensitive_map))); } class CoreModXLine : public Module diff --git a/src/dynamic.cpp b/src/dynamic.cpp index 340f40e19..f138b04d1 100644 --- a/src/dynamic.cpp +++ b/src/dynamic.cpp @@ -43,11 +43,7 @@ DLLManager::DLLManager(const char *fname) h = dlopen(fname, RTLD_NOW|RTLD_LOCAL); if (!h) { -#ifdef _WIN32 RetrieveLastError(); -#else - err = dlerror(); -#endif } } @@ -72,11 +68,7 @@ Module* DLLManager::CallInit() initfn.vptr = dlsym(h, MODULE_INIT_STR); if (!initfn.vptr) { -#ifdef _WIN32 RetrieveLastError(); -#else - err = dlerror(); -#endif return NULL; } @@ -94,18 +86,21 @@ std::string DLLManager::GetVersion() return ""; } -#ifdef _WIN32 void DLLManager::RetrieveLastError() { +#if defined _WIN32 char errmsg[500]; DWORD dwErrorCode = GetLastError(); if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)errmsg, _countof(errmsg), NULL) == 0) sprintf_s(errmsg, _countof(errmsg), "Error code: %u", dwErrorCode); SetLastError(ERROR_SUCCESS); err = errmsg; +#else + char* errmsg = dlerror(); + err = errmsg ? errmsg : "Unknown error"; +#endif std::string::size_type p; while ((p = err.find_last_of("\r\n")) != std::string::npos) err.erase(p, 1); } -#endif diff --git a/src/inspircd.cpp b/src/inspircd.cpp index bc0875502..47660f752 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -642,8 +642,15 @@ void InspIRCd::Run() OLDTIME = TIME.tv_sec; if ((TIME.tv_sec % 3600) == 0) + { FOREACH_MOD(OnGarbageCollect, ()); + // HACK: ELines are not expired properly at the moment but it can't be fixed as + // the 2.0 XLine system is a spaghetti nightmare. Instead we skip over expired + // ELines in XLineManager::CheckELines() and expire them here instead. + XLines->GetAll("E"); + } + Timers.TickTimers(TIME.tv_sec); Users->DoBackgroundUserStuff(); diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp index 6e67cb309..c26d92caa 100644 --- a/src/modules/m_blockcaps.cpp +++ b/src/modules/m_blockcaps.cpp @@ -56,7 +56,7 @@ public: { if (target_type == TYPE_CHANNEL) { - if ((!IS_LOCAL(user)) || (text.length() < minlen)) + if ((!IS_LOCAL(user)) || (text.length() < minlen) || (text == "\1ACTION\1") || (text == "\1ACTION")) return MOD_RES_PASSTHRU; Channel* c = (Channel*)dest; diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index 305801b0a..d8dbe6da7 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -107,7 +107,7 @@ class CommandWebIRC : public SplitCommand realip.set(user, user->GetIPString()); // Check if we're happy with the provided hostname. If it's problematic then make sure we won't set a host later, just the IP - bool host_ok = (parameters[2].length() <= ServerInstance->Config->Limits.MaxHost); + bool host_ok = (parameters[2].length() <= ServerInstance->Config->Limits.MaxHost) && (parameters[2].find_first_not_of("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-") == std::string::npos); const std::string& newhost = (host_ok ? parameters[2] : parameters[3]); if (notify) diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp index 9dd9bf852..713964328 100644 --- a/src/modules/m_noctcp.cpp +++ b/src/modules/m_noctcp.cpp @@ -50,7 +50,7 @@ class ModuleNoCTCP : public Module if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user))) { Channel* c = (Channel*)dest; - if ((text.empty()) || (text[0] != '\001') || (!strncmp(text.c_str(),"\1ACTION ",8))) + if ((text.empty()) || (text[0] != '\001') || (!strncmp(text.c_str(),"\1ACTION ", 8)) || (text == "\1ACTION\1") || (text == "\1ACTION")) return MOD_RES_PASSTHRU; ModResult res; diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index fe1438ccf..eedf968b4 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -174,6 +174,7 @@ class SaslAuthenticator parameterlist params; params.push_back(user->host); params.push_back(user->GetIPString()); + params.push_back(SSLIOHook::IsSSL(&user->eh) ? "S" : "P"); SendSASL(user, "*", 'H', params); } diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 44c6c4c4f..9890800e4 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -118,8 +118,8 @@ class CommandTban : public Command TimedBanList.push_back(T); // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above - ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL); - char pfxchar = (mh && mh->name == "halfop") ? '%' : '@'; + PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h'); + char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@'; channel->WriteAllExcept(ServerInstance->FakeClient, true, pfxchar, tmp, "NOTICE %s :%s added a timed ban on %s lasting for %ld seconds.", channel->name.c_str(), user->nick.c_str(), mask.c_str(), duration); return CMD_SUCCESS; diff --git a/src/xline.cpp b/src/xline.cpp index b116d2e1f..257af9ca7 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -159,6 +159,7 @@ void XLineManager::CheckELines() for (UserManager::LocalList::const_iterator u2 = list.begin(); u2 != list.end(); u2++) { LocalUser* u = *u2; + u->exempt = false; /* This uses safe iteration to ensure that if a line expires here, it doenst trash the iterator */ LookupIter safei; @@ -169,7 +170,8 @@ void XLineManager::CheckELines() safei++; XLine *e = i->second; - u->exempt = e->Matches(u); + if ((!e->duration || ServerInstance->Time() < e->expiry) && e->Matches(u)) + u->exempt = true; i = safei; } @@ -323,14 +325,6 @@ bool XLineManager::DelLine(const char* hostmask, const std::string &type, User* void ELine::Unset() { - /* remove exempt from everyone and force recheck after deleting eline */ - const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers(); - for (UserManager::LocalList::const_iterator u2 = list.begin(); u2 != list.end(); u2++) - { - LocalUser* u = *u2; - u->exempt = false; - } - ServerInstance->XLines->CheckELines(); } |