diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-04-20 17:40:12 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-04-20 17:40:12 +0200 |
commit | 8f5efbc7aa33b792e02d01e3288f553e6e98ccaa (patch) | |
tree | 54a67ebd11fac07d630fa03acad7797b2f781e80 /src/coremods | |
parent | dda1d696c1316b09d65763b4f12bc2b63cfbbe72 (diff) | |
parent | 1548078e5dc304814669cd1ea052f92be9d1ac40 (diff) |
Merge insp20
Diffstat (limited to 'src/coremods')
-rw-r--r-- | src/coremods/core_dns.cpp | 8 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_motd.cpp | 6 | ||||
-rw-r--r-- | src/coremods/core_list.cpp | 15 | ||||
-rw-r--r-- | src/coremods/core_reloadmodule.cpp | 2 | ||||
-rw-r--r-- | src/coremods/core_stats.cpp | 8 | ||||
-rw-r--r-- | src/coremods/core_user/cmd_user.cpp | 1 | ||||
-rw-r--r-- | src/coremods/core_user/core_user.cpp | 13 | ||||
-rw-r--r-- | src/coremods/core_userhost.cpp | 19 | ||||
-rw-r--r-- | src/coremods/core_who.cpp | 2 |
9 files changed, 58 insertions, 16 deletions
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp index de8dedd4a..9aca8b338 100644 --- a/src/coremods/core_dns.cpp +++ b/src/coremods/core_dns.cpp @@ -33,6 +33,11 @@ using namespace DNS; */ class Packet : public Query { + static bool IsValidName(const std::string& name) + { + return (name.find_first_not_of("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-") == std::string::npos); + } + void PackName(unsigned char* output, unsigned short output_size, unsigned short& pos, const std::string& name) { if (pos + name.length() + 2 > output_size) @@ -183,6 +188,9 @@ class Packet : public Query case QUERY_PTR: { record.rdata = this->UnpackName(input, input_size, pos); + if (!IsValidName(record.rdata)) + throw Exception("Invalid name"); // XXX: Causes the request to time out + break; } default: diff --git a/src/coremods/core_info/cmd_motd.cpp b/src/coremods/core_info/cmd_motd.cpp index 2d396858f..57616094e 100644 --- a/src/coremods/core_info/cmd_motd.cpp +++ b/src/coremods/core_info/cmd_motd.cpp @@ -32,7 +32,13 @@ CommandMotd::CommandMotd(Module* parent) CmdResult CommandMotd::Handle (const std::vector<std::string>& parameters, User *user) { if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName) + { + // Give extra penalty if a non-oper queries the /MOTD of a remote server + LocalUser* localuser = IS_LOCAL(user); + if ((localuser) && (!user->IsOper())) + localuser->CommandFloodPenalty += 2000; return CMD_SUCCESS; + } ConfigTag* tag = ServerInstance->Config->EmptyTag; LocalUser* localuser = IS_LOCAL(user); diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp index 745f019f2..278e6044d 100644 --- a/src/coremods/core_list.cpp +++ b/src/coremods/core_list.cpp @@ -94,14 +94,15 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User // if the channel is not private/secret, OR the user is on the channel anyway bool n = (has_privs || chan->HasUser(user)); - if ((!n) && (chan->IsModeSet(privatemode))) + // If we're not in the channel and +s is set on it, we want to ignore it + if ((n) || (!chan->IsModeSet(secretmode))) { - /* Channel is +p and user is outside/not privileged */ - user->WriteNumeric(RPL_LIST, "* %ld :", users); - } - else - { - if ((n) || (!chan->IsModeSet(secretmode))) + if ((!n) && (chan->IsModeSet(privatemode))) + { + // Channel is private (+p) and user is outside/not privileged + user->WriteNumeric(RPL_LIST, "* %ld :", users); + } + else { /* User is in the channel/privileged, channel is not +s */ user->WriteNumeric(RPL_LIST, "%s %ld :[+%s] %s", chan->name.c_str(), users, chan->ChanModes(n), chan->topic.c_str()); diff --git a/src/coremods/core_reloadmodule.cpp b/src/coremods/core_reloadmodule.cpp index 1561131dc..7f0f15e77 100644 --- a/src/coremods/core_reloadmodule.cpp +++ b/src/coremods/core_reloadmodule.cpp @@ -65,7 +65,7 @@ CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameter if (m) { - ServerInstance->Modules->Reload(m, new ReloadModuleWorker(user->uuid, parameters[0])); + ServerInstance->Modules->Reload(m, (creator->dying ? NULL : new ReloadModuleWorker(user->uuid, parameters[0]))); return CMD_SUCCESS; } else diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp index 997dd3afe..180ece9b3 100644 --- a/src/coremods/core_stats.cpp +++ b/src/coremods/core_stats.cpp @@ -58,7 +58,7 @@ static void GenerateStatsLl(User* user, string_list& results, char c) for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i) { LocalUser* u = *i; - results.push_back("211 "+user->nick+" "+u->nick+"["+u->ident+"@"+(c == 'l' ? u->dhost : u->GetIPString())+"] "+ConvToStr(u->eh.getSendQSize())+" "+ConvToStr(u->cmds_out)+" "+ConvToStr(u->bytes_out)+" "+ConvToStr(u->cmds_in)+" "+ConvToStr(u->bytes_in)+" "+ConvToStr(ServerInstance->Time() - u->age)); + results.push_back("211 "+user->nick+" "+u->nick+"["+u->ident+"@"+(c == 'l' ? u->dhost : u->GetIPString())+"] "+ConvToStr(u->eh.getSendQSize())+" "+ConvToStr(u->cmds_out)+" "+ConvToStr(u->bytes_out)+" "+ConvToStr(u->cmds_in)+" "+ConvToStr(u->bytes_in)+" "+ConvToStr(ServerInstance->Time() - u->signon)); } } @@ -378,7 +378,13 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results) CmdResult CommandStats::Handle (const std::vector<std::string>& parameters, User *user) { if (parameters.size() > 1 && parameters[1] != ServerInstance->Config->ServerName) + { + // Give extra penalty if a non-oper does /STATS <remoteserver> + LocalUser* localuser = IS_LOCAL(user); + if ((localuser) && (!user->IsOper())) + localuser->CommandFloodPenalty += 2000; return CMD_SUCCESS; + } string_list values; char search = parameters[0][0]; DoStats(search, user, values); diff --git a/src/coremods/core_user/cmd_user.cpp b/src/coremods/core_user/cmd_user.cpp index d593d7f4b..cbf4f5e08 100644 --- a/src/coremods/core_user/cmd_user.cpp +++ b/src/coremods/core_user/cmd_user.cpp @@ -58,6 +58,7 @@ CmdResult CommandUser::HandleLocal(const std::vector<std::string>& parameters, L else { user->WriteNumeric(ERR_ALREADYREGISTERED, ":You may not reregister"); + user->CommandFloodPenalty += 1000; return CMD_FAILURE; } diff --git a/src/coremods/core_user/core_user.cpp b/src/coremods/core_user/core_user.cpp index ffa6aa2ff..dd778548a 100644 --- a/src/coremods/core_user/core_user.cpp +++ b/src/coremods/core_user/core_user.cpp @@ -45,6 +45,7 @@ class CommandPass : public SplitCommand // Check to make sure they haven't registered -- Fix by FCS if (user->registered == REG_ALL) { + user->CommandFloodPenalty += 1000; user->WriteNumeric(ERR_ALREADYREGISTERED, ":You may not reregister"); return CMD_FAILURE; } @@ -64,7 +65,6 @@ class CommandPing : public Command CommandPing(Module* parent) : Command(parent, "PING", 1, 2) { - Penalty = 0; syntax = "<servername> [:<servername>]"; } @@ -102,8 +102,15 @@ class CommandPong : public Command CmdResult Handle(const std::vector<std::string>& parameters, User* user) { // set the user as alive so they survive to next ping - if (IS_LOCAL(user)) - IS_LOCAL(user)->lastping = 1; + LocalUser* localuser = IS_LOCAL(user); + if (localuser) + { + // Increase penalty unless we've sent a PING and this is the reply + if (localuser->lastping) + localuser->CommandFloodPenalty += 1000; + else + localuser->lastping = 1; + } return CMD_SUCCESS; } }; diff --git a/src/coremods/core_userhost.cpp b/src/coremods/core_userhost.cpp index a67824194..eae6e51ce 100644 --- a/src/coremods/core_userhost.cpp +++ b/src/coremods/core_userhost.cpp @@ -24,10 +24,15 @@ */ class CommandUserhost : public Command { + UserModeReference hideopermode; + public: /** Constructor for userhost. */ - CommandUserhost ( Module* parent) : Command(parent,"USERHOST", 1, 5) { + CommandUserhost(Module* parent) + : Command(parent,"USERHOST", 1) + , hideopermode(parent, "hideoper") + { syntax = "<nick> [<nick> ...]"; } /** Handle command. @@ -44,7 +49,11 @@ CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, U std::string retbuf = "302 " + user->nick + " :"; - for (unsigned int i = 0; i < parameters.size(); i++) + unsigned int max = parameters.size(); + if (max > 5) + max = 5; + + for (unsigned int i = 0; i < max; i++) { User *u = ServerInstance->FindNickOnly(parameters[i]); @@ -53,7 +62,11 @@ CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, U retbuf += u->nick; if (u->IsOper()) - retbuf += '*'; + { + // XXX: +H hidden opers must not be shown as opers + if ((u == user) || (has_privs) || (!u->IsModeSet(hideopermode))) + retbuf += '*'; + } retbuf += '='; retbuf += (u->IsAway() ? '-' : '+'); diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp index 39ea347dc..8b9258d71 100644 --- a/src/coremods/core_who.cpp +++ b/src/coremods/core_who.cpp @@ -144,7 +144,7 @@ bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext) long seconds = InspIRCd::Duration(matchtext); // Okay, so time matching, we want all users connected `seconds' ago - if (user->age >= ServerInstance->Time() - seconds) + if (user->signon >= ServerInstance->Time() - seconds) match = true; } |