summaryrefslogtreecommitdiff
path: root/modules/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'modules/protocol')
-rw-r--r--modules/protocol/bahamut.cpp249
-rw-r--r--modules/protocol/charybdis.cpp16
-rw-r--r--modules/protocol/hybrid.cpp70
-rw-r--r--modules/protocol/inspircd20.cpp1094
-rw-r--r--modules/protocol/ngircd.cpp655
-rw-r--r--modules/protocol/plexus.cpp6
-rw-r--r--modules/protocol/ratbox.cpp25
-rw-r--r--modules/protocol/rfc1459.cpp7
-rw-r--r--modules/protocol/unreal.cpp787
9 files changed, 1365 insertions, 1544 deletions
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 988cfaead..8e753b443 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -21,6 +21,7 @@
#include "module.h"
#include "modules/protocol/rfc1459.h"
+#include "modules/protocol/bahamut.h"
class ChannelModeFlood : public ChannelModeParam
{
@@ -317,56 +318,39 @@ class BahamutIRCdProto : public IRCDProto
}
};
-struct IRCDMessageBurst : IRCDMessage
+void bahamut::Burst::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageBurst(Module *creator) : IRCDMessage(creator, "BURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+ Server *s = source.GetServer();
+ s->Sync(true);
+}
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
- {
- /* If we found a server with the given source, that one just
- * finished bursting. If there was no source, then our uplink
- * server finished bursting. -GD
- */
- Server *s = source.GetServer();
- if (!s)
- s = Me->GetLinks().front();
- if (s)
- s->Sync(true);
- }
-};
-
-struct IRCDMessageMode : IRCDMessage
+void bahamut::Mode::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageMode(Module *creator, const Anope::string &sname) : IRCDMessage(creator, sname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
+ if (params.size() > 2 && IRCD->IsChannelValid(params[0]))
{
- if (params.size() > 2 && IRCD->IsChannelValid(params[0]))
- {
- Channel *c = Channel::Find(params[0]);
- time_t ts = 0;
-
- try
- {
- ts = convertTo<time_t>(params[1]);
- }
- catch (const ConvertException &) { }
-
- Anope::string modes = params[2];
- for (unsigned int i = 3; i < params.size(); ++i)
- modes += " " + params[i];
+ Channel *c = Channel::Find(params[0]);
+ time_t ts = 0;
- if (c)
- c->SetModesInternal(source, modes, ts);
- }
- else
+ try
{
- User *u = User::Find(params[0]);
- if (u)
- u->SetModesInternal(source, "%s", params[1].c_str());
+ ts = convertTo<time_t>(params[1]);
}
+ catch (const ConvertException &) { }
+
+ Anope::string modes = params[2];
+ for (unsigned int i = 3; i < params.size(); ++i)
+ modes += " " + params[i];
+
+ if (c)
+ c->SetModesInternal(source, modes, ts);
}
-};
+ else
+ {
+ User *u = User::Find(params[0]);
+ if (u)
+ u->SetModesInternal(source, "%s", params[1].c_str());
+ }
+}
/*
** NICK - new
@@ -386,117 +370,128 @@ struct IRCDMessageMode : IRCDMessage
** parv[0] = new nickname
** parv[1] = hopcount
*/
-struct IRCDMessageNick : IRCDMessage
+void bahamut::Nick::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
+ if (params.size() == 10)
{
- if (params.size() == 10)
+ Server *s = Server::Find(params[6]);
+ if (s == nullptr)
{
- Server *s = Server::Find(params[6]);
- if (s == NULL)
- {
- Log(LOG_DEBUG) << "User " << params[0] << " introduced from non-existent server " << params[6] << "?";
- return;
- }
+ Log(LOG_DEBUG) << "User " << params[0] << " introduced from non-existent server " << params[6] << "?";
+ return;
+ }
- NickServ::Nick *na = NULL;
- time_t signon = params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0,
- stamp = params[7].is_pos_number_only() ? convertTo<time_t>(params[7]) : 0;
- if (signon && signon == stamp && NickServ::service)
- na = NickServ::service->FindNick(params[0]);
+ NickServ::Nick *na = nullptr;
+ time_t signon = 0, stamp = 0;
- User::OnIntroduce(params[0], params[4], params[5], "", params[8], s, params[9], signon, params[3], "", na ? na->GetAccount() : NULL);
+ try
+ {
+ signon = convertTo<time_t>(params[2]);
+ stamp = convertTo<time_t>(params[7]);
}
- else
+ catch (const ConvertException &)
{
- User *u = source.GetUser();
-
- if (u)
- u->ChangeNick(params[0]);
}
+
+ if (signon && signon == stamp && NickServ::service)
+ na = NickServ::service->FindNick(params[0]);
+
+ User::OnIntroduce(params[0], params[4], params[5], "", params[8], s, params[9], signon, params[3], "", na ? na->GetAccount() : nullptr);
}
-};
+ else
+ {
+ User *u = source.GetUser();
-struct IRCDMessageServer : IRCDMessage
+ if (u)
+ u->ChangeNick(params[0]);
+ }
+}
+
+void bahamut::ServerMessage::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ unsigned int hops = 0;
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
+ try
{
- unsigned int hops = Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0;
- new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[2]);
+ hops = convertTo<unsigned>(params[1]);
}
-};
+ catch (const ConvertException &) { }
+
+ new Server(source.GetServer(), params[0], hops, params[2]);
+}
-struct IRCDMessageSJoin : IRCDMessage
+void bahamut::SJoin::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageSJoin(Module *creator) : IRCDMessage(creator, "SJOIN", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+ Anope::string modes;
+ if (params.size() >= 4)
+ for (unsigned i = 2; i < params.size(); ++i)
+ modes += " " + params[i];
+ if (!modes.empty())
+ modes.erase(modes.begin());
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
- {
- Anope::string modes;
- if (params.size() >= 4)
- for (unsigned i = 2; i < params.size(); ++i)
- modes += " " + params[i];
- if (!modes.empty())
- modes.erase(modes.begin());
+ std::list<rfc1459::Join::SJoinUser> users;
- std::list<rfc1459::Join::SJoinUser> users;
+ /* For some reason, bahamut will send a SJOIN from the user joining a channel
+ * if the channel already existed
+ */
+ if (source.GetUser())
+ {
+ rfc1459::Join::SJoinUser sju;
+ sju.second = source.GetUser();
+ users.push_back(sju);
+ }
+ else
+ {
+ spacesepstream sep(params[params.size() - 1]);
+ Anope::string buf;
- /* For some reason, bahamut will send a SJOIN from the user joining a channel
- * if the channel already existed
- */
- if (source.GetUser())
+ while (sep.GetToken(buf))
{
rfc1459::Join::SJoinUser sju;
- sju.second = source.GetUser();
- users.push_back(sju);
- }
- else
- {
- spacesepstream sep(params[params.size() - 1]);
- Anope::string buf;
- while (sep.GetToken(buf))
+ /* Get prefixes from the nick */
+ for (char ch; !buf.empty() && (ch = ModeManager::GetStatusChar(buf[0]));)
+ {
+ buf.erase(buf.begin());
+ sju.first.AddMode(ch);
+ }
+
+ sju.second = User::Find(buf);
+ if (!sju.second)
{
- rfc1459::Join::SJoinUser sju;
-
- /* Get prefixes from the nick */
- for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));)
- {
- buf.erase(buf.begin());
- sju.first.AddMode(ch);
- }
-
- sju.second = User::Find(buf);
- if (!sju.second)
- {
- Log(LOG_DEBUG) << "SJOIN for non-existent user " << buf << " on " << params[1];
- continue;
- }
-
- users.push_back(sju);
+ Log(LOG_DEBUG) << "SJOIN for non-existent user " << buf << " on " << params[1];
+ continue;
}
+
+ users.push_back(sju);
}
+ }
+
+ time_t ts = Anope::CurTime;
- time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : Anope::CurTime;
- rfc1459::Join::SJoin(source, params[1], ts, modes, users);
+ try
+ {
+ ts = convertTo<time_t>(params[0]);
}
-};
+ catch (const ConvertException &) { }
-struct IRCDMessageTopic : IRCDMessage
+ rfc1459::Join::SJoin(source, params[1], ts, modes, users);
+}
+
+void bahamut::Topic::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageTopic(Module *creator) : IRCDMessage(creator, "TOPIC", 4) { }
+ Channel *c = Channel::Find(params[0]);
+ time_t ts = Anope::CurTime;
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
+ try
{
- Channel *c = Channel::Find(params[0]);
- if (c)
- c->ChangeTopicInternal(source.GetUser(), params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime);
+ ts = convertTo<time_t>(params[2]);
}
-};
+ catch (const ConvertException &) { }
+
+ if (c)
+ c->ChangeTopicInternal(source.GetUser(), params[1], params[3], ts);
+}
class ProtoBahamut : public Module
, public EventHook<Event::UserNickChange>
@@ -524,12 +519,12 @@ class ProtoBahamut : public Module
rfc1459::Whois message_whois;
/* Our message handlers */
- IRCDMessageBurst message_burst;
- IRCDMessageMode message_mode, message_svsmode;
- IRCDMessageNick message_nick;
- IRCDMessageServer message_server;
- IRCDMessageSJoin message_sjoin;
- IRCDMessageTopic message_topic;
+ bahamut::Burst message_burst;
+ bahamut::Mode message_mode, message_svsmode;
+ bahamut::Nick message_nick;
+ bahamut::ServerMessage message_server;
+ bahamut::SJoin message_sjoin;
+ bahamut::Topic message_topic;
public:
ProtoBahamut(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR)
diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp
index b13dc99fc..5cc9f4c62 100644
--- a/modules/protocol/charybdis.cpp
+++ b/modules/protocol/charybdis.cpp
@@ -233,17 +233,25 @@ void charybdis::EUID::Run(MessageSource &source, const std::vector<Anope::string
if (params[9] != "*")
na = NickServ::FindNick(params[9]);
- User::OnIntroduce(params[0], params[4], (params[8] != "*" ? params[8] : params[5]), params[5], params[6], source.GetServer(), params[10], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime, params[3], params[7], na ? na->GetAccount() : NULL);
+ time_t ts = Anope::CurTime;
+
+ try
+ {
+ ts = convertTo<time_t>(params[2]);
+ }
+ catch (const ConvertException &) { }
+
+ User::OnIntroduce(params[0], params[4], (params[8] != "*" ? params[8] : params[5]), params[5], params[6], source.GetServer(), params[10], ts, params[3], params[7], na ? na->GetAccount() : NULL);
}
// we can't use this function from ratbox because we set a local variable here
// SERVER dev.anope.de 1 :charybdis test server
-void charybdis::Server::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void charybdis::ServerMessage::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
// Servers other then our immediate uplink are introduced via SID
if (params[1] != "1")
return;
- new ::Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID);
+ new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID);
IRCD->SendPing(Me->GetName(), params[0]);
}
@@ -291,7 +299,7 @@ class ProtoCharybdis : public Module
hybrid::Nick message_nick;
charybdis::Pass message_pass;
hybrid::Pong message_pong;
- charybdis::Server message_server;
+ charybdis::ServerMessage message_server;
hybrid::SID message_sid;
hybrid::SJoin message_sjoin;
ratbox::TB message_tb;
diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp
index 638a4037a..c28c9ebf5 100644
--- a/modules/protocol/hybrid.cpp
+++ b/modules/protocol/hybrid.cpp
@@ -375,7 +375,15 @@ void hybrid::Join::Run(MessageSource &source, const std::vector<Anope::string> &
/* :0MCAAAAAB NICK newnick 1350157102 */
void hybrid::Nick::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- source.GetUser()->ChangeNick(params[0], convertTo<time_t>(params[1]));
+ time_t ts = Anope::CurTime;
+
+ try
+ {
+ ts = convertTo<time_t>(params[1]);
+ }
+ catch (const ConvertException &) { }
+
+ source.GetUser()->ChangeNick(params[0], ts);
}
struct IRCDMessagePass : IRCDMessage
@@ -397,21 +405,28 @@ void hybrid::Pong::Run(MessageSource &source, const std::vector<Anope::string> &
/* 0 1 2 */
/* SERVER hades.arpa 1 :ircd-hybrid test server */
-void hybrid::Server::Run(MessageSource &source, const std::vector<Anope::string> &params)
+void hybrid::ServerMessage::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
/* Servers other than our immediate uplink are introduced via SID */
if (params[1] != "1")
return;
- new ::Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID);
+ new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID);
IRCD->SendPing(Me->GetName(), params[0]);
}
void hybrid::SID::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- unsigned int hops = params[1].is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0;
- new ::Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[3], params[2]);
+ unsigned int hops = 0;
+
+ try
+ {
+ hops = convertTo<unsigned int>(params[1]);
+ }
+ catch (const ConvertException &) { }
+
+ new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[3], params[2]);
IRCD->SendPing(Me->GetName(), params[0]);
}
@@ -435,7 +450,7 @@ void hybrid::SJoin::Run(MessageSource &source, const std::vector<Anope::string>
rfc1459::Join::SJoinUser sju;
/* Get prefixes from the nick */
- for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));)
+ for (char ch; !buf.empty() && (ch = ModeManager::GetStatusChar(buf[0]));)
{
buf.erase(buf.begin());
sju.first.AddMode(ch);
@@ -451,7 +466,14 @@ void hybrid::SJoin::Run(MessageSource &source, const std::vector<Anope::string>
users.push_back(sju);
}
- time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : Anope::CurTime;
+ time_t ts = Anope::CurTime;
+
+ try
+ {
+ ts = convertTo<time_t>(params[0]);
+ }
+ catch (const ConvertException &) { }
+
rfc1459::Join::SJoin(source, params[1], ts, modes, users);
}
@@ -467,7 +489,18 @@ void hybrid::SVSMode::Run(MessageSource &source, const std::vector<Anope::string
if (!u)
return;
- if (!params[1].is_pos_number_only() || convertTo<time_t>(params[1]) != u->timestamp)
+ time_t ts;
+
+ try
+ {
+ ts = convertTo<time_t>(params[1]);
+ }
+ catch (const ConvertException &)
+ {
+ return;
+ }
+
+ if (ts != u->timestamp)
return;
u->SetModesInternal(source, "%s", params[2].c_str());
@@ -477,9 +510,16 @@ void hybrid::TBurst::Run(MessageSource &source, const std::vector<Anope::string>
{
Anope::string setter;
sepstream(params[3], '!').GetToken(setter, 0);
- time_t topic_time = Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime;
Channel *c = Channel::Find(params[1]);
+ time_t topic_time = Anope::CurTime;
+
+ try
+ {
+ topic_time = convertTo<time_t>(params[2]);
+ }
+ catch (const ConvertException &ex) { }
+
if (c)
c->ChangeTopicInternal(NULL, setter, params[4], topic_time);
}
@@ -517,10 +557,18 @@ void hybrid::UID::Run(MessageSource &source, const std::vector<Anope::string> &p
if (params[8] != "0" && params[8] != "*")
na = NickServ::FindNick(params[8]);
+ time_t ts = 0;
+
+ try
+ {
+ ts = convertTo<time_t>(params[2]);
+ }
+ catch (const ConvertException &) { }
+
/* Source is always the server */
User::OnIntroduce(params[0], params[4], params[5], "",
ip, source.GetServer(),
- params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0,
+ params[9], ts,
params[3], params[7], na ? na->GetAccount() : NULL);
}
@@ -568,7 +616,7 @@ class ProtoHybrid : public Module
hybrid::Nick message_nick;
IRCDMessagePass message_pass;
hybrid::Pong message_pong;
- hybrid::Server message_server;
+ hybrid::ServerMessage message_server;
hybrid::SID message_sid;
hybrid::SJoin message_sjoin;
hybrid::SVSMode message_svsmode;
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index c2c09c95d..0f5469cea 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -24,6 +24,7 @@
#include "modules/chanserv/mode.h"
#include "modules/chanserv/set.h"
#include "modules/protocol/rfc1459.h"
+#include "modules/protocol/inspircd20.h"
struct SASLUser
{
@@ -631,380 +632,328 @@ namespace InspIRCdExtban
};
}
-struct IRCDMessageCapab : rfc1459::Capab
+void inspircd20::Capab::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageCapab(Module *creator) : rfc1459::Capab(creator, "CAPAB") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
+ if (params[0].equals_cs("START"))
{
- if (params[0].equals_cs("START"))
+ if (params.size() >= 2)
+ spanningtree_proto_ver = (Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0);
+
+ if (spanningtree_proto_ver < 1202)
{
- if (params.size() >= 2)
- spanningtree_proto_ver = (Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0);
+ Uplink::Send("ERROR", "Protocol mismatch, no or invalid protocol version given in CAPAB START");
+ Anope::QuitReason = "Protocol mismatch, no or invalid protocol version given in CAPAB START";
+ Anope::Quitting = true;
+ return;
+ }
- if (spanningtree_proto_ver < 1202)
- {
- Uplink::Send("ERROR", "Protocol mismatch, no or invalid protocol version given in CAPAB START");
- Anope::QuitReason = "Protocol mismatch, no or invalid protocol version given in CAPAB START";
- Anope::Quitting = true;
- return;
- }
+ /* reset CAPAB */
+ Servers::Capab.insert("SERVERS");
+ Servers::Capab.insert("CHGHOST");
+ Servers::Capab.insert("CHGIDENT");
+ Servers::Capab.insert("TOPICLOCK");
+ IRCD->CanSVSHold = false;
+ }
+ else if (params[0].equals_cs("CHANMODES") && params.size() > 1)
+ {
+ spacesepstream ssep(params[1]);
+ Anope::string capab;
- /* reset CAPAB */
- Servers::Capab.insert("SERVERS");
- Servers::Capab.insert("CHGHOST");
- Servers::Capab.insert("CHGIDENT");
- Servers::Capab.insert("TOPICLOCK");
- IRCD->CanSVSHold = false;
- }
- else if (params[0].equals_cs("CHANMODES") && params.size() > 1)
+ while (ssep.GetToken(capab))
{
- spacesepstream ssep(params[1]);
- Anope::string capab;
+ if (capab.find('=') == Anope::string::npos)
+ continue;
+
+ Anope::string modename = capab.substr(0, capab.find('='));
+ Anope::string modechar = capab.substr(capab.find('=') + 1);
+ char symbol = 0;
+
+ if (modechar.empty())
+ continue;
- while (ssep.GetToken(capab))
+ if (modechar.length() == 2)
{
- if (capab.find('=') == Anope::string::npos)
- continue;
-
- Anope::string modename = capab.substr(0, capab.find('='));
- Anope::string modechar = capab.substr(capab.find('=') + 1);
- char symbol = 0;
-
- if (modechar.empty())
- continue;
-
- if (modechar.length() == 2)
- {
- symbol = modechar[0];
- modechar = modechar.substr(1);
- }
-
- ChannelMode *cm = ModeManager::FindChannelModeByChar(modechar[0]);
- if (cm == nullptr)
- {
- Log(this->GetOwner()) << "Warning: Uplink has unknown channel mode " << modename << "=" << modechar;
- continue;
- }
-
- char modesymbol = cm->type == MODE_STATUS ? (anope_dynamic_static_cast<ChannelModeStatus *>(cm))->symbol : 0;
- if (symbol != modesymbol)
- {
- Log(this->GetOwner()) << "Warning: Channel mode " << modename << " has a misconfigured status character";
- continue;
- }
+ symbol = modechar[0];
+ modechar = modechar.substr(1);
}
- }
- if (params[0].equals_cs("USERMODES") && params.size() > 1)
- {
- spacesepstream ssep(params[1]);
- Anope::string capab;
- while (ssep.GetToken(capab))
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(modechar[0]);
+ if (cm == nullptr)
{
- if (capab.find('=') == Anope::string::npos)
- continue;
-
- Anope::string modename = capab.substr(0, capab.find('='));
- Anope::string modechar = capab.substr(capab.find('=') + 1);
-
- if (modechar.empty())
- continue;
-
- UserMode *um = ModeManager::FindUserModeByChar(modechar[0]);
- if (um == nullptr)
- {
- Log(this->GetOwner()) << "Warning: Uplink has unknown user mode " << modename << "=" << modechar;
- continue;
- }
+ Log(this->GetOwner()) << "Warning: Uplink has unknown channel mode " << modename << "=" << modechar;
+ continue;
}
- }
- else if (params[0].equals_cs("MODULES") && params.size() > 1)
- {
- spacesepstream ssep(params[1]);
- Anope::string module;
- while (ssep.GetToken(module))
+ char modesymbol = cm->type == MODE_STATUS ? (anope_dynamic_static_cast<ChannelModeStatus *>(cm))->symbol : 0;
+ if (symbol != modesymbol)
{
- if (module.equals_cs("m_svshold.so"))
- IRCD->CanSVSHold = true;
- else if (module.find("m_rline.so") == 0)
- {
- Servers::Capab.insert("RLINE");
- const Anope::string &regexengine = Config->GetBlock("options")->Get<Anope::string>("regexengine");
- if (!regexengine.empty() && module.length() > 11 && regexengine != module.substr(11))
- Log() << "Warning: InspIRCd is using regex engine " << module.substr(11) << ", but we have " << regexengine << ". This may cause inconsistencies.";
- }
- else if (module.equals_cs("m_topiclock.so"))
- Servers::Capab.insert("TOPICLOCK");
+ Log(this->GetOwner()) << "Warning: Channel mode " << modename << " has a misconfigured status character";
+ continue;
}
}
- else if (params[0].equals_cs("MODSUPPORT") && params.size() > 1)
+ }
+ if (params[0].equals_cs("USERMODES") && params.size() > 1)
+ {
+ spacesepstream ssep(params[1]);
+ Anope::string capab;
+
+ while (ssep.GetToken(capab))
{
- spacesepstream ssep(params[1]);
- Anope::string module;
+ if (capab.find('=') == Anope::string::npos)
+ continue;
- while (ssep.GetToken(module))
+ Anope::string modename = capab.substr(0, capab.find('='));
+ Anope::string modechar = capab.substr(capab.find('=') + 1);
+
+ if (modechar.empty())
+ continue;
+
+ UserMode *um = ModeManager::FindUserModeByChar(modechar[0]);
+ if (um == nullptr)
{
- if (module.equals_cs("m_services_account.so"))
- Servers::Capab.insert("SERVICES");
- else if (module.equals_cs("m_chghost.so"))
- Servers::Capab.insert("CHGHOST");
- else if (module.equals_cs("m_chgident.so"))
- Servers::Capab.insert("CHGIDENT");
+ Log(this->GetOwner()) << "Warning: Uplink has unknown user mode " << modename << "=" << modechar;
+ continue;
}
}
- else if (params[0].equals_cs("CAPABILITIES") && params.size() > 1)
+ }
+ else if (params[0].equals_cs("MODULES") && params.size() > 1)
+ {
+ spacesepstream ssep(params[1]);
+ Anope::string module;
+
+ while (ssep.GetToken(module))
{
- spacesepstream ssep(params[1]);
- Anope::string capab;
- while (ssep.GetToken(capab))
+ if (module.equals_cs("m_svshold.so"))
+ IRCD->CanSVSHold = true;
+ else if (module.find("m_rline.so") == 0)
{
- if (capab.find("MAXMODES=") != Anope::string::npos)
- {
- Anope::string maxmodes(capab.begin() + 9, capab.end());
- IRCD->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3;
- }
- else if (capab == "GLOBOPS=1")
- Servers::Capab.insert("GLOBOPS");
+ Servers::Capab.insert("RLINE");
+ const Anope::string &regexengine = Config->GetBlock("options")->Get<Anope::string>("regexengine");
+ if (!regexengine.empty() && module.length() > 11 && regexengine != module.substr(11))
+ Log() << "Warning: InspIRCd is using regex engine " << module.substr(11) << ", but we have " << regexengine << ". This may cause inconsistencies.";
}
+ else if (module.equals_cs("m_topiclock.so"))
+ Servers::Capab.insert("TOPICLOCK");
}
- else if (params[0].equals_cs("END"))
+ }
+ else if (params[0].equals_cs("MODSUPPORT") && params.size() > 1)
+ {
+ spacesepstream ssep(params[1]);
+ Anope::string module;
+
+ while (ssep.GetToken(module))
{
- if (!Servers::Capab.count("SERVICES"))
+ if (module.equals_cs("m_services_account.so"))
+ Servers::Capab.insert("SERVICES");
+ else if (module.equals_cs("m_chghost.so"))
+ Servers::Capab.insert("CHGHOST");
+ else if (module.equals_cs("m_chgident.so"))
+ Servers::Capab.insert("CHGIDENT");
+ }
+ }
+ else if (params[0].equals_cs("CAPABILITIES") && params.size() > 1)
+ {
+ spacesepstream ssep(params[1]);
+ Anope::string capab;
+ while (ssep.GetToken(capab))
+ {
+ if (capab.find("MAXMODES=") != Anope::string::npos)
{
- Uplink::Send("ERROR", "m_services_account.so is not loaded. This is required by Anope");
- Anope::QuitReason = "ERROR: Remote server does not have the m_services_account module loaded, and this is required.";
- Anope::Quitting = true;
- return;
+ Anope::string maxmodes(capab.begin() + 9, capab.end());
+ IRCD->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3;
}
- if (!ModeManager::FindUserModeByName("PRIV"))
- {
- Uplink::Send("ERROR", "m_hidechans.so is not loaded. This is required by Anope");
- Anope::QuitReason = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required.";
- Anope::Quitting = true;
- return;
- }
- if (!IRCD->CanSVSHold)
- Log() << "SVSHOLD missing, Usage disabled until module is loaded.";
- if (!Servers::Capab.count("CHGHOST"))
- Log() << "CHGHOST missing, Usage disabled until module is loaded.";
- if (!Servers::Capab.count("CHGIDENT"))
- Log() << "CHGIDENT missing, Usage disabled until module is loaded.";
+ else if (capab == "GLOBOPS=1")
+ Servers::Capab.insert("GLOBOPS");
}
-
- rfc1459::Capab::Run(source, params);
}
-};
-
-struct IRCDMessageChgHost : IRCDMessage
-{
- IRCDMessageChgHost(Module *creator) : IRCDMessage(creator, "CHGHOST", 2) { }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
+ else if (params[0].equals_cs("END"))
{
- User *u = User::Find(params[0]);
- if (!u || u->server != Me)
+ if (!Servers::Capab.count("SERVICES"))
+ {
+ Uplink::Send("ERROR", "m_services_account.so is not loaded. This is required by Anope");
+ Anope::QuitReason = "ERROR: Remote server does not have the m_services_account module loaded, and this is required.";
+ Anope::Quitting = true;
return;
-
- u->SetDisplayedHost(params[1]);
- Uplink::Send(u, "FHOST", params[1]);
+ }
+ if (!ModeManager::FindUserModeByName("PRIV"))
+ {
+ Uplink::Send("ERROR", "m_hidechans.so is not loaded. This is required by Anope");
+ Anope::QuitReason = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required.";
+ Anope::Quitting = true;
+ return;
+ }
+ if (!IRCD->CanSVSHold)
+ Log() << "SVSHOLD missing, Usage disabled until module is loaded.";
+ if (!Servers::Capab.count("CHGHOST"))
+ Log() << "CHGHOST missing, Usage disabled until module is loaded.";
+ if (!Servers::Capab.count("CHGIDENT"))
+ Log() << "CHGIDENT missing, Usage disabled until module is loaded.";
}
-};
-struct IRCDMessageChgIdent : IRCDMessage
-{
- IRCDMessageChgIdent(Module *creator) : IRCDMessage(creator, "CHGIDENT", 2) { }
+ rfc1459::Capab::Run(source, params);
+}
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
- {
- User *u = User::Find(params[0]);
- if (!u || u->server != Me)
- return;
+void inspircd20::ChgHost::Run(MessageSource &source, const std::vector<Anope::string> &params)
+{
+ User *u = User::Find(params[0]);
+ if (!u || u->server != Me)
+ return;
- u->SetIdent(params[1]);
- Uplink::Send(u, "FIDENT", params[1]);
- }
-};
+ u->SetDisplayedHost(params[1]);
+ Uplink::Send(u, "FHOST", params[1]);
+}
-struct IRCDMessageChgName : IRCDMessage
+void inspircd20::ChgIdent::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageChgName(Module *creator) : IRCDMessage(creator, "CHGNAME", 2) { }
+ User *u = User::Find(params[0]);
+ if (!u || u->server != Me)
+ return;
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
- {
- User *u = User::Find(params[0]);
- if (!u || u->server != Me)
- return;
-
- u->SetRealname(params[1]);
- Uplink::Send(u, "FNAME", params[1]);
- }
-};
+ u->SetIdent(params[1]);
+ Uplink::Send(u, "FIDENT", params[1]);
+}
-struct IRCDMessageEncap : IRCDMessage
+void inspircd20::ChgName::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 4) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+ User *u = User::Find(params[0]);
+ if (!u || u->server != Me)
+ return;
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
- {
- if (Anope::Match(Me->GetSID(), params[0]) == false)
- return;
+ u->SetRealname(params[1]);
+ Uplink::Send(u, "FNAME", params[1]);
+}
- const Anope::string &command = params[1];
- std::vector<Anope::string> encap_params(params.begin() + 2, params.end());
+void inspircd20::Encap::Run(MessageSource &source, const std::vector<Anope::string> &params)
+{
+ if (Anope::Match(Me->GetSID(), params[0]) == false)
+ return;
- Anope::ProcessCommand(source, command, encap_params);
- }
-};
+ const Anope::string &command = params[1];
+ std::vector<Anope::string> encap_params(params.begin() + 2, params.end());
-struct IRCDMessageEndburst : IRCDMessage
-{
- IRCDMessageEndburst(Module *creator) : IRCDMessage(creator, "ENDBURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ Anope::ProcessCommand(source, command, encap_params);
+}
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
- {
- Server *s = source.GetServer();
+void inspircd20::Endburst::Run(MessageSource &source, const std::vector<Anope::string> &params)
+{
+ Server *s = source.GetServer();
- Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName();
+ Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName();
- s->Sync(true);
- }
-};
+ s->Sync(true);
+}
-struct IRCDMessageFHost : IRCDMessage
+void inspircd20::FHost::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageFHost(Module *creator) : IRCDMessage(creator, "FHOST", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
-
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
- {
- User *u = source.GetUser();
- if (u->HasMode("CLOAK"))
- u->RemoveModeInternal(source, ModeManager::FindUserModeByName("CLOAK"));
- u->SetDisplayedHost(params[0]);
- }
-};
+ User *u = source.GetUser();
+ if (u->HasMode("CLOAK"))
+ u->RemoveModeInternal(source, ModeManager::FindUserModeByName("CLOAK"));
+ u->SetDisplayedHost(params[0]);
+}
-struct IRCDMessageFIdent : IRCDMessage
+void inspircd20::FIdent::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- IRCDMessageFIdent(Module *creator) : IRCDMessage(creator, "FIDENT", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
+ source.GetUser()->SetIdent(params[0]);
+}
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
+void inspircd20::FJoin::Run(MessageSource &source, const std::vector<Anope::string> &params)
+{
+ Anope::string modes;
+ if (params.size() >= 3)
{
- source.GetUser()->SetIdent(params[0]);
+ for (unsigned i = 2; i < params.size() - 1; ++i)
+ modes += " " + params[i];
+ if (!modes.empty())
+ modes.erase(modes.begin());
}
-};
-struct IRCDMessageFJoin : IRCDMessage
-{
- IRCDMessageFJoin(Module *creator) : IRCDMessage(creator, "FJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+ std::list<rfc1459::Join::SJoinUser> users;
- void Run(MessageSource &source, const std::vector<Anope::string> &params) override
+ spacesepstream sep(params[params.size() - 1]);
+ Anope::string buf;
+ while (sep.GetToken(buf))
{
- Anope::string modes;
- if (params.size() >= 3)
+ rfc1459::Join::SJoinUser sju;
+
+ /* Loop through prefixes and find modes for them */
+ for (char c; !buf.empty() && (c = buf[0]) != ',';)
{
- for (unsigned i = 2; i < params.size() - 1; ++i)
- modes += " " + params[i];
- if (!modes.empty())
- modes.erase(modes.begin());
+ buf.erase(buf.begin());
+ sju.first.AddMode(c);
}
+ /* E