From 37bd2c238eed91444a6812c6592c4e4ced3773a9 Mon Sep 17 00:00:00 2001 From: miwob Date: Thu, 19 Jun 2014 16:27:05 +0200 Subject: hybrid.cpp: add our own SendInvite() which sends the channel's timestamp along the INVITE command. INVITE with channel TS will be mandatory in some future release of ircd-hybrid --- modules/protocol/hybrid.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modules/protocol') diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 7c2c14098..52c442dc3 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -51,6 +51,11 @@ class HybridProto : public IRCDProto MaxModes = 4; } + void SendInvite(const MessageSource &source, const Channel *c, User *u) anope_override + { + UplinkSocket::Message(source) << "INVITE " << u->GetUID() << " " << c->name << " " << c->creation_time; + } + void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { UplinkSocket::Message(bi) << "NOTICE $$" << dest->GetName() << " :" << msg; -- cgit From 17ba13bc957ebdda962944dcf6031355448f366d Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 26 Jul 2014 13:28:08 -0400 Subject: Use ts version of services stamp when the account is unconfirmed on Unreal as 3.2.10.4 has changed thie behavior --- modules/protocol/unreal.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules/protocol') diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 4aa340f08..6f744f22f 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -345,7 +345,8 @@ class UnrealIRCdProto : public IRCDProto void SendLogin(User *u, NickAlias *na) anope_override { - if (Servers::Capab.count("ESVID") > 0) + /* 3.2.10.4+ treats users logged in with accounts as fully registered, even if -r, so we can not set this here. Just use the timestamp. */ + if (Servers::Capab.count("ESVID") > 0 && !na->nc->HasExt("UNCONFIRMED")) IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %s", na->nc->display.c_str()); else IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %d", u->signon); -- cgit From 18b3c572f46be91c64e50b1ac91f048790df7f2c Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 5 Oct 2014 16:22:39 -0400 Subject: ngircd doesn't allow sourceless messages --- modules/protocol/ngircd.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modules/protocol') diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 86ced45ed..6078b87b8 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -169,6 +169,11 @@ class ngIRCdProto : public IRCDProto { this->SendVhost(u, u->GetIdent(), ""); } + + Anope::string Format(const Anope::string &source, const Anope::string &message) anope_override + { + return IRCDProto::Format(source.empty() ? Me->GetSID() : source, message); + } }; struct IRCDMessage005 : IRCDMessage -- cgit From 0cd3bfa24fccea79a5055bcd12d6aa607ecc635e Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 14 Oct 2014 18:58:55 -0400 Subject: Fix module event prioritization which was broken with the newer auto-attach event stuff. Also remove logically dead code from os_defcon, and make os_defcon akill similar masks to os_session when enforcing session akills. Fixes #1618 which relies on os_session to be prioritized before os_defcon. --- modules/protocol/unreal.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules/protocol') diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 6f744f22f..40cb1fe70 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -1258,7 +1258,10 @@ class ProtoUnreal : public Module { this->AddModes(); + } + void Prioritize() anope_override + { ModuleManager::SetPriority(this, PRIORITY_FIRST); } -- cgit From 8a7793da0cc8331022775c381cd8e33be07fc2c9 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 8 Nov 2014 04:31:56 -0500 Subject: Fix bahamut mode handler --- modules/protocol/bahamut.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules/protocol') diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index a8252c8c5..a399ecece 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -328,8 +328,12 @@ struct IRCDMessageMode : IRCDMessage } 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, params[2], ts); + c->SetModesInternal(source, modes, ts); } else { -- cgit From 95684187b636c2a02822eb2e9ee26e3b9555d4c4 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Sun, 30 Nov 2014 21:46:50 +0100 Subject: Fix server token assignment of servers in the network 1. the directly linked server, our upstream, always has token "1", and 2. for remote servers in the network, the token and description filds were interchanged during registration, therefore up to now no server could be found by Server::Find() using its assigned server token. --- modules/protocol/ngircd.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'modules/protocol') diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 6078b87b8..1b28ea399 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -524,18 +524,17 @@ struct IRCDMessageServer : IRCDMessage IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } /* + * New directly linked server: + * * SERVER tolsun.oulu.fi 1 :Experimental server * New server tolsun.oulu.fi introducing itself * and attempting to register. * - * RFC 2813 says the server has to send a hopcount - * AND a servertoken. Not quite sure what ngIRCd is - * sending here. - * * params[0] = servername - * params[1] = hop count (or servertoken?) + * params[1] = hop count * params[2] = server description * + * New remote server in the network: * * :tolsun.oulu.fi SERVER csd.bu.edu 5 34 :BU Central Server * Server tolsun.oulu.fi is our uplink for csd.bu.edu @@ -554,13 +553,13 @@ struct IRCDMessageServer : IRCDMessage if (params.size() == 3) { // our uplink is introducing itself - new Server(Me, params[0], 1, params[2], ""); + new Server(Me, params[0], 1, params[2], "1"); } else { // our uplink is introducing a new server unsigned int hops = params[1].is_pos_number_only() ? convertTo(params[1]) : 0; - new Server(source.GetServer(), params[0], hops, params[2], params[3]); + new Server(source.GetServer(), params[0], hops, params[3], params[2]); } /* * ngIRCd does not send an EOB, so we send a PING immediately -- cgit From d4732faf4156297a83e27dafdf9e7c30dcf70355 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Sun, 30 Nov 2014 21:50:11 +0100 Subject: Correctly assign nicks to their respective host servers Use the "server token" parameter of NICK commands to find the host server and correctly assign the nick name to this server. This allows Anope to correctly free all nick names again when (remote) servers leave the network, which fixes arbitrary "KILL attacks" when such nick names reconnect later on. Initial debugging and patch by DukePyrolator, thanks a lot! --- modules/protocol/ngircd.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'modules/protocol') diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 1b28ea399..61613423e 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -448,7 +448,14 @@ struct IRCDMessageNick : IRCDMessage else if (params.size() == 7) { // a new user is connecting to the network - User::OnIntroduce(params[0], params[2], params[3], "", "", source.GetServer(), params[6], Anope::CurTime, params[5], "", NULL); + Server *s = Server::Find(params[4]); + if (s == NULL) + { + Log(LOG_DEBUG) << "User " << params[0] << " introduced from nonexistant server " << params[4] << "?"; + return; + } + User::OnIntroduce(params[0], params[2], params[3], "", "", s, params[6], Anope::CurTime, params[5], "", NULL); + Log(LOG_DEBUG) << "Registered nick \"" << params[0] << "\" on server " << s->GetName() << "."; } else { -- cgit From 516211c88ac96506fc8c36f73d56735304870c5c Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 7 Dec 2014 18:30:25 -0500 Subject: Add SAVE support to inspircd20 --- modules/protocol/inspircd20.cpp | 45 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'modules/protocol') diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index eb2941ced..98cfb40dc 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -792,6 +792,48 @@ struct IRCDMessageFIdent : IRCDMessage } }; +struct IRCDMessageSave : IRCDMessage +{ + time_t last_collide; + + IRCDMessageSave(Module *creator) : IRCDMessage(creator, "SAVE", 2), last_collide(0) { } + + void Run(MessageSource &source, const std::vector ¶ms) anope_override + { + User *targ = User::Find(params[0]); + time_t ts; + + try + { + ts = convertTo(params[1]); + } + catch (const ConvertException &) + { + return; + } + + if (!targ || targ->timestamp != ts) + return; + + BotInfo *bi; + if (targ->server == Me && (bi = dynamic_cast(targ))) + { + if (last_collide == Anope::CurTime) + { + Anope::QuitReason = "Nick collision fight on " + targ->nick; + Anope::Quitting = true; + return; + } + + IRCD->SendKill(Me, targ->nick, "Nick collision"); + IRCD->SendNickChange(targ, targ->nick); + last_collide = Anope::CurTime; + } + else + targ->ChangeNick(targ->GetUID()); + } +}; + class ProtoInspIRCd20 : public Module { Module *m_insp12; @@ -824,6 +866,7 @@ class ProtoInspIRCd20 : public Module IRCDMessageCapab message_capab; IRCDMessageEncap message_encap; IRCDMessageFIdent message_fident; + IRCDMessageSave message_save; bool use_server_side_topiclock, use_server_side_mlock; @@ -855,7 +898,7 @@ class ProtoInspIRCd20 : public Module message_time("IRCDMessage", "inspircd20/time", "inspircd12/time"), message_uid("IRCDMessage", "inspircd20/uid", "inspircd12/uid"), - message_capab(this), message_encap(this), message_fident(this) + message_capab(this), message_encap(this), message_fident(this), message_save(this) { if (ModuleManager::LoadModule("inspircd12", User::Find(creator)) != MOD_ERR_OK) -- cgit From e800afcfac4704eea13ef8dbac9d99c5220917f7 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 28 Dec 2014 18:08:39 -0500 Subject: Fix adding regmoderated mode twice in plexus --- modules/protocol/plexus.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'modules/protocol') diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index e65699f1c..a6625bae6 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -341,6 +341,7 @@ class ProtoPlexus : public Module ModeManager::AddUserMode(new UserMode("REGPRIV", 'R')); ModeManager::AddUserMode(new UserModeOperOnly("SNOMASK", 's')); ModeManager::AddUserMode(new UserModeNoone("SSL", 'S')); + ModeManager::AddUserMode(new UserModeNoone("PROTECTED", 'U')); ModeManager::AddUserMode(new UserMode("WALLOPS", 'w')); ModeManager::AddUserMode(new UserModeNoone("WEBIRC", 'W')); ModeManager::AddUserMode(new UserMode("CLOAK", 'x')); @@ -350,7 +351,6 @@ class ProtoPlexus : public Module ModeManager::AddChannelMode(new ChannelModeList("BAN", 'b')); ModeManager::AddChannelMode(new ChannelModeList("EXCEPT", 'e')); ModeManager::AddChannelMode(new ChannelModeList("INVITEOVERRIDE", 'I')); - ModeManager::AddUserMode(new UserModeNoone("PROTECTED", 'U')); /* v/h/o/a/q */ ModeManager::AddChannelMode(new ChannelModeStatus("VOICE", 'v', '+', 0)); @@ -376,7 +376,6 @@ class ProtoPlexus : public Module ModeManager::AddChannelMode(new ChannelMode("SECRET", 's')); ModeManager::AddChannelMode(new ChannelMode("TOPIC", 't')); ModeManager::AddChannelMode(new ChannelModeOperOnly("OPERONLY", 'O')); - ModeManager::AddChannelMode(new ChannelMode("REGMODERATED", 'M')); ModeManager::AddChannelMode(new ChannelMode("REGISTEREDONLY", 'R')); ModeManager::AddChannelMode(new ChannelMode("SSL", 'S')); ModeManager::AddChannelMode(new ChannelMode("PERM", 'z')); -- cgit