diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/protocol/bahamut.cpp | 452 | ||||
| -rw-r--r-- | modules/protocol/charybdis.cpp | 222 | ||||
| -rw-r--r-- | modules/protocol/hybrid.cpp | 499 | ||||
| -rw-r--r-- | modules/protocol/inspircd20.cpp | 723 | ||||
| -rw-r--r-- | modules/protocol/ngircd.cpp | 236 | ||||
| -rw-r--r-- | modules/protocol/plexus.cpp | 266 | ||||
| -rw-r--r-- | modules/protocol/ratbox.cpp | 216 | ||||
| -rw-r--r-- | modules/protocol/unreal.cpp | 660 |
8 files changed, 1593 insertions, 1681 deletions
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 7ab9dd9b2..46ffb3ea2 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -42,281 +42,277 @@ class ChannelModeFlood : public ChannelModeParam } }; -class BahamutIRCdProto : public IRCDProto +bahamut::Proto::Proto(Module *creator) : IRCDProto(creator, "Bahamut 1.8.x") { - public: - BahamutIRCdProto(Module *creator) : IRCDProto(creator, "Bahamut 1.8.x") - { - DefaultPseudoclientModes = "+"; - CanSVSNick = true; - CanSNLine = true; - CanSQLine = true; - CanSQLineChannel = true; - CanSZLine = true; - CanSVSHold = true; - MaxModes = 60; - } - - void SendMode(const MessageSource &source, Channel *dest, const Anope::string &buf) override - { - if (Servers::Capab.count("TSMODE") > 0) - { - IRCMessage message(source, "MODE", dest->name, dest->creation_time); - message.TokenizeAndPush(buf); - Uplink::SendMessage(message); - } - else - { - IRCDProto::SendMode(source, dest, buf); - } - } + DefaultPseudoclientModes = "+"; + CanSVSNick = true; + CanSNLine = true; + CanSQLine = true; + CanSQLineChannel = true; + CanSZLine = true; + CanSVSHold = true; + MaxModes = 60; +} - void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override +void bahamut::Proto::SendMode(const MessageSource &source, Channel *dest, const Anope::string &buf) +{ + if (Servers::Capab.count("TSMODE") > 0) { - IRCMessage message(source, "SVSMODE", u->nick, u->timestamp); + IRCMessage message(source, "MODE", dest->name, dest->creation_time); message.TokenizeAndPush(buf); Uplink::SendMessage(message); } - - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override + else { - Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); + IRCDProto::SendMode(source, dest, buf); } +} - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); - } +void bahamut::Proto::SendMode(const MessageSource &source, User *u, const Anope::string &buf) +{ + IRCMessage message(source, "SVSMODE", u->nick, u->timestamp); + message.TokenizeAndPush(buf); + Uplink::SendMessage(message); +} - /* SVSHOLD - set */ - void SendSVSHold(const Anope::string &nick, time_t time) override - { - Uplink::Send(Me, "SVSHOLD", nick, time, "Being held for registered user"); - } +void bahamut::Proto::SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); +} - /* SVSHOLD - release */ - void SendSVSHoldDel(const Anope::string &nick) override - { - Uplink::Send(Me, "SVSHOLD", nick, 0); - } +void bahamut::Proto::SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); +} - /* SQLINE */ - void SendSQLine(User *, XLine *x) override - { - Uplink::Send(Me, "SQLINE", x->GetMask(), x->GetReason()); - } +/* SVSHOLD - set */ +void bahamut::Proto::SendSVSHold(const Anope::string &nick, time_t time) +{ + Uplink::Send(Me, "SVSHOLD", nick, time, "Being held for registered user"); +} - /* UNSLINE */ - void SendSGLineDel(XLine *x) override - { - Uplink::Send("UNSGLINE", 0, x->GetMask()); - } +/* SVSHOLD - release */ +void bahamut::Proto::SendSVSHoldDel(const Anope::string &nick) +{ + Uplink::Send(Me, "SVSHOLD", nick, 0); +} - /* UNSZLINE */ - void SendSZLineDel(XLine *x) override - { - /* this will likely fail so its only here for legacy */ - Uplink::Send("UNSZLINE", 0, x->GetHost()); - /* this is how we are supposed to deal with it */ - Uplink::Send("RAKILL", x->GetHost(), "*"); - } +/* SQLINE */ +void bahamut::Proto::SendSQLine(User *, XLine *x) +{ + Uplink::Send(Me, "SQLINE", x->GetMask(), x->GetReason()); +} - /* SZLINE */ - void SendSZLine(User *, XLine *x) override - { - // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->GetExpires() - Anope::CurTime; - if (timeleft > 172800 || !x->GetExpires()) - timeleft = 172800; - /* this will likely fail so its only here for legacy */ - Uplink::Send("SZLINE", x->GetHost(), x->GetReason()); - /* this is how we are supposed to deal with it */ - Uplink::Send("AKILL", x->GetHost(), "*", timeleft, x->GetBy(), Anope::CurTime, x->GetReason()); - } +/* UNSLINE */ +void bahamut::Proto::SendSGLineDel(XLine *x) +{ + Uplink::Send("UNSGLINE", 0, x->GetMask()); +} - /* SVSNOOP */ - void SendSVSNOOP(Server *server, bool set) override - { - Uplink::Send("SVSNOOP", server->GetName(), set ? "+" : "-"); - } +/* UNSZLINE */ +void bahamut::Proto::SendSZLineDel(XLine *x) +{ + /* this will likely fail so its only here for legacy */ + Uplink::Send("UNSZLINE", 0, x->GetHost()); + /* this is how we are supposed to deal with it */ + Uplink::Send("RAKILL", x->GetHost(), "*"); +} - /* SGLINE */ - void SendSGLine(User *, XLine *x) override - { - Uplink::Send("SGLINE", x->GetMask().length(), x->GetMask() + ":" + x->GetReason()); - } +/* SZLINE */ +void bahamut::Proto::SendSZLine(User *, XLine *x) +{ + // Calculate the time left before this would expire, capping it at 2 days + time_t timeleft = x->GetExpires() - Anope::CurTime; + if (timeleft > 172800 || !x->GetExpires()) + timeleft = 172800; + /* this will likely fail so its only here for legacy */ + Uplink::Send("SZLINE", x->GetHost(), x->GetReason()); + /* this is how we are supposed to deal with it */ + Uplink::Send("AKILL", x->GetHost(), "*", timeleft, x->GetBy(), Anope::CurTime, x->GetReason()); +} - /* RAKILL */ - void SendAkillDel(XLine *x) override - { - if (x->IsRegex() || x->HasNickOrReal()) - return; +/* SVSNOOP */ +void bahamut::Proto::SendSVSNOOP(Server *server, bool set) +{ + Uplink::Send("SVSNOOP", server->GetName(), set ? "+" : "-"); +} - /* ZLine if we can instead */ - if (x->GetUser() == "*") - { - cidr a(x->GetHost()); - if (a.valid()) - { - IRCD->SendSZLineDel(x); - return; - } - } +/* SGLINE */ +void bahamut::Proto::SendSGLine(User *, XLine *x) +{ + Uplink::Send("SGLINE", x->GetMask().length(), x->GetMask() + ":" + x->GetReason()); +} - Uplink::Send("RAKKILL", x->GetHost(), x->GetUser()); - } +/* RAKILL */ +void bahamut::Proto::SendAkillDel(XLine *x) +{ + if (x->IsRegex() || x->HasNickOrReal()) + return; - /* TOPIC */ - void SendTopic(const MessageSource &source, Channel *c) override + /* ZLine if we can instead */ + if (x->GetUser() == "*") { - Uplink::Send(source, "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic); + cidr a(x->GetHost()); + if (a.valid()) + { + IRCD->SendSZLineDel(x); + return; + } } - /* UNSQLINE */ - void SendSQLineDel(XLine *x) override - { - Uplink::Send("UNSQLINE", x->GetMask()); - } + Uplink::Send("RAKKILL", x->GetHost(), x->GetUser()); +} + +/* TOPIC */ +void bahamut::Proto::SendTopic(const MessageSource &source, Channel *c) +{ + Uplink::Send(source, "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic); +} + +/* UNSQLINE */ +void bahamut::Proto::SendSQLineDel(XLine *x) +{ + Uplink::Send("UNSQLINE", x->GetMask()); +} - /* JOIN - SJOIN */ - void SendJoin(User *user, Channel *c, const ChannelStatus *status) override +/* JOIN - SJOIN */ +void bahamut::Proto::SendJoin(User *user, Channel *c, const ChannelStatus *status) +{ + Uplink::Send(user, "SJOIN", c->creation_time, c->name); + + if (status) { - Uplink::Send(user, "SJOIN", c->creation_time, c->name); + /* First save the channel status incase uc->Status == status */ + ChannelStatus cs = *status; + /* If the user is internally on the channel with flags, kill them so that + * the stacker will allow this. + */ + ChanUserContainer *uc = c->FindUser(user); + if (uc != NULL) + uc->status.Clear(); - if (status) - { - /* First save the channel status incase uc->Status == status */ - ChannelStatus cs = *status; - /* If the user is internally on the channel with flags, kill them so that - * the stacker will allow this. - */ - ChanUserContainer *uc = c->FindUser(user); - if (uc != NULL) - uc->status.Clear(); - - ServiceBot *setter = ServiceBot::Find(user->GetUID()); - for (size_t i = 0; i < cs.Modes().length(); ++i) - c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); - - if (uc != NULL) - uc->status = cs; - } + ServiceBot *setter = ServiceBot::Find(user->GetUID()); + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); + + if (uc != NULL) + uc->status = cs; } +} - void SendAkill(User *u, XLine *x) override +void bahamut::Proto::SendAkill(User *u, XLine *x) +{ + if (x->IsRegex() || x->HasNickOrReal()) { - if (x->IsRegex() || x->HasNickOrReal()) + if (!u) { - if (!u) - { - /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */ - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - if (x->GetManager()->Check(it->second, x)) - this->SendAkill(it->second, x); - return; - } + /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */ + for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + if (x->GetManager()->Check(it->second, x)) + this->SendAkill(it->second, x); + return; + } - XLine *old = x; + XLine *old = x; - if (old->GetManager()->HasEntry("*@" + u->host)) - return; + if (old->GetManager()->HasEntry("*@" + u->host)) + return; - /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - x = Serialize::New<XLine *>(); - x->SetMask("*@" + u->host); - x->SetBy(old->GetBy()); - x->SetExpires(old->GetExpires()); - x->SetReason(old->GetReason()); - x->SetID(old->GetID()); - old->GetManager()->AddXLine(x); + /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ + x = Serialize::New<XLine *>(); + x->SetMask("*@" + u->host); + x->SetBy(old->GetBy()); + x->SetExpires(old->GetExpires()); + x->SetReason(old->GetReason()); + x->SetID(old->GetID()); + old->GetManager()->AddXLine(x); - Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); - } + Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); + } - /* ZLine if we can instead */ - if (x->GetUser() == "*") + /* ZLine if we can instead */ + if (x->GetUser() == "*") + { + cidr a(x->GetHost()); + if (a.valid()) { - cidr a(x->GetHost()); - if (a.valid()) - { - IRCD->SendSZLine(u, x); - return; - } + IRCD->SendSZLine(u, x); + return; } - - // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->GetExpires() - Anope::CurTime; - if (timeleft > 172800) - timeleft = 172800; - - Uplink::Send("AKILL", x->GetHost(), x->GetUser(), timeleft, x->GetBy(), Anope::CurTime, x->GetReason()); } - /* - Note: if the stamp is null 0, the below usage is correct of Bahamut - */ - void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override - { - Uplink::Send(source, "SVSKILL", user->nick, buf); - } + // Calculate the time left before this would expire, capping it at 2 days + time_t timeleft = x->GetExpires() - Anope::CurTime; + if (timeleft > 172800) + timeleft = 172800; - void SendBOB() override - { - Uplink::Send("BURST"); - } + Uplink::Send("AKILL", x->GetHost(), x->GetUser(), timeleft, x->GetBy(), Anope::CurTime, x->GetReason()); +} - void SendEOB() override - { - Uplink::Send("BURST", 0); - } +/* + Note: if the stamp is null 0, the below usage is correct of Bahamut +*/ +void bahamut::Proto::SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) +{ + Uplink::Send(source, "SVSKILL", user->nick, buf); +} - void SendClientIntroduction(User *u) override - { - Anope::string modes = "+" + u->GetModes(); - Uplink::Send("NICK", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, u->server->GetName(), 0, 0, u->realname); - } +void bahamut::Proto::SendBOB() +{ + Uplink::Send("BURST"); +} - /* SERVER */ - void SendServer(Server *server) override - { - Uplink::Send("SERVER", server->GetName(), server->GetHops(), server->GetDescription()); - } +void bahamut::Proto::SendEOB() +{ + Uplink::Send("BURST", 0); +} - void SendConnect() override - { - Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS"); - Uplink::Send("CAPAB", "SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3"); - SendServer(Me); - /* - * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time - */ - Uplink::Send("SVINFO", 3, 1, 0, Anope::CurTime); - this->SendBOB(); - } +void bahamut::Proto::SendClientIntroduction(User *u) +{ + Anope::string modes = "+" + u->GetModes(); + Uplink::Send("NICK", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, u->server->GetName(), 0, 0, u->realname); +} - void SendChannel(Channel *c) override - { - Anope::string modes = c->GetModes(true, true); - if (modes.empty()) - modes = "+"; - Uplink::Send("SJOIN", c->creation_time, c->name, modes, ""); - } +/* SERVER */ +void bahamut::Proto::SendServer(Server *server) +{ + Uplink::Send("SERVER", server->GetName(), server->GetHops(), server->GetDescription()); +} - void SendLogin(User *u, NickServ::Nick *) override - { - IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", u->signon); - } +void bahamut::Proto::SendConnect() +{ + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS"); + Uplink::Send("CAPAB", "SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3"); + SendServer(Me); + /* + * SVINFO + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time + */ + Uplink::Send("SVINFO", 3, 1, 0, Anope::CurTime); + this->SendBOB(); +} - void SendLogout(User *u) override - { - IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 1"); - } -}; +void bahamut::Proto::SendChannel(Channel *c) +{ + Anope::string modes = c->GetModes(true, true); + if (modes.empty()) + modes = "+"; + Uplink::Send("SJOIN", c->creation_time, c->name, modes, ""); +} + +void bahamut::Proto::SendLogin(User *u, NickServ::Nick *) +{ + IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", u->signon); +} + +void bahamut::Proto::SendLogout(User *u) +{ + IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 1"); +} void bahamut::Burst::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { @@ -496,7 +492,7 @@ void bahamut::Topic::Run(MessageSource &source, const std::vector<Anope::string> class ProtoBahamut : public Module , public EventHook<Event::UserNickChange> { - BahamutIRCdProto ircd_proto; + bahamut::Proto ircd_proto; /* Core message handlers */ rfc1459::Away message_away; diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index c111a31d3..4488f5425 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -40,143 +40,119 @@ class ChannelModeLargeBan : public ChannelMode }; -class CharybdisProto : public IRCDProto +charybdis::Proto::Proto(Module *creator) : IRCDProto(creator, "Charybdis 3.4+") + , ratbox("ratbox") { - ServiceReference<IRCDProto> ratbox; // XXX - - public: - CharybdisProto(Module *creator) : IRCDProto(creator, "Charybdis 3.4+") - , ratbox("ratbox") - { - DefaultPseudoclientModes = "+oiS"; - CanCertFP = true; - CanSNLine = true; - CanSQLine = true; - CanSQLineChannel = true; - CanSZLine = true; - CanSVSNick = true; - CanSVSHold = true; - CanSetVHost = true; - RequiresID = true; - MaxModes = 4; - } + DefaultPseudoclientModes = "+oiS"; + CanCertFP = true; + CanSNLine = true; + CanSQLine = true; + CanSQLineChannel = true; + CanSZLine = true; + CanSVSNick = true; + CanSVSHold = true; + CanSetVHost = true; + RequiresID = true; + MaxModes = 4; +} - void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { ratbox->SendSVSKill(source, targ, reason); } - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override { ratbox->SendGlobalNotice(bi, dest, msg); } - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override { ratbox->SendGlobalPrivmsg(bi, dest, msg); } - void SendGlobops(const MessageSource &source, const Anope::string &buf) override { ratbox->SendGlobops(source, buf); } - void SendSGLine(User *u, XLine *x) override { ratbox->SendSGLine(u, x); } - void SendSGLineDel(XLine *x) override { ratbox->SendSGLineDel(x); } - void SendAkill(User *u, XLine *x) override { ratbox->SendAkill(u, x); } - void SendAkillDel(XLine *x) override { ratbox->SendAkillDel(x); } - void SendSQLine(User *u, XLine *x) override { ratbox->SendSQLine(u, x); } - void SendSQLineDel(XLine *x) override { ratbox->SendSQLineDel(x); } - void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { ratbox->SendJoin(user, c, status); } - void SendServer(Server *server) override { ratbox->SendServer(server); } - void SendChannel(Channel *c) override { ratbox->SendChannel(c); } - void SendTopic(const MessageSource &source, Channel *c) override { ratbox->SendTopic(source, c); } - bool IsIdentValid(const Anope::string &ident) override { return ratbox->IsIdentValid(ident); } - void SendLogin(User *u, NickServ::Nick *na) override { ratbox->SendLogin(u, na); } - void SendLogout(User *u) override { ratbox->SendLogout(u); } - - void SendConnect() override - { - Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); - - /* - * Received: CAPAB :BAN CHW CLUSTER ENCAP EOPMOD EUID EX IE KLN - * KNOCK MLOCK QS RSFNC SAVE SERVICES TB UNKLN - * - * BAN - Can do BAN message - * CHW - Can do channel wall @# - * CLUSTER - Supports umode +l, can send LOCOPS (encap only) - * ENCAP - Can do ENCAP message - * EOPMOD - Can do channel wall =# (for cmode +z) - * EUID - Can do EUID (its similar to UID but includes the ENCAP REALHOST and ENCAP LOGIN information) - * EX - Can do channel +e exemptions - * GLN - Can set G:Lines - * IE - Can do invite exceptions - * KLN - Can set K:Lines (encap only) - * KNOCK - Supports KNOCK - * MLOCK - Supports MLOCK - * RSFNC - Forces a nickname change and propagates it (encap only) - * SERVICES - Support channel mode +r (only registered users may join) - * SAVE - Resolve a nick collision by changing a nickname to the UID. - * TB - Supports topic burst - * UNKLN - Can do UNKLINE (encap only) - * QS - Can handle quit storm removal - */ - Uplink::Send("CAPAB", "BAN CHW CLUSTER ENCAP EOPMOD EUID EX IE KLN KNOCK MLOCK QS RSFNC SERVICES TB UNKLN"); - - /* Make myself known to myself in the serverlist */ - SendServer(Me); - - /* - * Received: SVINFO 6 6 0 :1353235537 - * arg[0] = current TS version - * arg[1] = minimum required TS version - * arg[2] = '0' - * arg[3] = server's idea of UTC time - */ - Uplink::Send("SVINFO", 6, 6, Anope::CurTime); - } +void charybdis::Proto::SendConnect() +{ + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); - void SendClientIntroduction(User *u) override - { - Anope::string modes = "+" + u->GetModes(); - Uplink::Send(Me, "EUID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, 0, u->GetUID(), "*", "*", u->realname); - } + /* + * Received: CAPAB :BAN CHW CLUSTER ENCAP EOPMOD EUID EX IE KLN + * KNOCK MLOCK QS RSFNC SAVE SERVICES TB UNKLN + * + * BAN - Can do BAN message + * CHW - Can do channel wall @# + * CLUSTER - Supports umode +l, can send LOCOPS (encap only) + * ENCAP - Can do ENCAP message + * EOPMOD - Can do channel wall =# (for cmode +z) + * EUID - Can do EUID (its similar to UID but includes the ENCAP REALHOST and ENCAP LOGIN information) + * EX - Can do channel +e exemptions + * GLN - Can set G:Lines + * IE - Can do invite exceptions + * KLN - Can set K:Lines (encap only) + * KNOCK - Supports KNOCK + * MLOCK - Supports MLOCK + * RSFNC - Forces a nickname change and propagates it (encap only) + * SERVICES - Support channel mode +r (only registered users may join) + * SAVE - Resolve a nick collision by changing a nickname to the UID. + * TB - Supports topic burst + * UNKLN - Can do UNKLINE (encap only) + * QS - Can handle quit storm removal + */ + Uplink::Send("CAPAB", "BAN CHW CLUSTER ENCAP EOPMOD EUID EX IE KLN KNOCK MLOCK QS RSFNC SERVICES TB UNKLN"); + + /* Make myself known to myself in the serverlist */ + SendServer(Me); - void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override - { - Uplink::Send(Me, "ENCAP", u->server->GetName(), "RSFNC", u->GetUID(), - newnick, when, u->timestamp); - } + /* + * Received: SVINFO 6 6 0 :1353235537 + * arg[0] = current TS version + * arg[1] = minimum required TS version + * arg[2] = '0' + * arg[3] = server's idea of UTC time + */ + Uplink::Send("SVINFO", 6, 6, Anope::CurTime); +} - void SendSVSHold(const Anope::string &nick, time_t delay) override - { - Uplink::Send(Me, "ENCAP", "*", "NICKDELAY", delay, nick); - } +void charybdis::Proto::SendClientIntroduction(User *u) +{ + Anope::string modes = "+" + u->GetModes(); + Uplink::Send(Me, "EUID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, 0, u->GetUID(), "*", "*", u->realname); +} - void SendSVSHoldDel(const Anope::string &nick) override - { - Uplink::Send(Me, "ENCAP", "*", "NICKDELAY", 0, nick); - } +void charybdis::Proto::SendForceNickChange(User *u, const Anope::string &newnick, time_t when) +{ + Uplink::Send(Me, "ENCAP", u->server->GetName(), "RSFNC", u->GetUID(), + newnick, when, u->timestamp); +} - void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) override - { - Uplink::Send(Me, "ENCAP", "*", "CHGHOST", u->GetUID(), host); - } +void charybdis::Proto::SendSVSHold(const Anope::string &nick, time_t delay) +{ + Uplink::Send(Me, "ENCAP", "*", "NICKDELAY", delay, nick); +} - void SendVhostDel(User *u) override - { - this->SendVhost(u, "", u->host); - } +void charybdis::Proto::SendSVSHoldDel(const Anope::string &nick) +{ + Uplink::Send(Me, "ENCAP", "*", "NICKDELAY", 0, nick); +} - void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) override - { - Anope::string mechlist; +void charybdis::Proto::SendVhost(User *u, const Anope::string &ident, const Anope::string &host) +{ + Uplink::Send(Me, "ENCAP", "*", "CHGHOST", u->GetUID(), host); +} - for (unsigned i = 0; i < mechanisms.size(); ++i) - { - mechlist += "," + mechanisms[i]; - } +void charybdis::Proto::SendVhostDel(User *u) +{ + this->SendVhost(u, "", u->host); +} - Uplink::Send(Me, "ENCAP", "*", "MECHLIST", mechlist.empty() ? "" : mechlist.substr(1)); - } +void charybdis::Proto::SendSASLMechanisms(std::vector<Anope::string> &mechanisms) +{ + Anope::string mechlist; - void SendSASLMessage(const SASL::Message &message) override + for (unsigned i = 0; i < mechanisms.size(); ++i) { - Server *s = Server::Find(message.target.substr(0, 3)); - Uplink::Send(Me, "ENCAP", s ? s->GetName() : message.target.substr(0, 3), "SASL", message.source, message.target, message.type, message.data, message.ext.empty() ? "" : message.ext); + mechlist += "," + mechanisms[i]; } - void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) override - { - Server *s = Server::Find(uid.substr(0, 3)); - Uplink::Send(Me, "ENCAP", s ? s->GetName() : uid.substr(0, 3), "SVSLOGIN", uid, "*", vident.empty() ? "*" : vident, vhost.empty() ? "*" : vhost, acc); - } -}; + Uplink::Send(Me, "ENCAP", "*", "MECHLIST", mechlist.empty() ? "" : mechlist.substr(1)); +} + +void charybdis::Proto::SendSASLMessage(const SASL::Message &message) +{ + Server *s = Server::Find(message.target.substr(0, 3)); + Uplink::Send(Me, "ENCAP", s ? s->GetName() : message.target.substr(0, 3), "SASL", message.source, message.target, message.type, message.data, message.ext.empty() ? "" : message.ext); +} + +void charybdis::Proto::SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) +{ + Server *s = Server::Find(uid.substr(0, 3)); + Uplink::Send(Me, "ENCAP", s ? s->GetName() : uid.substr(0, 3), "SVSLOGIN", uid, "*", vident.empty() ? "*" : vident, vhost.empty() ? "*" : vhost, acc); +} void charybdis::Encap::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) @@ -268,7 +244,7 @@ class ProtoCharybdis : public Module { ServiceReference<ModeLocks> mlocks; - CharybdisProto ircd_proto; + charybdis::Proto ircd_proto; /* Core message handlers */ rfc1459::Away message_away; diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 2af72ed4c..922083587 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -25,319 +25,316 @@ static Anope::string UplinkSID; -class HybridProto : public IRCDProto + +ServiceBot *hybrid::Proto::FindIntroduced() { - ServiceBot *FindIntroduced() - { - ServiceBot *bi = Config->GetClient("OperServ"); - if (bi && bi->introduced) - return bi; + ServiceBot *bi = Config->GetClient("OperServ"); + if (bi && bi->introduced) + return bi; - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + { + User *u = it->second; + if (u->type == UserType::BOT) { - User *u = it->second; - if (u->type == UserType::BOT) - { - bi = anope_dynamic_static_cast<ServiceBot *>(u); - if (bi->introduced) - return bi; - } + bi = anope_dynamic_static_cast<ServiceBot *>(u); + if (bi->introduced) + return bi; } - - return NULL; } - void SendSVSKill(const MessageSource &source, User *u, const Anope::string &buf) override - { - IRCDProto::SendSVSKill(source, u, buf); - u->KillInternal(source, buf); - } + return NULL; +} - public: - HybridProto(Module *creator) : IRCDProto(creator, "Hybrid 8.2.x") - { - DefaultPseudoclientModes = "+oi"; - CanSVSNick = true; - CanSVSHold = true; - CanSVSJoin = true; - CanSNLine = true; - CanSQLine = true; - CanSQLineChannel = true; - CanSZLine = true; - CanCertFP = true; - CanSetVHost = true; - RequiresID = true; - MaxModes = 6; - } +void hybrid::Proto::SendSVSKill(const MessageSource &source, User *u, const Anope::string &buf) +{ + IRCDProto::SendSVSKill(source, u, buf); + u->KillInternal(source, buf); +} - void SendInvite(const MessageSource &source, Channel *c, User *u) override - { - Uplink::Send(source, "INVITE", u->GetUID(), c->name, c->creation_time); - } +hybrid::Proto::Proto(Module *creator) : IRCDProto(creator, "Hybrid 8.2.x") +{ + DefaultPseudoclientModes = "+oi"; + CanSVSNick = true; + CanSVSHold = true; + CanSVSJoin = true; + CanSNLine = true; + CanSQLine = true; + CanSQLineChannel = true; + CanSZLine = true; + CanCertFP = true; + CanSetVHost = true; + RequiresID = true; + MaxModes = 6; +} - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "NOTICE", "$$" + dest->GetName(), msg); - } +void hybrid::Proto::SendInvite(const MessageSource &source, Channel *c, User *u) +{ + Uplink::Send(source, "INVITE", u->GetUID(), c->name, c->creation_time); +} - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "PRIVMSG", "$$" + dest->GetName(), msg); - } +void hybrid::Proto::SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "NOTICE", "$$" + dest->GetName(), msg); +} - void SendSQLine(User *, XLine *x) override - { - Uplink::Send(FindIntroduced(), "RESV", "*", x->GetExpires() ? x->GetExpires() - Anope::CurTime : 0, x->GetMask(), x->GetReason()); - } +void hybrid::Proto::SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "PRIVMSG", "$$" + dest->GetName(), msg); +} - void SendSGLineDel(XLine *x) override - { - Uplink::Send(Config->GetClient("OperServ"), "UNXLINE", "*", x->GetMask()); - } +void hybrid::Proto::SendSQLine(User *, XLine *x) +{ + Uplink::Send(FindIntroduced(), "RESV", "*", x->GetExpires() ? x->GetExpires() - Anope::CurTime : 0, x->GetMask(), x->GetReason()); +} - void SendSGLine(User *, XLine *x) override - { - Uplink::Send(Config->GetClient("OperServ"), "XLINE", "*", x->GetMask(), x->GetExpires() ? x->GetExpires() - Anope::CurTime : 0, x->GetReason()); - } +void hybrid::Proto::SendSGLineDel(XLine *x) +{ + Uplink::Send(Config->GetClient("OperServ"), "UNXLINE", "*", x->GetMask()); +} - void SendSZLineDel(XLine *x) override - { - Uplink::Send(Config->GetClient("OperServ"), "UNDLINE", "*", x->GetHost()); - } +void hybrid::Proto::SendSGLine(User *, XLine *x) +{ + Uplink::Send(Config->GetClient("OperServ"), "XLINE", "*", x->GetMask(), x->GetExpires() ? x->GetExpires() - Anope::CurTime : 0, x->GetReason()); +} - void SendSZLine(User *, XLine *x) override - { - /* Calculate the time left before this would expire, capping it at 2 days */ - time_t timeleft = x->GetExpires() - Anope::CurTime; +void hybrid::Proto::SendSZLineDel(XLine *x) +{ + Uplink::Send(Config->GetClient("OperServ"), "UNDLINE", "*", x->GetHost()); +} - if (timeleft > 172800 || !x->GetExpires()) - timeleft = 172800; +void hybrid::Proto::SendSZLine(User *, XLine *x) +{ + /* Calculate the time left before this would expire, capping it at 2 days */ + time_t timeleft = x->GetExpires() - Anope::CurTime; - Uplink::Send(Config->GetClient("OperServ"), "DLINE", "*", timeleft, x->GetHost(), x->GetReason()); - } + if (timeleft > 172800 || !x->GetExpires()) + timeleft = 172800; - void SendAkillDel(XLine *x) override - { - if (x->IsRegex() || x->HasNickOrReal()) - return; + Uplink::Send(Config->GetClient("OperServ"), "DLINE", "*", timeleft, x->GetHost(), x->GetReason()); +} - Uplink::Send(Config->GetClient("OperServ"), "UNKLINE", "*", x->GetUser(), x->GetHost()); - } +void hybrid::Proto::SendAkillDel(XLine *x) +{ + if (x->IsRegex() || x->HasNickOrReal()) + return; - void SendSQLineDel(XLine *x) override - { - Uplink::Send(Config->GetClient("OperServ"), "UNRESV", "*", x->GetMask()); - } + Uplink::Send(Config->GetClient("OperServ"), "UNKLINE", "*", x->GetUser(), x->GetHost()); +} + +void hybrid::Proto::SendSQLineDel(XLine *x) +{ + Uplink::Send(Config->GetClient("OperServ"), "UNRESV", "*", x->GetMask()); +} + +void hybrid::Proto::SendJoin(User *u, Channel *c, const ChannelStatus *status) +{ + /* + * Note that we must send our modes with the SJOIN and can not add them to the + * mode stacker because ircd-hybrid does not allow *any* client to op itself + */ + Uplink::Send("SJOIN", c->creation_time, c->name, "+" + c->GetModes(true, true), (status != NULL ? status->BuildModePrefixList() : "") + u->GetUID()); - void SendJoin(User *u, Channel *c, const ChannelStatus *status) override + /* And update our internal status for this user since this is not going through our mode handling system */ + if (status) { - /* - * Note that we must send our modes with the SJOIN and can not add them to the - * mode stacker because ircd-hybrid does not allow *any* client to op itself - */ - Uplink::Send("SJOIN", c->creation_time, c->name, "+" + c->GetModes(true, true), (status != NULL ? status->BuildModePrefixList() : "") + u->GetUID()); - - /* And update our internal status for this user since this is not going through our mode handling system */ - if (status) - { - ChanUserContainer *uc = c->FindUser(u); + ChanUserContainer *uc = c->FindUser(u); - if (uc) - uc->status = *status; - } + if (uc) + uc->status = *status; } +} - void SendAkill(User *u, XLine *x) override +void hybrid::Proto::SendAkill(User *u, XLine *x) +{ + if (x->IsRegex() || x->HasNickOrReal()) { - if (x->IsRegex() || x->HasNickOrReal()) + if (!u) { - if (!u) - { - /* - * No user (this akill was just added), and contains nick and/or realname. - * Find users that match and ban them. - */ - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - if (x->GetManager()->Check(it->second, x)) - this->SendAkill(it->second, x); - |
