diff options
Diffstat (limited to 'modules')
28 files changed, 1905 insertions, 2053 deletions
diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index 0b45ee71c..de7fa1128 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -218,11 +218,8 @@ class CommandBSBot : public Command } /* The new nick is really different, so we remove the Q line for the old nick. */ - if (ircd->sqline) - { - XLine x(bi->nick); - ircdproto->SendSQLineDel(&x); - } + XLine x_del(bi->nick); + ircdproto->SendSQLineDel(&x_del); /* Add a Q line for the new nick */ XLine x(nick, "Reserved for services"); diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index 289988867..ce88efa44 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -376,9 +376,9 @@ class CSSeen : public Module UpdateUser(u, PART, u->nick, "", channel, msg); } - void OnUserKicked(Channel *c, User *target, const Anope::string &source, const Anope::string &msg) anope_override + void OnUserKicked(Channel *c, User *target, MessageSource &source, const Anope::string &msg) anope_override { - UpdateUser(target, KICK, target->nick, source, c->name, msg); + UpdateUser(target, KICK, target->nick, source.GetSource(), c->name, msg); } private: diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp index 91fcaf10e..d02dd7dfe 100644 --- a/modules/commands/hs_on.cpp +++ b/modules/commands/hs_on.cpp @@ -27,6 +27,8 @@ class CommandHSOn : public Command User *u = source.GetUser(); if (!u) return; + else if (!ircdproto->CanSetVHost) + return; // HostServ wouldn't even be loaded at this point const NickAlias *na = findnick(u->nick); if (na && u->Account() == na->nc && na->HasVhost()) @@ -37,13 +39,9 @@ class CommandHSOn : public Command source.Reply(_("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str()); Log(LOG_COMMAND, source, this) << "to enable their vhost of " << (!na->GetVhostIdent().empty() ? na->GetVhostIdent() + "@" : "") << na->GetVhostHost(); ircdproto->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost()); - if (ircd->vhost) - u->vhost = na->GetVhostHost(); - if (ircd->vident) - { - if (!na->GetVhostIdent().empty()) - u->SetVIdent(na->GetVhostIdent()); - } + u->vhost = na->GetVhostHost(); + if (ircdproto->CanSetVIdent && !na->GetVhostIdent().empty()) + u->SetVIdent(na->GetVhostIdent()); u->UpdateHost(); } else diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index f4b710b7f..94b181f51 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -121,7 +121,7 @@ class CommandHSRequest : public Command source.Reply(HOST_SET_IDENTTOOLONG, Config->UserLen); return; } - else if (!ircd->vident) + else if (!ircdproto->CanSetVIdent) { source.Reply(HOST_NO_VIDENT); return; @@ -354,6 +354,9 @@ class HSRequest : public Module { this->SetAuthor("Anope"); + if (!ircdproto || !ircdproto->CanSetVHost) + throw ModuleException("Your IRCd does not support vhosts"); + Implementation i[] = { I_OnReload }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp index b2509bcea..2189f2483 100644 --- a/modules/commands/hs_set.cpp +++ b/modules/commands/hs_set.cpp @@ -55,7 +55,7 @@ class CommandHSSet : public Command if (!user.empty()) { - if (!ircd->vident) + if (!ircdproto->CanSetVIdent) { source.Reply(HOST_NO_VIDENT); return; @@ -156,7 +156,7 @@ class CommandHSSetAll : public Command if (!user.empty()) { - if (!ircd->vident) + if (!ircdproto->CanSetVIdent) { source.Reply(HOST_NO_VIDENT); return; diff --git a/modules/commands/ns_cert.cpp b/modules/commands/ns_cert.cpp index da3cb2aa1..a06dd1a3a 100644 --- a/modules/commands/ns_cert.cpp +++ b/modules/commands/ns_cert.cpp @@ -225,7 +225,7 @@ class NSCert : public Module { this->SetAuthor("Anope"); - if (!ircd || !ircd->certfp) + if (!ircdproto || !ircdproto->CanCertFP) throw ModuleException("Your IRCd does not support ssl client certificates"); Implementation i[] = { I_OnFingerprint }; diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp index b3b734a39..5daf2357e 100644 --- a/modules/commands/ns_info.cpp +++ b/modules/commands/ns_info.cpp @@ -102,7 +102,7 @@ class CommandNSInfo : public Command { if (na->HasVhost()) { - if (ircd->vident && !na->GetVhostIdent().empty()) + if (ircdproto->CanSetVIdent && !na->GetVhostIdent().empty()) info[_("VHost")] = na->GetVhostIdent() + "@" + na->GetVhostHost(); else info[_("VHost")] = na->GetVhostHost(); diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index 741eb9d43..1d684bc27 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -323,14 +323,6 @@ class OSDefcon : public Module Log() << "DefConChanModes must lock mode +l as well to lock mode +L"; } - - /* Some ircd we can't set NOKNOCK without INVITE */ - /* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */ - if (ircd->knock_needs_i && (cm = ModeManager::FindChannelModeByName(CMODE_NOKNOCK)) && DConfig.DefConModesOn.HasFlag(cm->Name) && !DConfig.DefConModesOn.HasFlag(CMODE_INVITE)) - { - DConfig.DefConModesOn.UnsetFlag(CMODE_NOKNOCK); - Log() << "DefConChanModes must lock mode +i as well to lock mode +K"; - } } public: @@ -437,7 +429,7 @@ class OSDefcon : public Module return EVENT_CONTINUE; } - EventReturn OnChannelModeSet(Channel *c, User *setter, ChannelModeName Name, const Anope::string ¶m) anope_override + EventReturn OnChannelModeSet(Channel *c, MessageSource &, ChannelModeName Name, const Anope::string ¶m) anope_override { ChannelMode *cm = ModeManager::FindChannelModeByName(Name); @@ -451,7 +443,7 @@ class OSDefcon : public Module return EVENT_CONTINUE; } - EventReturn OnChannelModeUnset(Channel *c, User *setter, ChannelModeName Name, const Anope::string &) anope_override + EventReturn OnChannelModeUnset(Channel *c, MessageSource &, ChannelModeName Name, const Anope::string &) anope_override { ChannelMode *cm = ModeManager::FindChannelModeByName(Name); diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp index 4862d5ea9..5f1d1d0ed 100644 --- a/modules/commands/os_forbid.cpp +++ b/modules/commands/os_forbid.cpp @@ -278,7 +278,7 @@ class OSForbid : public Module ForbidData *d = this->forbidService.FindForbid(c->name, FT_CHAN); if (bi != NULL && d != NULL) { - if (ircd->chansqline) + if (ircdproto->CanSQLineChannel) { XLine x(c->name, bi->nick, Anope::CurTime + Config->CSInhabit, d->reason); ircdproto->SendSQLine(NULL, &x); diff --git a/modules/commands/os_jupe.cpp b/modules/commands/os_jupe.cpp index 34c28a864..cfe917c13 100644 --- a/modules/commands/os_jupe.cpp +++ b/modules/commands/os_jupe.cpp @@ -37,7 +37,7 @@ class CommandOSJupe : public Command Anope::string rbuf = "Juped by " + source.GetNick() + (!reason.empty() ? ": " + reason : ""); if (server) ircdproto->SendSquit(server, rbuf); - Server *juped_server = new Server(Me, jserver, 1, rbuf, ircd->ts6 ? ts6_sid_retrieve() : "", SERVER_JUPED); + Server *juped_server = new Server(Me, jserver, 1, rbuf, ts6_sid_retrieve(), SERVER_JUPED); ircdproto->SendServer(juped_server); Log(LOG_ADMIN, source, this) << "on " << jserver << " (" << rbuf << ")"; diff --git a/modules/commands/os_oline.cpp b/modules/commands/os_oline.cpp index a468281e0..ccf053f7e 100644 --- a/modules/commands/os_oline.cpp +++ b/modules/commands/os_oline.cpp @@ -72,7 +72,7 @@ class OSOLine : public Module { this->SetAuthor("Anope"); - if (!ircd || !ircd->omode) + if (!ircdproto || !ircdproto->CanSVSO) throw ModuleException("Your IRCd does not support OMODE."); } diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index 7b593e421..dd5bf9ee0 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -84,7 +84,7 @@ class CommandOSStats : public Command else source.Reply(_("Default AKILL expiry time: \002No expiration\002")); } - if (ircd->snline && snlines) + if (ircdproto->CanSNLine && snlines) { /* SNLINEs */ source.Reply(_("Current number of SNLINEs: \002%d\002"), snlines->GetCount()); @@ -104,7 +104,7 @@ class CommandOSStats : public Command else source.Reply(_("Default SNLINE expiry time: \002No expiration\002")); } - if (ircd->sqline && sqlines) + if (ircdproto->CanSQLine && sqlines) { /* SQLINEs */ source.Reply(_("Current number of SQLINEs: \002%d\002"), sqlines->GetCount()); diff --git a/modules/commands/os_svsnick.cpp b/modules/commands/os_svsnick.cpp index aeaa38a59..4c6329acb 100644 --- a/modules/commands/os_svsnick.cpp +++ b/modules/commands/os_svsnick.cpp @@ -81,7 +81,7 @@ class OSSVSNick : public Module { this->SetAuthor("Anope"); - if (!ircd || !ircd->svsnick) + if (!ircdproto || !ircdproto->CanSVSNick) throw ModuleException("Your IRCd does not support SVSNICK"); } diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp index 20e76a94d..8cd3d9f7a 100644 --- a/modules/commands/os_sxline.cpp +++ b/modules/commands/os_sxline.cpp @@ -250,7 +250,7 @@ class CommandOSSNLine : public CommandOSSXLineBase void OnAdd(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (!this->xlm() ||! ircd->snline) + if (!this->xlm() || !ircdproto->CanSNLine) { source.Reply(_("Your IRCd does not support SNLINE")); return; @@ -384,18 +384,15 @@ class CommandOSSNLine : public CommandOSSXLineBase { this->xlm()->Send(source.GetUser(), x); - if (!ircd->sglineenforce) - { - Anope::string rreason = "G-Lined: " + reason; + Anope::string rreason = "G-Lined: " + reason; - for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) - { - User *user = it->second; - ++it; + for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) + { + User *user = it->second; + ++it; - if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->realname, x->Mask, false, true)) - user->Kill(Config->ServerName, rreason); - } + if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->realname, x->Mask, false, true)) + user->Kill(Config->ServerName, rreason); } } @@ -474,7 +471,7 @@ class CommandOSSQLine : public CommandOSSXLineBase void OnAdd(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (!this->xlm() || !ircd->sqline) + if (!this->xlm() || !ircdproto->CanSQLine) { source.Reply(_("Your IRCd does not support SQLINE")); return; diff --git a/modules/extra/m_chanstats.cpp b/modules/extra/m_chanstats.cpp index ed9a5f444..9d9e9dbd8 100644 --- a/modules/extra/m_chanstats.cpp +++ b/modules/extra/m_chanstats.cpp @@ -365,8 +365,9 @@ class MChanstats : public Module else Log() << "Chanstats: no database connection to " << engine; } - void OnTopicUpdated(Channel *c, User *u, const Anope::string &topic) anope_override + void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) anope_override { + User *u = finduser(user); if (!u || !u->Account() || !c->ci || !c->ci->HasFlag(CI_STATS)) return; query = "CALL " + prefix + "chanstats_proc_update(@channel@, @nick@, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);"; @@ -374,16 +375,17 @@ class MChanstats : public Module query.setValue("nick", GetDisplay(u)); this->RunQuery(query); } - EventReturn OnChannelModeSet(Channel *c, User *setter, ChannelModeName Name, const Anope::string ¶m) anope_override + EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelModeName Name, const Anope::string ¶m) anope_override { - this->OnModeChange(c, setter); + this->OnModeChange(c, setter.GetUser()); return EVENT_CONTINUE; } - EventReturn OnChannelModeUnset(Channel *c, User *setter, ChannelModeName Name, const Anope::string ¶m) anope_override + EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelModeName Name, const Anope::string ¶m) anope_override { - this->OnModeChange(c, setter); + this->OnModeChange(c, setter.GetUser()); return EVENT_CONTINUE; } + private: void OnModeChange(Channel *c, User *u) { if (!u || !u->Account() || !c->ci || !c->ci->HasFlag(CI_STATS)) @@ -394,7 +396,8 @@ class MChanstats : public Module query.setValue("nick", GetDisplay(u)); this->RunQuery(query); } - void OnUserKicked(Channel *c, User *target, const Anope::string &source, const Anope::string &kickmsg) anope_override + public: + void OnUserKicked(Channel *c, User *target, MessageSource &source, const Anope::string &kickmsg) anope_override { if (!c->ci || !c->ci->HasFlag(CI_STATS)) return; @@ -406,7 +409,7 @@ class MChanstats : public Module query = "CALL " + prefix + "chanstats_proc_update(@channel@, @nick@, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0);"; query.setValue("channel", c->name); - query.setValue("nick", GetDisplay(finduser(source))); + query.setValue("nick", GetDisplay(source.GetUser())); this->RunQuery(query); } void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override diff --git a/modules/extra/m_proxyscan.cpp b/modules/extra/m_proxyscan.cpp index f7fa3fdad..e6ee4008a 100644 --- a/modules/extra/m_proxyscan.cpp +++ b/modules/extra/m_proxyscan.cpp @@ -94,7 +94,7 @@ class ProxyConnect : public ConnectionSocket } else { - if (ircd->szline) + if (ircdproto->CanSZLine) ircdproto->SendSZLine(NULL, x); else ircdproto->SendAkill(NULL, x); diff --git a/modules/extra/webcpanel/webcpanel.cpp b/modules/extra/webcpanel/webcpanel.cpp index 4970845cd..bb65387f2 100644 --- a/modules/extra/webcpanel/webcpanel.cpp +++ b/modules/extra/webcpanel/webcpanel.cpp @@ -73,7 +73,7 @@ class ModuleWebCPanel : public Module s.subsections.push_back(ss); provider->RegisterPage(&this->nickserv_info); - if (ircd && ircd->certfp) + if (ircdproto && ircdproto->CanCertFP) { ss.name = "SSL Certificates"; ss.url = "/nickserv/cert"; diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 73955149d..8aeee39c8 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -13,34 +13,40 @@ #include "module.h" -IRCDVar myIrcd = { - "Bahamut 1.8.x", /* ircd name */ - "+", /* Modes used by pseudoclients */ - 1, /* SVSNICK */ - 0, /* Vhost */ - 1, /* Supports SNlines */ - 1, /* Supports SQlines */ - 1, /* Supports SZlines */ - 0, /* Join 2 Message */ - 1, /* Chan SQlines */ - 1, /* Quit on Kill */ - 0, /* vidents */ - 1, /* svshold */ - 1, /* time stamp on mode */ - 0, /* O:LINE */ - 1, /* UMODE */ - 1, /* No Knock requires +i */ - 0, /* Can remove User Channel Modes with SVSMODE */ - 0, /* Sglines are not enforced until user reconnects */ - 0, /* ts6 */ - "$", /* TLD Prefix for Global */ - 6, /* Max number of modes we can send per line */ - 0 /* IRCd sends a SSL users certificate fingerprint */ -}; +class ChannelModeFlood : public ChannelModeParam +{ + public: + ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam(CMODE_FLOOD, modeChar, minusNoArg) { } + bool IsValid(const Anope::string &value) const anope_override + { + try + { + Anope::string rest; + if (!value.empty() && value[0] != ':' && convertTo<int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<int>(rest.substr(1), rest, false) > 0 && rest.empty()) + return true; + } + catch (const ConvertException &) { } + + return false; + } +}; class BahamutIRCdProto : public IRCDProto { + public: + BahamutIRCdProto() : IRCDProto("Bahamut 1.8.x") + { + DefaultPseudoclientModes = "+"; + CanSVSNick = true; + CanSNLine = true; + CanSQLine = true; + CanSQLineChannel = true; + CanSZLine = true; + CanSVSHold = true; + MaxModes = 60; + } + void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override { if (Capab.count("TSMODE") > 0) @@ -62,6 +68,16 @@ class BahamutIRCdProto : public IRCDProto UplinkSocket::Message(Me) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf; } + void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + { + UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg; + } + + void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + { + UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg; + } + /* SVSHOLD - set */ void SendSVSHold(const Anope::string &nick) anope_override { @@ -290,46 +306,82 @@ class BahamutIRCdProto : public IRCDProto } }; -class BahamutIRCdMessage : public IRCdMessage +struct IRCDMessageBurst : IRCDMessage { - public: - bool OnMode(const Anope::string &source, const std::vector<Anope::string> ¶ms) anope_override - { - if (params.size() > 2 && (params[0][0] == '#' || params[0][0] == '&')) - do_cmode(source, params[0], params[2], params[1]); - else if (params.size() > 1) - do_umode(params[0], params[1]); + IRCDMessageBurst() : IRCDMessage("BURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_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); return true; } +}; - /* - ** NICK - new - ** source = NULL - ** parv[0] = nickname - ** parv[1] = hopcount - ** parv[2] = timestamp - ** parv[3] = modes - ** parv[4] = username - ** parv[5] = hostname - ** parv[6] = server - ** parv[7] = servicestamp - ** parv[8] = IP - ** parv[9] = info - ** NICK - change - ** source = oldnick - ** parv[0] = new nickname - ** parv[1] = hopcount - */ - bool OnNick(const Anope::string &source, const std::vector<Anope::string> ¶ms) anope_override - { - if (params.size() != 2) +struct IRCDMessageMode : IRCDMessage +{ + IRCDMessageMode(const Anope::string &n) : IRCDMessage(n, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + if (params.size() > 2 && ircdproto->IsChannelValid(params[0])) + { + Channel *c = findchan(params[0]); + time_t ts = Anope::CurTime; + try + { + ts = convertTo<time_t>(params[1]); + } + catch (const ConvertException &) { } + + if (c) + c->SetModesInternal(source, params[2], ts); + } + else { - /* Currently bahamut has no ipv6 support */ - sockaddrs ip; - ip.ntop(AF_INET, params[8].c_str()); + User *u = finduser(params[0]); + if (u) + u->SetModesInternal("%s", params[1].c_str()); + } + + return true; + } +}; + +/* + ** NICK - new + ** source = NULL + ** parv[0] = nickname + ** parv[1] = hopcount + ** parv[2] = timestamp + ** parv[3] = modes + ** parv[4] = username + ** parv[5] = hostname + ** parv[6] = server + ** parv[7] = servicestamp + ** parv[8] = IP + ** parv[9] = info + ** NICK - change + ** source = oldnick + ** parv[0] = new nickname + ** parv[1] = hopcount + */ +struct IRCDMessageNick : IRCDMessage +{ + IRCDMessageNick() : IRCDMessage("NICK", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - User *user = do_nick(source, params[0], params[4], params[5], params[6], params[9], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, ip.addr(), "", "", params[3]); + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + if (params.size() == 10) + { + User *user = new User(params[0], params[4], params[5], "", params[8], source.GetServer(), params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[3]); if (user && nickserv) { const NickAlias *na; @@ -345,35 +397,29 @@ class BahamutIRCdMessage : public IRCdMessage } } else - do_nick(source, params[0], "", "", "", "", Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0, "", "", "", ""); + source.GetUser()->ChangeNick(params[0]); return true; } +}; - bool OnServer(const Anope::string &source, const std::vector<Anope::string> ¶ms) anope_override - { - do_server(source, params[0], Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, params[2], ""); - return true; - } +struct IRCDMessageServer : IRCDMessage +{ + IRCDMessageServer() : IRCDMessage("SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - bool OnTopic(const Anope::string &, const std::vector<Anope::string> ¶ms) anope_override + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (params.size() < 4) - return true; - - Channel *c = findchan(params[0]); - if (!c) - { - Log() << "TOPIC for nonexistant channel " << params[0]; - return true; - } - - c->ChangeTopicInternal(params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime); - + 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]); return true; } +}; - bool OnSJoin(const Anope::string &source, const std::vector<Anope::string> ¶ms) anope_override +struct IRCDMessageSJoin : IRCDMessage +{ + IRCDMessageSJoin() : IRCDMessage("SJOIN", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { Channel *c = findchan(params[1]); time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0; @@ -403,7 +449,7 @@ class BahamutIRCdMessage : public IRCdMessage modes += " " + params[i]; if (!modes.empty()) modes.erase(modes.begin()); - c->SetModesInternal(NULL, modes); + c->SetModesInternal(source, modes); } /* For some reason, bahamut will send a SJOIN from the user joining a channel @@ -411,28 +457,24 @@ class BahamutIRCdMessage : public IRCdMessage */ if (!c->HasFlag(CH_SYNCING) && params.size() == 2) { - User *u = finduser(source); - if (!u) - Log(LOG_DEBUG) << "SJOIN for nonexistant user " << source << " on " << c->name; - else - { - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); + User *u = source.GetUser(); - /* Add the user to the channel */ - c->JoinUser(u); + EventReturn MOD_RESULT; + FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); - /* Now set whatever modes this user is allowed to have on the channel */ - chan_set_correct_modes(u, c, 1, true); + /* Add the user to the channel */ + c->JoinUser(u); - /* Check to see if modules want the user to join, if they do - * check to see if they are allowed to join (CheckKick will kick/ban them) - * Don't trigger OnJoinChannel event then as the user will be destroyed - */ - if (MOD_RESULT == EVENT_STOP && (!c->ci || !c->ci->CheckKick(u))) - { - FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); - } + /* Now set whatever modes this user is allowed to have on the channel */ + chan_set_correct_modes(u, c, 1, true); + + /* Check to see if modules want the user to join, if they do + * check to see if they are allowed to join (CheckKick will kick/ban them) + * Don't trigger OnJoinChannel event then as the user will be destroyed + */ + if (MOD_RESULT == EVENT_STOP && (!c->ci || !c->ci->CheckKick(u))) + { + FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); } } else @@ -476,7 +518,7 @@ class BahamutIRCdMessage : public IRCdMessage * This will enforce secureops etc on the user */ for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it) - c->SetModeInternal(NULL, *it, buf); + c->SetModeInternal(source, *it, buf); /* Now set whatever modes this user is allowed to have on the channel */ chan_set_correct_modes(u, c, 1, true); @@ -504,53 +546,48 @@ class BahamutIRCdMessage : public IRCdMessage } }; -bool event_burst(const Anope::string &source, const std::vector<Anope::string> ¶ms) -{ - Server *s = Server::Find(source); - - if (params.empty()) - { - /* for future use - start burst */ - } - else - { - /* 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 - */ - if (!s) - s = Me->GetLinks().front(); - if (s) - s->Sync(true); - } - return true; -} - -class ChannelModeFlood : public ChannelModeParam +struct IRCDMessageTopic : IRCDMessage { - public: - ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam(CMODE_FLOOD, modeChar, minusNoArg) { } + IRCDMessageTopic() : IRCDMessage("TOPIC", 4) { } - bool IsValid(const Anope::string &value) const anope_override + bool Run(MessageSource &, const std::vector<Anope::string> ¶ms) anope_override { - try - { - Anope::string rest; - if (!value.empty() && value[0] != ':' && convertTo<int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<int>(rest.substr(1), rest, false) > 0 && rest.empty()) - return true; - } - catch (const ConvertException &) { } - - return false; + Channel *c = findchan(params[0]); + if (c) + c->ChangeTopicInternal(params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime); + return true; } }; class ProtoBahamut : public Module { - Message message_svsmode, message_burst; - BahamutIRCdProto ircd_proto; - BahamutIRCdMessage ircd_message; + + /* Core message handlers */ + CoreIRCDMessageAway core_message_away; + CoreIRCDMessageCapab core_message_capab; + CoreIRCDMessageError core_message_error; + CoreIRCDMessageJoin core_message_join; + CoreIRCDMessageKill core_message_kill; + CoreIRCDMessageMOTD core_message_motd; + CoreIRCDMessagePart core_message_part; + CoreIRCDMessagePing core_message_ping; + CoreIRCDMessagePrivmsg core_message_privmsg; + CoreIRCDMessageQuit core_message_quit; + CoreIRCDMessageSQuit core_message_squit; + CoreIRCDMessageStats core_message_stats; + CoreIRCDMessageTime core_message_time; + CoreIRCDMessageTopic core_message_topic; + CoreIRCDMessageVersion core_message_version; + CoreIRCDMessageWhois core_message_whois |
