summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-08-30 13:01:10 +0200
committerattilamolnar <attilamolnar@hush.com>2013-08-30 13:01:10 +0200
commit1031f333332cf1b09db4fd632f141143ee637c34 (patch)
tree3f2b3c08e9a743f19725da45f3879aa2bf54bfbf /src/modules
parent7432fea968127b606fc029ae462e91d3f30df8a4 (diff)
parentd54eec6dd8d44cba3c1e935f72089dbe675e0820 (diff)
Merge insp20
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp10
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp2
-rw-r--r--src/modules/m_dnsbl.cpp32
-rw-r--r--src/modules/m_ircv3.cpp2
-rw-r--r--src/modules/m_permchannels.cpp106
-rw-r--r--src/modules/m_spanningtree/fjoin.cpp32
-rw-r--r--src/modules/m_spanningtree/main.cpp7
-rw-r--r--src/modules/m_spanningtree/utils.h3
-rw-r--r--src/modules/m_userip.cpp2
9 files changed, 143 insertions, 53 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index dab377397..53fc38ec0 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -47,8 +47,14 @@
/* $CompileFlags: pkgconfincludes("gnutls","/gnutls/gnutls.h","") exec("libgcrypt-config --cflags") -Wno-pedantic */
/* $LinkerFlags: rpath("pkg-config --libs gnutls") pkgconflibs("gnutls","/libgnutls.so","-lgnutls") exec("libgcrypt-config --libs") */
+#ifndef GNUTLS_VERSION_MAJOR
+#define GNUTLS_VERSION_MAJOR LIBGNUTLS_VERSION_MAJOR
+#define GNUTLS_VERSION_MINOR LIBGNUTLS_VERSION_MINOR
+#define GNUTLS_VERSION_PATCH LIBGNUTLS_VERSION_PATCH
+#endif
+
// These don't exist in older GnuTLS versions
-#if ((GNUTLS_VERSION_MAJOR > 2) || (GNUTLS_VERSION_MAJOR == 2 && GNUTLS_VERSION_MINOR > 1) || (GNUTLS_VERSION_MAJOR == 2 && GNUTLS_VERSION_MINOR == 1 && GNUTLS_VERSION_MICRO >= 7))
+#if ((GNUTLS_VERSION_MAJOR > 2) || (GNUTLS_VERSION_MAJOR == 2 && GNUTLS_VERSION_MINOR > 1) || (GNUTLS_VERSION_MAJOR == 2 && GNUTLS_VERSION_MINOR == 1 && GNUTLS_VERSION_PATCH >= 7))
#define GNUTLS_NEW_PRIO_API
#endif
@@ -115,6 +121,8 @@ class GnuTLSIOHook : public SSLIOHook
#ifdef GNUTLS_NEW_PRIO_API
gnutls_priority_set(session->sess, priority);
+ #else
+ gnutls_set_default_priority(session->sess);
#endif
gnutls_credentials_set(session->sess, GNUTLS_CRD_CERTIFICATE, x509_cred);
gnutls_dh_set_prime_bits(session->sess, dh_bits);
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 4cb6ee07b..29c3568ef 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -184,7 +184,7 @@ class OpenSSLIOHook : public SSLIOHook
certinfo->invalid = (SSL_get_verify_result(session->sess) != X509_V_OK);
- if (SelfSigned)
+ if (!SelfSigned)
{
certinfo->unknownsigner = false;
certinfo->trusted = true;
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index becc7a6e8..3c9d64d49 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -26,7 +26,7 @@
#include "modules/dns.h"
/* Class holding data for a single entry */
-class DNSBLConfEntry
+class DNSBLConfEntry : public refcountbase
{
public:
enum EnumBanaction { I_UNKNOWN, I_KILL, I_ZLINE, I_KLINE, I_GLINE, I_MARK };
@@ -49,11 +49,11 @@ class DNSBLResolver : public DNS::Request
std::string theiruid;
LocalStringExt& nameExt;
LocalIntExt& countExt;
- DNSBLConfEntry *ConfEntry;
+ reference<DNSBLConfEntry> ConfEntry;
public:
- DNSBLResolver(DNS::Manager *mgr, Module *me, LocalStringExt& match, LocalIntExt& ctr, const std::string &hostname, LocalUser* u, DNSBLConfEntry *conf)
+ DNSBLResolver(DNS::Manager *mgr, Module *me, LocalStringExt& match, LocalIntExt& ctr, const std::string &hostname, LocalUser* u, reference<DNSBLConfEntry> conf)
: DNS::Request(mgr, me, hostname, DNS::QUERY_A, true), theiruid(u->uuid), nameExt(match), countExt(ctr), ConfEntry(conf)
{
}
@@ -203,7 +203,7 @@ class DNSBLResolver : public DNS::Request
class ModuleDNSBL : public Module
{
- std::vector<DNSBLConfEntry *> DNSBLConfEntries;
+ std::vector<reference<DNSBLConfEntry> > DNSBLConfEntries;
dynamic_reference<DNS::Manager> DNS;
LocalStringExt nameExt;
LocalIntExt countExt;
@@ -236,36 +236,22 @@ class ModuleDNSBL : public Module
ServerInstance->Modules->AddService(countExt);
}
- ~ModuleDNSBL()
- {
- ClearEntries();
- }
-
Version GetVersion() CXX11_OVERRIDE
{
return Version("Provides handling of DNS blacklists", VF_VENDOR);
}
- /** Clear entries and free the mem it was using
- */
- void ClearEntries()
- {
- for (std::vector<DNSBLConfEntry *>::iterator i = DNSBLConfEntries.begin(); i != DNSBLConfEntries.end(); i++)
- delete *i;
- DNSBLConfEntries.clear();
- }
-
/** Fill our conf vector with data
*/
void ReadConf()
{
- ClearEntries();
+ DNSBLConfEntries.clear();
ConfigTagList dnsbls = ServerInstance->Config->ConfTags("dnsbl");
for(ConfigIter i = dnsbls.first; i != dnsbls.second; ++i)
{
ConfigTag* tag = i->second;
- DNSBLConfEntry *e = new DNSBLConfEntry();
+ reference<DNSBLConfEntry> e = new DNSBLConfEntry();
e->name = tag->getString("name");
e->ident = tag->getString("ident");
@@ -325,11 +311,7 @@ class ModuleDNSBL : public Module
/* add it, all is ok */
DNSBLConfEntries.push_back(e);
- continue;
}
-
- /* delete and drop it, error somewhere */
- delete e;
}
}
@@ -410,7 +392,7 @@ class ModuleDNSBL : public Module
unsigned long total_hits = 0, total_misses = 0;
- for (std::vector<DNSBLConfEntry*>::iterator i = DNSBLConfEntries.begin(); i != DNSBLConfEntries.end(); i++)
+ for (std::vector<reference<DNSBLConfEntry> >::const_iterator i = DNSBLConfEntries.begin(); i != DNSBLConfEntries.end(); ++i)
{
total_hits += (*i)->stats_hits;
total_misses += (*i)->stats_misses;
diff --git a/src/modules/m_ircv3.cpp b/src/modules/m_ircv3.cpp
index 59a69f669..f46ae97b4 100644
--- a/src/modules/m_ircv3.cpp
+++ b/src/modules/m_ircv3.cpp
@@ -84,7 +84,7 @@ class ModuleIRCv3 : public Module
void OnRehash(User* user) CXX11_OVERRIDE
{
ConfigTag* conf = ServerInstance->Config->ConfValue("ircv3");
- accountnotify = conf->getBool("accoutnotify", true);
+ accountnotify = conf->getBool("accountnotify", true);
awaynotify = conf->getBool("awaynotify", true);
extendedjoin = conf->getBool("extendedjoin", true);
}
diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp
index 2a3dff6ee..a19a184e0 100644
--- a/src/modules/m_permchannels.cpp
+++ b/src/modules/m_permchannels.cpp
@@ -19,9 +19,16 @@
#include "inspircd.h"
+#include "listmode.h"
#include <fstream>
+struct ListModeData
+{
+ std::string modes;
+ std::string params;
+};
+
/** Handles the +P channel mode
*/
class PermChannel : public ModeHandler
@@ -48,8 +55,9 @@ class PermChannel : public ModeHandler
// Not in a class due to circular dependancy hell.
static std::string permchannelsconf;
-static bool WriteDatabase(PermChannel& permchanmode)
+static bool WriteDatabase(PermChannel& permchanmode, Module* mod, bool save_listmodes)
{
+ ChanModeReference ban(mod, "ban");
/*
* We need to perform an atomic write so as not to fuck things up.
* So, let's write to a temporary file, flush it, then rename the file..
@@ -78,9 +86,45 @@ static bool WriteDatabase(PermChannel& permchanmode)
if (!chan->IsModeSet(permchanmode))
continue;
+ std::string chanmodes = chan->ChanModes(true);
+ if (save_listmodes)
+ {
+ ListModeData lm;
+
+ // Bans are managed by the core, so we have to process them separately
+ static_cast<ListModeBase*>(*ban)->DoSyncChannel(chan, mod, &lm);
+
+ // All other listmodes are managed by modules, so we need to ask them (call their
+ // OnSyncChannel() handler) to give our ProtoSendMode() a list of modes that are
+ // set on the channel. The ListModeData struct is passed as an opaque pointer
+ // that will be passed back to us by the module handling the mode.
+ FOREACH_MOD(OnSyncChannel, (chan, mod, &lm));
+
+ if (!lm.modes.empty())
+ {
+ // Remove the last space
+ lm.params.erase(lm.params.end()-1);
+
+ // If there is at least a space in chanmodes (that is, a non-listmode has a parameter)
+ // insert the listmode mode letters before the space. Otherwise just append them.
+ std::string::size_type p = chanmodes.find(' ');
+ if (p == std::string::npos)
+ chanmodes += lm.modes;
+ else
+ chanmodes.insert(p, lm.modes);
+
+ // Append the listmode parameters (the masks themselves)
+ chanmodes += ' ';
+ chanmodes += lm.params;
+ }
+ }
+
stream << "<permchannels channel=\"" << ServerConfig::Escape(chan->name)
+ << "\" ts=\"" << chan->age
<< "\" topic=\"" << ServerConfig::Escape(chan->topic)
- << "\" modes=\"" << ServerConfig::Escape(chan->ChanModes(true))
+ << "\" topicts=\"" << chan->topicset
+ << "\" topicsetby=\"" << ServerConfig::Escape(chan->setby)
+ << "\" modes=\"" << ServerConfig::Escape(chanmodes)
<< "\">" << std::endl;
}
@@ -115,6 +159,7 @@ class ModulePermanentChannels : public Module
{
PermChannel p;
bool dirty;
+ bool save_listmodes;
public:
ModulePermanentChannels() : p(this), dirty(false)
@@ -156,7 +201,9 @@ public:
void OnRehash(User *user) CXX11_OVERRIDE
{
- permchannelsconf = ServerInstance->Config->ConfValue("permchanneldb")->getString("filename");
+ ConfigTag* tag = ServerInstance->Config->ConfValue("permchanneldb");
+ permchannelsconf = tag->getString("filename");
+ save_listmodes = tag->getBool("listmodes");
}
void LoadDatabase()
@@ -170,12 +217,11 @@ public:
{
ConfigTag* tag = i->second;
std::string channel = tag->getString("channel");
- std::string topic = tag->getString("topic");
std::string modes = tag->getString("modes");
- if (channel.empty())
+ if ((channel.empty()) || (channel.length() > ServerInstance->Config->Limits.ChanMax))
{
- ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Malformed permchannels tag with empty channel name.");
+ ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Ignoring permchannels tag with empty or too long channel name (\"" + channel + "\")");
continue;
}
@@ -183,20 +229,23 @@ public:
if (!c)
{
- c = new Channel(channel, ServerInstance->Time());
- if (!topic.empty())
+ time_t TS = tag->getInt("ts", ServerInstance->Time(), 1);
+ c = new Channel(channel, TS);
+
+ unsigned int topicset = tag->getInt("topicts");
+ c->topic = tag->getString("topic");
+
+ if ((topicset != 0) || (!c->topic.empty()))
{
- c->SetTopic(ServerInstance->FakeClient, topic);
-
- /*
- * Due to the way protocol works in 1.2, we need to hack the topic TS in such a way that this
- * topic will always win over others.
- *
- * This is scheduled for (proper) fixing in a later release, and can be removed at a later date.
- */
- c->topicset = 42;
+ if (topicset == 0)
+ topicset = ServerInstance->Time();
+ c->topicset = topicset;
+ c->setby = tag->getString("topicsetby");
+ if (c->setby.empty())
+ c->setby = ServerInstance->Config->ServerName;
}
- ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Added %s with topic %s", channel.c_str(), topic.c_str());
+
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Added %s with topic %s", channel.c_str(), c->topic.c_str());
if (modes.empty())
continue;
@@ -242,7 +291,7 @@ public:
void OnBackgroundTimer(time_t) CXX11_OVERRIDE
{
if (dirty)
- WriteDatabase(p);
+ WriteDatabase(p, this, save_listmodes);
dirty = false;
}
@@ -278,6 +327,25 @@ public:
}
}
+ void ProtoSendMode(void* opaque, TargetTypeFlags type, void* target, const std::vector<std::string>& modes, const std::vector<TranslateType>& translate)
+ {
+ // We never pass an empty modelist but better be sure
+ if (modes.empty())
+ return;
+
+ ListModeData* lm = static_cast<ListModeData*>(opaque);
+
+ // Append the mode letters without the trailing '+' (for example "IIII", "gg")
+ lm->modes.append(modes[0].begin()+1, modes[0].end());
+
+ // Append the parameters
+ for (std::vector<std::string>::const_iterator i = modes.begin()+1; i != modes.end(); ++i)
+ {
+ lm->params += *i;
+ lm->params += ' ';
+ }
+ }
+
Version GetVersion() CXX11_OVERRIDE
{
return Version("Provides support for channel mode +P to provide permanent channels",VF_VENDOR);
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp
index 93320757c..0fb446877 100644
--- a/src/modules/m_spanningtree/fjoin.cpp
+++ b/src/modules/m_spanningtree/fjoin.cpp
@@ -124,12 +124,36 @@ CmdResult CommandFJoin::Handle(User* srcuser, std::vector<std::string>& params)
/* First up, apply their channel modes if they won the TS war */
if (apply_other_sides_modes)
{
+ // Need to use a modestacker here due to maxmodes
+ irc::modestacker stack(true);
+ std::vector<std::string>::const_iterator paramit = params.begin() + 3;
+ const std::vector<std::string>::const_iterator lastparamit = ((params.size() > 3) ? (params.end() - 1) : params.end());
+ for (std::string::const_iterator i = params[2].begin(); i != params[2].end(); ++i)
+ {
+ ModeHandler* mh = ServerInstance->Modes->FindMode(*i, MODETYPE_CHANNEL);
+ if (!mh)
+ continue;
+
+ std::string modeparam;
+ if ((paramit != lastparamit) && (mh->GetNumParams(true)))
+ {
+ modeparam = *paramit;
+ ++paramit;
+ }
+
+ stack.Push(*i, modeparam);
+ }
+
std::vector<std::string> modelist;
- modelist.push_back(channel);
- /* Remember, params[params.size() - 1] is userlist, and we don't want to apply *that* */
- modelist.insert(modelist.end(), params.begin()+2, params.end()-1);
- ServerInstance->Modes->Process(modelist, srcuser, ModeParser::MODE_LOCALONLY | ModeParser::MODE_MERGE);
+ // Mode parser needs to know what channel to act on.
+ modelist.push_back(params[0]);
+
+ while (stack.GetStackedLine(modelist))
+ {
+ ServerInstance->Modes->Process(modelist, srcuser, ModeParser::MODE_LOCALONLY | ModeParser::MODE_MERGE);
+ modelist.erase(modelist.begin() + 1, modelist.end());
+ }
}
irc::modestacker modestack(true);
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 98f9a304b..9ece3c03d 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -669,6 +669,13 @@ void ModuleSpanningTree::OnUnloadModule(Module* mod)
sock->Close();
}
}
+
+ for (SpanningTreeUtilities::TimeoutList::const_iterator i = Utils->timeoutlist.begin(); i != Utils->timeoutlist.end(); ++i)
+ {
+ TreeSocket* sock = i->first;
+ if (sock->GetIOHook() && sock->GetIOHook()->creator == mod)
+ sock->Close();
+ }
}
// note: the protocol does not allow direct umode +o except
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index 9e6f41852..164bed1ca 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -50,6 +50,7 @@ class SpanningTreeUtilities : public classbase
public:
typedef std::set<TreeSocket*> TreeSocketSet;
+ typedef std::map<TreeSocket*, std::pair<std::string, int> > TimeoutList;
/** Creator module
*/
@@ -91,7 +92,7 @@ class SpanningTreeUtilities : public classbase
server_hash sidlist;
/** List of all outgoing sockets and their timeouts
*/
- std::map<TreeSocket*, std::pair<std::string, int> > timeoutlist;
+ TimeoutList timeoutlist;
/** Holds the data from the <link> tags in the conf
*/
std::vector<reference<Link> > LinkBlocks;
diff --git a/src/modules/m_userip.cpp b/src/modules/m_userip.cpp
index 97e4c9284..79e69ec5e 100644
--- a/src/modules/m_userip.cpp
+++ b/src/modules/m_userip.cpp
@@ -36,7 +36,7 @@ class CommandUserip : public Command
std::string retbuf = "340 " + user->nick + " :";
int nicks = 0;
bool checked_privs = false;
- bool has_privs;
+ bool has_privs = false;
for (int i = 0; i < (int)parameters.size(); i++)
{