summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2016-02-22 12:52:18 +0100
committerAttila Molnar <attilamolnar@hush.com>2016-02-22 12:52:18 +0100
commit0b63ccd0b5cb26883d6becb196fb98e4f95d0397 (patch)
treed9c660b46e106d76c5953579eca45e49c4486cbf /src
parent7b6bd133ca4472f6cb8058d5e34e3c8b2af7e99a (diff)
parent1624ab03b86542a2cb02eda809303144974755f3 (diff)
Merge insp20
Diffstat (limited to 'src')
-rw-r--r--src/coremods/core_dns.cpp10
-rw-r--r--src/coremods/core_oper/cmd_kill.cpp2
-rw-r--r--src/inspircd.cpp4
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp2
-rw-r--r--src/modules/m_callerid.cpp9
-rw-r--r--src/modules/m_check.cpp2
-rw-r--r--src/modules/m_dccallow.cpp10
-rw-r--r--src/modules/m_hideoper.cpp40
-rw-r--r--src/modules/m_ircv3.cpp2
-rw-r--r--src/modules/m_namedmodes.cpp9
-rw-r--r--src/modules/m_nationalchars.cpp19
11 files changed, 92 insertions, 17 deletions
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index da468af5f..1e8bb7533 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -339,6 +339,10 @@ class MyManager : public Manager, public Timer, public EventHandler
irc::sockets::sockaddrs myserver;
+ /** Maximum number of entries in cache
+ */
+ static const unsigned int MAX_CACHE_SIZE = 1000;
+
static bool IsExpired(const Query& record, time_t now = ServerInstance->Time())
{
const ResourceRecord& req = record.answers[0];
@@ -374,6 +378,9 @@ class MyManager : public Manager, public Timer, public EventHandler
*/
void AddCache(Query& r)
{
+ if (cache.size() >= MAX_CACHE_SIZE)
+ cache.clear();
+
// Determine the lowest TTL value and use that as the TTL of the cache entry
unsigned int cachettl = UINT_MAX;
for (std::vector<ResourceRecord>::const_iterator i = r.answers.begin(); i != r.answers.end(); ++i)
@@ -383,6 +390,7 @@ class MyManager : public Manager, public Timer, public EventHandler
cachettl = rr.ttl;
}
+ cachettl = std::min(cachettl, (unsigned int)5*60);
ResourceRecord& rr = r.answers.front();
// Set TTL to what we've determined to be the lowest
rr.ttl = cachettl;
@@ -393,7 +401,7 @@ class MyManager : public Manager, public Timer, public EventHandler
public:
DNS::Request* requests[MAX_REQUEST_ID+1];
- MyManager(Module* c) : Manager(c), Timer(3600, true)
+ MyManager(Module* c) : Manager(c), Timer(5*60, true)
{
for (unsigned int i = 0; i <= MAX_REQUEST_ID; ++i)
requests[i] = NULL;
diff --git a/src/coremods/core_oper/cmd_kill.cpp b/src/coremods/core_oper/cmd_kill.cpp
index e6b41382c..4a0cb2f28 100644
--- a/src/coremods/core_oper/cmd_kill.cpp
+++ b/src/coremods/core_oper/cmd_kill.cpp
@@ -117,7 +117,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User
u->Write(":%s KILL %s :%s!%s!%s (%s)", ServerInstance->Config->HideKillsServer.empty() ? user->GetFullHost().c_str() : ServerInstance->Config->HideKillsServer.c_str(),
u->nick.c_str(),
ServerInstance->Config->ServerName.c_str(),
- user->dhost.c_str(),
+ ServerInstance->Config->HideKillsServer.empty() ? user->dhost.c_str() : ServerInstance->Config->HideKillsServer.c_str(),
ServerInstance->Config->HideKillsServer.empty() ? user->nick.c_str() : ServerInstance->Config->HideKillsServer.c_str(),
parameters[1].c_str());
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 69aa2619c..eb24cdea0 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -649,11 +649,11 @@ void InspIRCd::Run()
/* Allow a buffer of two seconds drift on this so that ntpdate etc dont harass admins */
if (TIME.tv_sec < OLDTIME - 2)
{
- SNO->WriteToSnoMask('d', "\002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %lu secs.", (unsigned long)OLDTIME-TIME.tv_sec);
+ SNO->WriteToSnoMask('d', "\002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %lu secs.", (unsigned long)(OLDTIME-TIME.tv_sec));
}
else if (TIME.tv_sec > OLDTIME + 2)
{
- SNO->WriteToSnoMask('d', "\002EH?!\002 -- Time is jumping FORWARDS! Clock skipped %lu secs.", (unsigned long)TIME.tv_sec - OLDTIME);
+ SNO->WriteToSnoMask('d', "\002EH?!\002 -- Time is jumping FORWARDS! Clock skipped %lu secs.", (unsigned long)(TIME.tv_sec - OLDTIME));
}
OLDTIME = TIME.tv_sec;
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 8d786cc3f..6a653dded 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -59,7 +59,7 @@
#endif
#ifdef _WIN32
-# pragma comment(lib, "libgnutls-28.lib")
+# pragma comment(lib, "libgnutls-30.lib")
#endif
/* $CompileFlags: pkgconfincludes("gnutls","/gnutls/gnutls.h","") eval("print `libgcrypt-config --cflags | tr -d \r` if `pkg-config --modversion gnutls 2>/dev/null | tr -d \r` lt '2.12'") */
diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp
index c844ef04f..0eb208138 100644
--- a/src/modules/m_callerid.cpp
+++ b/src/modules/m_callerid.cpp
@@ -89,7 +89,12 @@ struct CallerIDExtInfo : public ExtensionItem
if (format == FORMAT_NETWORK)
return;
+ void* old = get_raw(container);
+ if (old)
+ this->free(old);
callerid_data* dat = new callerid_data;
+ set_raw(container, dat);
+
irc::commasepstream s(value);
std::string tok;
if (s.GetToken(tok))
@@ -107,10 +112,6 @@ struct CallerIDExtInfo : public ExtensionItem
}
}
}
-
- void* old = set_raw(container, dat);
- if (old)
- this->free(old);
}
callerid_data* get(User* user, bool create)
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp
index 6f9c32fb1..22dcf730f 100644
--- a/src/modules/m_check.cpp
+++ b/src/modules/m_check.cpp
@@ -213,7 +213,7 @@ class CommandCheck : public Command
/* /check on a channel */
user->SendText(checkstr + " timestamp " + timestring(targchan->age));
- if (targchan->topic[0] != 0)
+ if (!targchan->topic.empty())
{
/* there is a topic, assume topic related information exists */
user->SendText(checkstr + " topic " + targchan->topic);
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index 93fddf813..0e57896f3 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -58,6 +58,7 @@ class CommandDccallow : public Command
DCCAllowExt& ext;
public:
+ unsigned int maxentries;
CommandDccallow(Module* parent, DCCAllowExt& Ext)
: Command(parent, "DCCALLOW", 0)
, ext(Ext)
@@ -142,6 +143,12 @@ class CommandDccallow : public Command
ul.push_back(user);
}
+ if (dl->size() >= maxentries)
+ {
+ user->WriteNumeric(996, "%s :Too many nicks on DCCALLOW list", user->nick.c_str());
+ return CMD_FAILURE;
+ }
+
for (dccallowlist::const_iterator k = dl->begin(); k != dl->end(); ++k)
{
if (k->nickname == target->nick)
@@ -453,6 +460,9 @@ class ModuleDCCAllow : public Module
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
+ ConfigTag* tag = ServerInstance->Config->ConfValue("dccallow");
+ cmd.maxentries = tag->getInt("maxentries", 20);
+
bfl.clear();
ConfigTagList tags = ServerInstance->Config->ConfTags("banfile");
for (ConfigIter i = tags.first; i != tags.second; ++i)
diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp
index 9f40d702e..03f6745ee 100644
--- a/src/modules/m_hideoper.cpp
+++ b/src/modules/m_hideoper.cpp
@@ -26,19 +26,37 @@
class HideOper : public SimpleUserModeHandler
{
public:
+ size_t opercount;
+
HideOper(Module* Creator) : SimpleUserModeHandler(Creator, "hideoper", 'H')
+ , opercount(0)
{
oper = true;
}
+
+ ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding)
+ {
+ if (SimpleUserModeHandler::OnModeChange(source, dest, channel, parameter, adding) == MODEACTION_DENY)
+ return MODEACTION_DENY;
+
+ if (adding)
+ opercount++;
+ else
+ opercount--;
+
+ return MODEACTION_ALLOW;
+ }
};
class ModuleHideOper : public Module, public Whois::LineEventListener
{
HideOper hm;
+ bool active;
public:
ModuleHideOper()
: Whois::LineEventListener(this)
, hm(this)
+ , active(false)
{
}
@@ -47,6 +65,28 @@ class ModuleHideOper : public Module, public Whois::LineEventListener
return Version("Provides support for hiding oper status with user mode +H", VF_VENDOR);
}
+ void OnUserQuit(User* user, const std::string&, const std::string&) CXX11_OVERRIDE
+ {
+ if (user->IsModeSet(hm))
+ hm.opercount--;
+ }
+
+ ModResult OnNumeric(User* user, unsigned int numeric, const std::string& text) CXX11_OVERRIDE
+ {
+ if (numeric != 252 || active || user->HasPrivPermission("users/auspex"))
+ return MOD_RES_PASSTHRU;
+
+ // If there are no visible operators then we shouldn't send the numeric.
+ size_t opercount = ServerInstance->Users->all_opers.size() - hm.opercount;
+ if (opercount)
+ {
+ active = true;
+ user->WriteNumeric(252, "%lu :operator(s) online", opercount);
+ active = false;
+ }
+ return MOD_RES_DENY;
+ }
+
ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE
{
/* Dont display numeric 313 (RPL_WHOISOPER) if they have +H set and the
diff --git a/src/modules/m_ircv3.cpp b/src/modules/m_ircv3.cpp
index 5275e9bd5..9e94e556d 100644
--- a/src/modules/m_ircv3.cpp
+++ b/src/modules/m_ircv3.cpp
@@ -160,7 +160,7 @@ class ModuleIRCv3 : public Module, public AccountEventListener
{
// Send the away notify line if the current member is local, has the away-notify cap and isn't excepted
User* member = IS_LOCAL(it->first);
- if ((member) && (cap_awaynotify.get(member)) && (last_excepts.find(member) == last_excepts.end()))
+ if ((member) && (cap_awaynotify.get(member)) && (last_excepts.find(member) == last_excepts.end()) && (it->second != memb))
{
member->Write(line);
}
diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp
index 1735df924..617ee43b3 100644
--- a/src/modules/m_namedmodes.cpp
+++ b/src/modules/m_namedmodes.cpp
@@ -30,7 +30,12 @@ static void DisplayList(User* user, Channel* channel)
continue;
items << " +" << mh->name;
if (mh->GetNumParams(true))
- items << " " << channel->GetModeParameter(mh);
+ {
+ if ((mh->name == "key") && (!channel->HasUser(user)) && (!user->HasPrivPermission("channels/auspex")))
+ items << " <key>";
+ else
+ items << " " << channel->GetModeParameter(mh);
+ }
}
const std::string line = ":" + ServerInstance->Config->ServerName + " 961 " + user->nick + " " + channel->name;
user->SendText(line, items);
@@ -64,6 +69,8 @@ class CommandProp : public Command
while (i < parameters.size())
{
std::string prop = parameters[i++];
+ if (prop.empty())
+ continue;
bool plus = prop[0] != '-';
if (prop[0] == '+' || prop[0] == '-')
prop.erase(prop.begin());
diff --git a/src/modules/m_nationalchars.cpp b/src/modules/m_nationalchars.cpp
index b3937b4a4..8e836c407 100644
--- a/src/modules/m_nationalchars.cpp
+++ b/src/modules/m_nationalchars.cpp
@@ -271,11 +271,19 @@ class ModuleNationalChars : public Module
{
ConfigTag* tag = ServerInstance->Config->ConfValue("nationalchars");
charset = tag->getString("file");
- casemapping = tag->getString("casemapping", charset);
+ casemapping = tag->getString("casemapping", FileSystem::GetFileName(charset));
+ if (casemapping.find(' ') != std::string::npos)
+ throw ModuleException("<nationalchars:casemapping> must not contain any spaces!");
+#if defined _WIN32
+ if (!FileSystem::StartsWithWindowsDriveLetter(charset))
+ charset.insert(0, "./locales/");
+#else
if(charset[0] != '/')
charset.insert(0, "../locales/");
+#endif
unsigned char * tables[8] = { m_additional, m_additionalMB, m_additionalUp, m_lower, m_upper, m_additionalUtf8, m_additionalUtf8range, m_additionalUtf8interval };
- loadtables(charset, tables, 8, 5);
+ if (!loadtables(charset, tables, 8, 5))
+ throw ModuleException("The locale file failed to load. Check your log file for more information.");
forcequit = tag->getBool("forcequit");
CheckForceQuit("National character set changed");
CheckRehash();
@@ -320,13 +328,13 @@ class ModuleNationalChars : public Module
}
/*so Bynets Unreal distribution stuff*/
- void loadtables(std::string filename, unsigned char ** tables, unsigned char cnt, char faillimit)
+ bool loadtables(std::string filename, unsigned char ** tables, unsigned char cnt, char faillimit)
{
std::ifstream ifs(ServerInstance->Config->Paths.PrependConfig(filename).c_str());
if (ifs.fail())
{
ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "loadtables() called for missing file: %s", filename.c_str());
- return;
+ return false;
}
for (unsigned char n=0; n< cnt; n++)
@@ -341,11 +349,12 @@ class ModuleNationalChars : public Module
if (loadtable(ifs, tables[n], 255) && (n < faillimit))
{
ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "loadtables() called for illegal file: %s (line %d)", filename.c_str(), n+1);
- return;
+ return false;
}
}
makereverse(m_additional, m_reverse_additional, sizeof(m_additional));
+ return true;
}
unsigned char symtoi(const char *t,unsigned char base)