diff options
Diffstat (limited to 'modules/protocol/ratbox.cpp')
-rw-r--r-- | modules/protocol/ratbox.cpp | 216 |
1 files changed, 98 insertions, 118 deletions
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 04f1314cc..592002578 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -25,146 +25,126 @@ static Anope::string UplinkSID; -class RatboxProto : public IRCDProto +ServiceBot *ratbox::Proto::FindIntroduced() { - ServiceReference<IRCDProto> hybrid; // XXX + ServiceBot *bi = Config->GetClient("OperServ"); + if (bi && bi->introduced) + return bi; - ServiceBot *FindIntroduced() + for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { - ServiceBot *bi = Config->GetClient("OperServ"); - if (bi && bi->introduced) - return bi; - - 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; - } - - public: - RatboxProto(Module *creator) : IRCDProto(creator, "Ratbox 3.0+") - , hybrid("hybrid") - { - DefaultPseudoclientModes = "+oiS"; - CanSNLine = true; - CanSQLine = true; - CanSQLineChannel = true; - CanSZLine = true; - RequiresID = true; - MaxModes = 4; } - void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKill(source, targ, reason); } - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); } - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } - void SendSGLine(User *u, XLine *x) override { hybrid->SendSGLine(u, x); } - void SendSGLineDel(XLine *x) override { hybrid->SendSGLineDel(x); } - void SendAkill(User *u, XLine *x) override { hybrid->SendAkill(u, x); } - void SendAkillDel(XLine *x) override { hybrid->SendAkillDel(x); } - void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { hybrid->SendJoin(user, c, status); } - void SendServer(Server *server) override { hybrid->SendServer(server); } - void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override { hybrid->SendMode(source, u, buf); } - void SendChannel(Channel *c) override { hybrid->SendChannel(c); } - bool IsIdentValid(const Anope::string &ident) override { return hybrid->IsIdentValid(ident); } - - void SendGlobops(const MessageSource &source, const Anope::string &buf) override - { - Uplink::Send(source, "OPERWALL", buf); - } + return NULL; +} - void SendConnect() override - { - Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); - - /* - QS - Can handle quit storm removal - EX - Can do channel +e exemptions - CHW - Can do channel wall @# - IE - Can do invite exceptions - GLN - Can do GLINE message - KNOCK - supports KNOCK - TB - supports topic burst - ENCAP - supports ENCAP - */ - Uplink::Send("CAPAB", "QS EX CHW IE GLN TB ENCAP"); - - /* Make myself known to myself in the serverlist */ - 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", 6, 6, 0, Anope::CurTime); - } +ratbox::Proto::Proto(Module *creator) : IRCDProto(creator, "Ratbox 3.0+") + , hybrid("hybrid") +{ + DefaultPseudoclientModes = "+oiS"; + CanSNLine = true; + CanSQLine = true; + CanSQLineChannel = true; + CanSZLine = true; + RequiresID = true; + MaxModes = 4; +} - void SendClientIntroduction(User *u) override - { - Anope::string modes = "+" + u->GetModes(); - Uplink::Send(Me, "UID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, 0, u->GetUID(), u->realname); - } +void ratbox::Proto::SendGlobops(const MessageSource &source, const Anope::string &buf) +{ + Uplink::Send(source, "OPERWALL", buf); +} - void SendLogin(User *u, NickServ::Nick *na) override - { - if (na->GetAccount()->IsUnconfirmed()) - return; +void ratbox::Proto::SendConnect() +{ + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "TS", 6, Me->GetSID()); + + /* + QS - Can handle quit storm removal + EX - Can do channel +e exemptions + CHW - Can do channel wall @# + IE - Can do invite exceptions + GLN - Can do GLINE message + KNOCK - supports KNOCK + TB - supports topic burst + ENCAP - supports ENCAP + */ + Uplink::Send("CAPAB", "QS EX CHW IE GLN TB ENCAP"); + + /* Make myself known to myself in the serverlist */ + 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", 6, 6, 0, Anope::CurTime); +} - Uplink::Send(Me, "ENCAP", "*", "SU", u->GetUID(), na->GetAccount()->GetDisplay()); - } +void ratbox::Proto::SendClientIntroduction(User *u) +{ + Anope::string modes = "+" + u->GetModes(); + Uplink::Send(Me, "UID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, 0, u->GetUID(), u->realname); +} - void SendLogout(User *u) override - { - Uplink::Send(Me, "ENCAP", "*", "SU", u->GetUID()); - } +void ratbox::Proto::SendLogin(User *u, NickServ::Nick *na) +{ + if (na->GetAccount()->IsUnconfirmed()) + return; - void SendTopic(const MessageSource &source, Channel *c) override - { - ServiceBot *bi = source.GetBot(); - bool needjoin = c->FindUser(bi) == NULL; + Uplink::Send(Me, "ENCAP", "*", "SU", u->GetUID(), na->GetAccount()->GetDisplay()); +} - if (needjoin) - { - ChannelStatus status; +void ratbox::Proto::SendLogout(User *u) +{ + Uplink::Send(Me, "ENCAP", "*", "SU", u->GetUID()); +} - status.AddMode('o'); - bi->Join(c, &status); - } +void ratbox::Proto::SendTopic(const MessageSource &source, Channel *c) +{ + ServiceBot *bi = source.GetBot(); + bool needjoin = c->FindUser(bi) == NULL; - IRCDProto::SendTopic(source, c); + if (needjoin) + { + ChannelStatus status; - if (needjoin) - bi->Part(c); + status.AddMode('o'); + bi->Join(c, &status); } - void SendSQLine(User *, XLine *x) override - { - /* Calculate the time left before this would expire, capping it at 2 days */ - time_t timeleft = x->GetExpires() - Anope::CurTime; + IRCDProto::SendTopic(source, c); - if (timeleft > 172800 || !x->GetExpires()) - timeleft = 172800; + if (needjoin) + bi->Part(c); +} - Uplink::Send(FindIntroduced(), "ENCAP", "*", "RESV", timeleft, x->GetMask(), 0, x->GetReason()); - } +void ratbox::Proto::SendSQLine(User *, XLine *x) +{ + /* Calculate the time left before this would expire, capping it at 2 days */ + time_t timeleft = x->GetExpires() - Anope::CurTime; - void SendSQLineDel(XLine *x) override - { - Uplink::Send(Config->GetClient("OperServ"), "ENCAP", "*", "UNRESV", x->GetMask()); - } + if (timeleft > 172800 || !x->GetExpires()) + timeleft = 172800; -}; + Uplink::Send(FindIntroduced(), "ENCAP", "*", "RESV", timeleft, x->GetMask(), 0, x->GetReason()); +} + +void ratbox::Proto::SendSQLineDel(XLine *x) +{ + Uplink::Send(Config->GetClient("OperServ"), "ENCAP", "*", "UNRESV", x->GetMask()); +} // Debug: Received: :00BAAAAAB ENCAP * LOGIN Adam void ratbox::Encap::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) @@ -262,7 +242,7 @@ void ratbox::UID::Run(MessageSource &source, const std::vector<Anope::string> &p class ProtoRatbox : public Module { - RatboxProto ircd_proto; + ratbox::Proto ircd_proto; /* Core message handlers */ rfc1459::Away message_away; |