diff options
Diffstat (limited to 'modules/protocol/unreal.cpp')
-rw-r--r-- | modules/protocol/unreal.cpp | 660 |
1 files changed, 326 insertions, 334 deletions
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 259a64c9c..4a4a0c4d0 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -28,405 +28,397 @@ static Anope::string UplinkSID; -class UnrealIRCdProto : public IRCDProto +unreal::Proto::Proto(Module *creator) : IRCDProto(creator, "UnrealIRCd 4") { - public: - UnrealIRCdProto(Module *creator) : IRCDProto(creator, "UnrealIRCd 4") - { - DefaultPseudoclientModes = "+Soiq"; - CanSVSNick = true; - CanSVSJoin = true; - CanSetVHost = true; - CanSetVIdent = true; - CanSNLine = true; - CanSQLine = true; - CanSZLine = true; - CanSVSHold = true; - CanCertFP = true; - RequiresID = true; - MaxModes = 12; - } + DefaultPseudoclientModes = "+Soiq"; + CanSVSNick = true; + CanSVSJoin = true; + CanSetVHost = true; + CanSetVIdent = true; + CanSNLine = true; + CanSQLine = true; + CanSZLine = true; + CanSVSHold = true; + CanCertFP = true; + RequiresID = true; + MaxModes = 12; +} - private: - /* SVSNOOP */ - void SendSVSNOOP(Server *server, bool set) override - { - Uplink::Send("SVSNOOP", server->GetSID(), set ? "+" : "-"); - } +/* SVSNOOP */ +void unreal::Proto::SendSVSNOOP(Server *server, bool set) +{ + Uplink::Send("SVSNOOP", server->GetSID(), set ? "+" : "-"); +} - void SendAkillDel(XLine *x) override - { - if (x->IsRegex() || x->HasNickOrReal()) - return; +void unreal::Proto::SendAkillDel(XLine *x) +{ + if (x->IsRegex() || x->HasNickOrReal()) + return; - /* 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->SendSZLineDel(x); - return; - } + IRCD->SendSZLineDel(x); + return; } - - Uplink::Send("TKL", "-", "G", x->GetUser(), x->GetHost(), x->GetBy()); } - void SendTopic(const MessageSource &source, Channel *c) override - { - Uplink::Send(source, "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic); - } + Uplink::Send("TKL", "-", "G", x->GetUser(), x->GetHost(), x->GetBy()); +} - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); - } +void unreal::Proto::SendTopic(const MessageSource &source, Channel *c) +{ + Uplink::Send(source, "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic); +} - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); - } +void unreal::Proto::SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); +} - void SendVhostDel(User *u) override - { - ServiceBot *HostServ = Config->GetClient("HostServ"); - u->RemoveMode(HostServ, "CLOAK"); - u->RemoveMode(HostServ, "VHOST"); - ModeManager::ProcessModes(); - u->SetMode(HostServ, "CLOAK"); - } +void unreal::Proto::SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); +} + +void unreal::Proto::SendVhostDel(User *u) +{ + ServiceBot *HostServ = Config->GetClient("HostServ"); + u->RemoveMode(HostServ, "CLOAK"); + u->RemoveMode(HostServ, "VHOST"); + ModeManager::ProcessModes(); + u->SetMode(HostServ, "CLOAK"); +} - void SendAkill(User *u, XLine *x) override +void unreal::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; - } - - XLine *old = x; - - if (old->GetManager()->HasEntry("*@" + u->host)) - 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; + } - /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - XLine *xl = Serialize::New<XLine *>(); - xl->SetMask("*@" + u->host); - xl->SetBy(old->GetBy()); - xl->SetExpires(old->GetExpires()); - xl->SetReason(old->GetReason()); - xl->SetID(old->GetID()); + XLine *old = x; - old->GetManager()->AddXLine(xl); - x = xl; + if (old->GetManager()->HasEntry("*@" + u->host)) + return; - Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); - } + /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ + XLine *xl = Serialize::New<XLine *>(); + xl->SetMask("*@" + u->host); + xl->SetBy(old->GetBy()); + xl->SetExpires(old->GetExpires()); + xl->SetReason(old->GetReason()); + xl->SetID(old->GetID()); - /* ZLine if we can instead */ - if (x->GetUser() == "*") - { - cidr a(x->GetHost()); - if (a.valid()) - { - IRCD->SendSZLine(u, x); - return; - } - } + old->GetManager()->AddXLine(xl); + x = xl; - // 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; - Uplink::Send("TKL", "+", "G", x->GetUser(), x->GetHost(), x->GetBy(), Anope::CurTime + timeleft, x->GetCreated(), x->GetReason()); + Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); } - void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override + /* ZLine if we can instead */ + if (x->GetUser() == "*") { - Uplink::Send(source, "SVSKILL", user->GetUID(), buf); - user->KillInternal(source, buf); + cidr a(x->GetHost()); + if (a.valid()) + { + IRCD->SendSZLine(u, x); + return; + } } - void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override - { - IRCMessage message(source, "SVS2MODE", u->GetUID()); - message.TokenizeAndPush(buf); - Uplink::SendMessage(message); - } + // 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; + Uplink::Send("TKL", "+", "G", x->GetUser(), x->GetHost(), x->GetBy(), Anope::CurTime + timeleft, x->GetCreated(), x->GetReason()); +} - void SendClientIntroduction(User *u) override - { - Anope::string modes = "+" + u->GetModes(); - Uplink::Send("UID", u->nick, 1, u->timestamp, u->GetIdent(), u->host, u->GetUID(), "*", modes, !u->vhost.empty() ? u->vhost : "*", !u->chost.empty() ? u->chost : "*", "*", u->realname); - } +void unreal::Proto::SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) +{ + Uplink::Send(source, "SVSKILL", user->GetUID(), buf); + user->KillInternal(source, buf); +} - /* SERVER name hop descript */ - /* Unreal 3.2 actually sends some info about itself in the descript area */ - void SendServer(Server *server) override - { - if (!server->GetSID().empty() && server == Me) - Uplink::Send("SERVER", server->GetName(), server->GetHops() + 1, server->GetDescription()); - else - Uplink::Send("SID", server->GetName(), server->GetHops() + 1, server->GetSID(), server->GetDescription()); - } +void unreal::Proto::SendMode(const MessageSource &source, User *u, const Anope::string &buf) +{ + IRCMessage message(source, "SVS2MODE", u->GetUID()); + message.TokenizeAndPush(buf); + Uplink::SendMessage(message); +} - /* JOIN */ - void SendJoin(User *user, Channel *c, const ChannelStatus *status) override - { - Uplink::Send(Me, "SJOIN", c->creation_time, c->name, user->GetUID()); - 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; - } - } +void unreal::Proto::SendClientIntroduction(User *u) +{ + Anope::string modes = "+" + u->GetModes(); + Uplink::Send("UID", u->nick, 1, u->timestamp, u->GetIdent(), u->host, u->GetUID(), "*", modes, !u->vhost.empty() ? u->vhost : "*", !u->chost.empty() ? u->chost : "*", "*", u->realname); +} - /* unsqline - */ - void SendSQLineDel(XLine *x) override - { - Uplink::Send("UNSQLINE", x->GetMask()); - } +/* SERVER name hop descript */ +/* Unreal 3.2 actually sends some info about itself in the descript area */ +void unreal::Proto::SendServer(Server *server) +{ + if (!server->GetSID().empty() && server == Me) + Uplink::Send("SERVER", server->GetName(), server->GetHops() + 1, server->GetDescription()); + else + Uplink::Send("SID", server->GetName(), server->GetHops() + 1, server->GetSID(), server->GetDescription()); +} - /* SQLINE */ - /* - ** - Unreal will translate this to TKL for us - ** - */ - void SendSQLine(User *, XLine *x) override +/* JOIN */ +void unreal::Proto::SendJoin(User *user, Channel *c, const ChannelStatus *status) +{ + Uplink::Send(Me, "SJOIN", c->creation_time, c->name, user->GetUID()); + if (status) { - Uplink::Send("SQLINE", x->GetMask(), x->GetReason()); - } + /* 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(); - /* Functions that use serval cmd functions */ + 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); - void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override - { - if (!vIdent.empty()) - Uplink::Send(Me, "CHGIDENT", u->GetUID(), vIdent); - if (!vhost.empty()) - Uplink::Send(Me, "CHGHOST", u->GetUID(), vhost); + if (uc != NULL) + uc->status = cs; } +} - void SendConnect() override - { - /* - NICKv2 = Nick Version 2 - VHP = Sends hidden host - UMODE2 = sends UMODE2 on user modes - NICKIP = Sends IP on NICK - SJ3 = Supports SJOIN - NOQUIT = No Quit - TKLEXT = Extended TKL we don't use it but best to have it - MLOCK = Supports the MLOCK server command - VL = Version Info - SID = SID/UID mode - */ - Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password); - Uplink::Send("PROTOCTL", "NICKv2", "VHP", "UMODE2", "NICKIP", "SJOIN", "SJOIN2", "SJ3", "NOQUIT", "TKLEXT", "MLOCK", "SID"); - Uplink::Send("PROTOCTL", "EAUTH=" + Me->GetName() + ",,,Anope-" + Anope::VersionShort()); - Uplink::Send("PROTOCTL", "SID=" + Me->GetSID()); - SendServer(Me); - } +/* unsqline +*/ +void unreal::Proto::SendSQLineDel(XLine *x) +{ + Uplink::Send("UNSQLINE", x->GetMask()); +} - /* SVSHOLD - set */ - void SendSVSHold(const Anope::string &nick, time_t t) override - { - Uplink::Send("TKL", "+", "Q", "H", nick, Me->GetName(), Anope::CurTime + t, Anope::CurTime, "Being held for registered user"); - } +/* SQLINE */ +/* +** - Unreal will translate this to TKL for us +** +*/ +void unreal::Proto::SendSQLine(User *, XLine *x) +{ + Uplink::Send("SQLINE", x->GetMask(), x->GetReason()); +} - /* SVSHOLD - release */ - void SendSVSHoldDel(const Anope::string &nick) override - { - Uplink::Send("TKL", "-", "Q", "*", nick, Me->GetName()); - } +/* Functions that use serval cmd functions */ - /* UNSGLINE */ +void unreal::Proto::SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) +{ + if (!vIdent.empty()) + Uplink::Send(Me, "CHGIDENT", u->GetUID(), vIdent); + if (!vhost.empty()) + Uplink::Send(Me, "CHGHOST", u->GetUID(), vhost); +} + +void unreal::Proto::SendConnect() +{ /* - * SVSNLINE - :realname mask + NICKv2 = Nick Version 2 + VHP = Sends hidden host + UMODE2 = sends UMODE2 on user modes + NICKIP = Sends IP on NICK + SJ3 = Supports SJOIN + NOQUIT = No Quit + TKLEXT = Extended TKL we don't use it but best to have it + MLOCK = Supports the MLOCK server command + VL = Version Info + SID = SID/UID mode */ - void SendSGLineDel(XLine *x) override - { - Uplink::Send("SVSNLINE", "-", x->GetMask()); - } + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password); + Uplink::Send("PROTOCTL", "NICKv2", "VHP", "UMODE2", "NICKIP", "SJOIN", "SJOIN2", "SJ3", "NOQUIT", "TKLEXT", "MLOCK", "SID"); + Uplink::Send("PROTOCTL", "EAUTH=" + Me->GetName() + ",,,Anope-" + Anope::VersionShort()); + Uplink::Send("PROTOCTL", "SID=" + Me->GetSID()); + SendServer(Me); +} - /* UNSZLINE */ - void SendSZLineDel(XLine *x) override - { - Uplink::Send("TKL", "-", "Z", "*", x->GetHost(), x->GetBy()); - } +/* SVSHOLD - set */ +void unreal::Proto::SendSVSHold(const Anope::string &nick, time_t t) +{ + Uplink::Send("TKL", "+", "Q", "H", nick, Me->GetName(), Anope::CurTime + t, Anope::CurTime, "Being held for registered user"); +} - /* 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; - Uplink::Send("TKL", "+", "Z", "*", x->GetHost(), x->GetBy(), Anope::CurTime + timeleft, x->GetCreated(), x->GetReason()); - } +/* SVSHOLD - release */ +void unreal::Proto::SendSVSHoldDel(const Anope::string &nick) +{ + Uplink::Send("TKL", "-", "Q", "*", nick, Me->GetName()); +} - /* SGLINE */ - /* - * SVSNLINE + reason_where_is_space :realname mask with spaces - */ - void SendSGLine(User *, XLine *x) override - { - Anope::string edited_reason = x->GetReason(); - edited_reason = edited_reason.replace_all_cs(" ", "_"); - Uplink::Send("SVSNLINE", "+", edited_reason, x->GetMask()); - } +/* UNSGLINE */ +/* + * SVSNLINE - :realname mask +*/ +void unreal::Proto::SendSGLineDel(XLine *x) +{ + Uplink::Send("SVSNLINE", "-", x->GetMask()); +} - /* svsjoin - parv[0] - sender - parv[1] - nick to make join - parv[2] - channel to join - parv[3] - (optional) channel key(s) - */ - /* In older Unreal SVSJOIN and SVSNLINE tokens were mixed so SVSJOIN and SVSNLINE are broken - when coming from a none TOKEN'd server - */ - void SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) override - { - if (!param.empty()) - Uplink::Send(source, "SVSJOIN", user->GetUID(), chan, param); - else - Uplink::Send(source, "SVSJOIN", user->GetUID(), chan); - } +/* UNSZLINE */ +void unreal::Proto::SendSZLineDel(XLine *x) +{ + Uplink::Send("TKL", "-", "Z", "*", x->GetHost(), x->GetBy()); +} - void SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) override - { - if (!param.empty()) - Uplink::Send(source, "SVSPART", user->GetUID(), chan, param); - else - Uplink::Send(source, "SVSPART", user->GetUID(), chan); - } +/* SZLINE */ +void unreal::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; + Uplink::Send("TKL", "+", "Z", "*", x->GetHost(), x->GetBy(), Anope::CurTime + timeleft, x->GetCreated(), x->GetReason()); +} - void SendSWhois(const MessageSource &source, const Anope::string &who, const Anope::string &mask) override - { - Uplink::Send(source, "SWHOIS", who, mask); - } +/* SGLINE */ +/* + * SVSNLINE + reason_where_is_space :realname mask with spaces +*/ +void unreal::Proto::SendSGLine(User *, XLine *x) +{ + Anope::string edited_reason = x->GetReason(); + edited_reason = edited_reason.replace_all_cs(" ", "_"); + Uplink::Send("SVSNLINE", "+", edited_reason, x->GetMask()); +} - void SendEOB() override - { - Uplink::Send(Me, "EOS"); - } +/* svsjoin + parv[0] - sender + parv[1] - nick to make join + parv[2] - channel to join + parv[3] - (optional) channel key(s) +*/ +void unreal::Proto::SendSVSJoin(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) +{ + if (!param.empty()) + Uplink::Send(source, "SVSJOIN", user->GetUID(), chan, param); + else + Uplink::Send(source, "SVSJOIN", user->GetUID(), chan); +} - bool IsNickValid(const Anope::string &nick) override - { - if (nick.equals_ci("ircd") || nick.equals_ci("irc")) - return false; +void unreal::Proto::SendSVSPart(const MessageSource &source, User *user, const Anope::string &chan, const Anope::string ¶m) +{ + if (!param.empty()) + Uplink::Send(source, "SVSPART", user->GetUID(), chan, param); + else + Uplink::Send(source, "SVSPART", user->GetUID(), chan); +} - return IRCDProto::IsNickValid(nick); - } +void unreal::Proto::SendSWhois(const MessageSource &source, const Anope::string &who, const Anope::string &mask) +{ + Uplink::Send(source, "SWHOIS", who, mask); +} - bool IsChannelValid(const Anope::string &chan) override - { - if (chan.find(':') != Anope::string::npos) - return false; +void unreal::Proto::SendEOB() +{ + Uplink::Send(Me, "EOS"); +} - return IRCDProto::IsChannelValid(chan); - } +bool unreal::Proto::IsNickValid(const Anope::string &nick) +{ + if (nick.equals_ci("ircd") || nick.equals_ci("irc")) + return false; - bool IsExtbanValid(const Anope::string &mask) override - { - return mask.length() >= 4 && mask[0] == '~' && mask[2] == ':'; - } + return IRCDProto::IsNickValid(nick); +} - void SendLogin(User *u, NickServ::Nick *na) override - { - /* 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->GetAccount()->IsUnconfirmed()) - IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", na->GetAccount()->GetDisplay()); - else - IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", u->signon); - } +bool unreal::Proto::IsChannelValid(const Anope::string &chan) +{ + if (chan.find(':') != Anope::string::npos) + return false; - void SendLogout(User *u) override - { - IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 0"); - } + return IRCDProto::IsChannelValid(chan); +} - void SendChannel(Channel *c) override - { - /* Unreal does not support updating a channels TS without actually joining a user, - * so we will join and part us now - */ - ServiceBot *bi = c->ci->WhoSends(); - if (!bi) - ; - else if (c->FindUser(bi) == NULL) - { - bi->Join(c); - bi->Part(c); - } - else - { - bi->Part(c); - bi->Join(c); - } - } +bool unreal::Proto:: IsExtbanValid(const Anope::string &mask) +{ + return mask.length() >= 4 && mask[0] == '~' && mask[2] == ':'; +} - void SendSASLMessage(const SASL::Message &message) override - { - size_t p = message.target.find('!'); - if (p == Anope::string::npos) - return; +void unreal::Proto::SendLogin(User *u, NickServ::Nick *na) +{ + /* 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->GetAccount()->IsUnconfirmed()) + IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", na->GetAccount()->GetDisplay()); + else + IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", u->signon); +} - if (!message.ext.empty()) - Uplink::Send(ServiceBot::Find(message.source), "SASL", message.target.substr(0, p), message.target, message.type, message.data, message.ext); - else - Uplink::Send(ServiceBot::Find(message.source), "SASL", message.target.substr(0, p), message.target, message.type, message.data); - } +void unreal::Proto::SendLogout(User *u) +{ + IRCD->SendMode(Config->GetClient("NickServ"), u, "+d 0"); +} - void SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) override +void unreal::Proto::SendChannel(Channel *c) +{ + /* Unreal does not support updating a channels TS without actually joining a user, + * so we will join and part us now + */ + ServiceBot *bi = c->ci->WhoSends(); + if (!bi) + ; + else if (c->FindUser(bi) == NULL) { - size_t p = uid.find('!'); - if (p == Anope::string::npos) - return; - Uplink::Send(Me, "SVSLOGIN", uid.substr(0, p), uid, acc); + bi->Join(c); + bi->Part(c); } - - bool IsIdentValid(const Anope::string &ident) override + else { - if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) - return false; + bi->Part(c); + bi->Join(c); + } +} - for (unsigned i = 0; i < ident.length(); ++i) - { - const char &c = ident[i]; +void unreal::Proto::SendSASLMessage(const ::SASL::Message &message) +{ + size_t p = message.target.find('!'); + if (p == Anope::string::npos) + return; - if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-') - continue; + if (!message.ext.empty()) + Uplink::Send(ServiceBot::Find(message.source), "SASL", message.target.substr(0, p), message.target, message.type, message.data, message.ext); + else + Uplink::Send(ServiceBot::Find(message.source), "SASL", message.target.substr(0, p), message.target, message.type, message.data); +} - if (c == '-' || c == '.' || c == '_') - continue; +void unreal::Proto::SendSVSLogin(const Anope::string &uid, const Anope::string &acc, const Anope::string &vident, const Anope::string &vhost) +{ + size_t p = uid.find('!'); + if (p == Anope::string::npos) + return; + Uplink::Send(Me, "SVSLOGIN", uid.substr(0, p), uid, acc); +} - return false; - } +bool unreal::Proto::IsIdentValid(const Anope::string &ident) +{ + if (ident.empty() || ident.length() > Config->GetBlock("networkinfo")->Get<unsigned>("userlen")) + return false; - return true; + for (unsigned i = 0; i < ident.length(); ++i) + { + const char &c = ident[i]; + + if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '-') + continue; + + if (c == '-' || c == '.' || c == '_') + continue; + + return false; } -}; + + return true; +} class UnrealExtBan : public ChannelModeVirtual<ChannelModeList> { @@ -1120,7 +1112,7 @@ class ProtoUnreal : public Module , public EventHook<Event::DelChan> , public EventHook<Event::MLockEvents> { - UnrealIRCdProto ircd_proto; + unreal::Proto ircd_proto; ServiceReference<ModeLocks> mlocks; /* Core message handlers */ |