diff options
Diffstat (limited to 'modules/protocol')
-rw-r--r-- | modules/protocol/bahamut.cpp | 126 | ||||
-rw-r--r-- | modules/protocol/inspircd-ts6.h | 32 | ||||
-rw-r--r-- | modules/protocol/inspircd11.cpp | 71 | ||||
-rw-r--r-- | modules/protocol/inspircd12.cpp | 54 | ||||
-rw-r--r-- | modules/protocol/inspircd20.cpp | 29 | ||||
-rw-r--r-- | modules/protocol/ngircd.cpp | 141 | ||||
-rw-r--r-- | modules/protocol/plexus.cpp | 214 | ||||
-rw-r--r-- | modules/protocol/ratbox.cpp | 193 | ||||
-rw-r--r-- | modules/protocol/unreal32.cpp | 111 |
9 files changed, 421 insertions, 550 deletions
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index a8cdef155..5da7c4785 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -75,18 +75,14 @@ class BahamutIRCdProto : public IRCDProto { void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) { - if (buf.empty()) - return; if (Capab.HasFlag(CAPAB_TSMODE)) - send_cmd(source->nick, "MODE %s 0 %s", dest->name.c_str(), buf.c_str()); + send_cmd(source->nick, "MODE %s %ld %s", dest->name.c_str(), static_cast<long>(dest->creation_time), buf.c_str()); else send_cmd(source->nick, "MODE %s %s", dest->name.c_str(), buf.c_str()); } void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) { - if (buf.empty()) - return; send_cmd(bi ? bi->nick : Config->ServerName, "SVSMODE %s %ld %s", u->nick.c_str(), static_cast<long>(u->timestamp), buf.c_str()); } @@ -163,22 +159,13 @@ class BahamutIRCdProto : public IRCDProto } /* JOIN - SJOIN */ - void SendJoin(const BotInfo *user, const Anope::string &channel, time_t chantime) + void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status) { - send_cmd(user->nick, "SJOIN %ld %s", static_cast<long>(chantime), channel.c_str()); - } - - void SendJoin(BotInfo *user, const ChannelContainer *cc) - { - SendJoin(user, cc->chan->name, cc->chan->creation_time); - for (std::map<char, ChannelMode *>::iterator it = ModeManager::ChannelModesByChar.begin(), it_end = ModeManager::ChannelModesByChar.end(); it != it_end; ++it) - { - if (cc->Status->HasFlag(it->second->Name)) - { - cc->chan->SetMode(user, it->second, user->nick); - } - } - cc->chan->SetModes(user, false, "%s", cc->chan->GetModes(true, true).c_str()); + send_cmd(user->nick, "SJOIN %ld %s", static_cast<long>(c->creation_time), c->name.c_str()); + if (status) + for (size_t i = CMODE_BEGIN + 1; i != CMODE_END; ++i) + if (status->HasFlag(static_cast<ChannelModeName>(i))) + c->SetMode(user, static_cast<ChannelModeName>(i), user->nick, false); } void SendAkill(const XLine *x) @@ -210,8 +197,6 @@ class BahamutIRCdProto : public IRCDProto void SendNoticeChanopsInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) { - if (buf.empty()) - return; send_cmd("", "NOTICE @%s :%s", dest->name.c_str(), buf.c_str()); } @@ -259,9 +244,9 @@ class BahamutIRCdProto : public IRCDProto ircdproto->SendMode(NickServ, u, "+d %d", u->timestamp); } - void SendChannel(Channel *c, const Anope::string &modes) + void SendChannel(Channel *c) { - send_cmd("", "SJOIN %ld %s %s :", static_cast<long>(c->creation_time), c->name.c_str(), modes.c_str()); + send_cmd("", "SJOIN %ld %s %s :", static_cast<long>(c->creation_time), c->name.c_str(), get_mlock_modes(c->ci, true).c_str()); } }; @@ -270,13 +255,10 @@ class BahamutIRCdMessage : public IRCdMessage public: bool OnMode(const Anope::string &source, const std::vector<Anope::string> ¶ms) { - if (params.size() < 3) - return true; - - if (params[0][0] == '#' || params[0][0] == '&') + if (params.size() > 2 && (params[0][0] == '#' || params[0][0] == '&')) do_cmode(source, params[0], params[2], params[1]); - else - do_umode(source, params[0], params[1]); + else if (params.size() > 1) + do_umode(params[0], params[1]); return true; } @@ -303,7 +285,11 @@ class BahamutIRCdMessage : public IRCdMessage { if (params.size() != 2) { - 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, params[8], "", "", params[3]); + /* Currently bahamut has no ipv6 support */ + sockaddrs ip; + ip.ntop(AF_INET, params[8].c_str()); + + 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]); if (user) { NickAlias *na; @@ -554,43 +540,6 @@ bool ChannelModeFlood::IsValid(const Anope::string &value) const return false; } -static void AddModes() -{ - /* Add user modes */ - ModeManager::AddUserMode(new UserMode(UMODE_SERV_ADMIN, "UMODE_SERV_ADMIN", 'A')); - ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, "UMODE_REGPRIV", 'R')); - ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, "UMODE_ADMIN", 'a')); - ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i')); - ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o')); - ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, "UMODE_REGISTERED", 'r')); - ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, "UMODE_SNOMASK", 's')); - ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w')); - ModeManager::AddUserMode(new UserMode(UMODE_DEAF, "UMODE_DEAF", 'd')); - - /* b/e/I */ - ModeManager::AddChannelMode(new ChannelModeBan('b')); - - /* v/h/o/a/q */ - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, "CMODE_VOICE", 'v', '+')); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, "CMODE_OP", 'o', '@')); - - /* Add channel modes */ - ModeManager::AddChannelMode(new ChannelMode(CMODE_BLOCKCOLOR, "CMODE_BLOCKCOLOR", 'c')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, "CMODE_INVITE", 'i')); - ModeManager::AddChannelMode(new ChannelModeFlood('f')); - ModeManager::AddChannelMode(new ChannelModeKey('k')); - ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, "CMODE_LIMIT", 'l')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, "CMODE_MODERATED", 'm')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, "CMODE_NOEXTERNAL", 'n')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, "CMODE_PRIVATE", 'p')); - ModeManager::AddChannelMode(new ChannelModeRegistered('r')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, "CMODE_SECRET", 's')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, "CMODE_TOPIC", 't')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_REGMODERATED, "CMODE_REGMODERATED", 'M')); - ModeManager::AddChannelMode(new ChannelModeOper('O')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_REGISTEREDONLY, "CMODE_REGISTEREDONLY", 'R')); -} - class ProtoBahamut : public Module { Message message_svsmode, message_cs, message_hs, message_ms, message_ns, message_os, message_burst; @@ -598,6 +547,43 @@ class ProtoBahamut : public Module BahamutIRCdProto ircd_proto; BahamutIRCdMessage ircd_message; + void AddModes() + { + /* Add user modes */ + ModeManager::AddUserMode(new UserMode(UMODE_SERV_ADMIN, "UMODE_SERV_ADMIN", 'A')); + ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, "UMODE_REGPRIV", 'R')); + ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, "UMODE_ADMIN", 'a')); + ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i')); + ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o')); + ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, "UMODE_REGISTERED", 'r')); + ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, "UMODE_SNOMASK", 's')); + ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w')); + ModeManager::AddUserMode(new UserMode(UMODE_DEAF, "UMODE_DEAF", 'd')); + + /* b/e/I */ + ModeManager::AddChannelMode(new ChannelModeBan('b')); + + /* v/h/o/a/q */ + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, "CMODE_VOICE", 'v', '+')); + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, "CMODE_OP", 'o', '@')); + + /* Add channel modes */ + ModeManager::AddChannelMode(new ChannelMode(CMODE_BLOCKCOLOR, "CMODE_BLOCKCOLOR", 'c')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, "CMODE_INVITE", 'i')); + ModeManager::AddChannelMode(new ChannelModeFlood('f')); + ModeManager::AddChannelMode(new ChannelModeKey('k')); + ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, "CMODE_LIMIT", 'l')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, "CMODE_MODERATED", 'm')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, "CMODE_NOEXTERNAL", 'n')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, "CMODE_PRIVATE", 'p')); + ModeManager::AddChannelMode(new ChannelModeRegistered('r')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, "CMODE_SECRET", 's')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, "CMODE_TOPIC", 't')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_REGMODERATED, "CMODE_REGMODERATED", 'M')); + ModeManager::AddChannelMode(new ChannelModeOper('O')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_REGISTEREDONLY, "CMODE_REGISTEREDONLY", 'R')); + } + public: ProtoBahamut(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), message_svsmode("SVSMODE", OnMode), message_cs("CS", event_cs), message_hs("HS", event_hs), @@ -607,12 +593,12 @@ class ProtoBahamut : public Module this->SetAuthor("Anope"); this->SetType(PROTOCOL); - AddModes(); - pmodule_ircd_var(myIrcd); pmodule_ircd_proto(&this->ircd_proto); pmodule_ircd_message(&this->ircd_message); + this->AddModes(); + ModuleManager::Attach(I_OnUserNickChange, this); } diff --git a/modules/protocol/inspircd-ts6.h b/modules/protocol/inspircd-ts6.h index 1dff475b8..3642a75f4 100644 --- a/modules/protocol/inspircd-ts6.h +++ b/modules/protocol/inspircd-ts6.h @@ -77,8 +77,6 @@ class InspIRCdTS6Proto : public IRCDProto void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) { - if (buf.empty()) - return; send_cmd(bi ? bi->GetUID() : Config->Numeric, "MODE %s %s", u->GetUID().c_str(), buf.c_str()); } @@ -107,14 +105,17 @@ class InspIRCdTS6Proto : public IRCDProto } /* JOIN */ - void SendJoin(const BotInfo *user, const Anope::string &channel, time_t chantime) + void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status) { - send_cmd(Config->Numeric, "FJOIN %s %ld + :,%s", channel.c_str(), static_cast<long>(chantime), user->GetUID().c_str()); - } - - void SendJoin(BotInfo *user, const ChannelContainer *cc) - { - send_cmd(Config->Numeric, "FJOIN %s %ld +%s :%s,%s", cc->chan->name.c_str(), static_cast<long>(cc->chan->creation_time), cc->chan->GetModes(true, true).c_str(), cc->Status->BuildCharPrefixList().c_str(), user->GetUID().c_str()); + send_cmd(Config->Numeric, "FJOIN %s %ld +%s :,%s", c->name.c_str(), static_cast<long>(c->creation_time), c->GetModes(true, true).c_str(), user->GetUID().c_str()); + /* Note that we can send this with the FJOIN but choose not to + * because the mode stacker will handle this and probably will + * merge these modes with +nrt and other mlocked modes + */ + if (status) + for (size_t i = CMODE_BEGIN + 1; i != CMODE_END; ++i) + if (status->HasFlag(static_cast<ChannelModeName>(i))) + c->SetMode(user, static_cast<ChannelModeName>(i), user->nick, false); } /* UNSQLINE */ @@ -218,9 +219,9 @@ class InspIRCdTS6Proto : public IRCDProto send_cmd(Config->Numeric, "METADATA %s accountname :", u->GetUID().c_str()); } - void SendChannel(Channel *c, const Anope::string &modes) + void SendChannel(Channel *c) { - send_cmd(Config->Numeric, "FJOIN %s %ld %s :", c->name.c_str(), static_cast<long>(c->creation_time), modes.c_str()); + send_cmd(Config->Numeric, "FJOIN %s %ld %s :", c->name.c_str(), static_cast<long>(c->creation_time), get_mlock_modes(c->ci, true).c_str()); } bool IsNickValid(const Anope::string &nick) @@ -247,18 +248,15 @@ class InspircdIRCdMessage : public IRCdMessage as it slightly breaks RFC1459 */ User *u = finduser(source); - User *u2 = finduser(params[0]); - // This can happen with server-origin modes. if (!u) - u = u2; - + u = finduser(params[0]); // if it's still null, drop it like fire. // most likely situation was that server introduced a nick which we subsequently akilled - if (!u || !u2) + if (!u) return true; - do_umode(u->nick, u2->nick, params[1]); + do_umode(u->nick, params[1]); } return true; diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp index 96867071c..c6dafc81a 100644 --- a/modules/protocol/inspircd11.cpp +++ b/modules/protocol/inspircd11.cpp @@ -120,15 +120,11 @@ class InspIRCdProto : public IRCDProto void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) { - if (buf.empty()) - return; send_cmd(source ? source->nick : Config->s_OperServ, "FMODE %s %u %s", dest->name.c_str(), static_cast<unsigned>(dest->creation_time), buf.c_str()); } void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) { - if (buf.empty()) - return; send_cmd(bi ? bi->nick : Config->ServerName, "MODE %s %s", u->nick.c_str(), buf.c_str()); } @@ -148,8 +144,6 @@ class InspIRCdProto : public IRCDProto void SendNoticeChanopsInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) { - if (buf.empty()) - return; send_cmd(Config->ServerName, "NOTICE @%s :%s", dest->name.c_str(), buf.c_str()); } @@ -160,22 +154,13 @@ class InspIRCdProto : public IRCDProto } /* JOIN */ - void SendJoin(const BotInfo *user, const Anope::string &channel, time_t chantime) - { - send_cmd(user->nick, "JOIN %s %ld", channel.c_str(), static_cast<long>(chantime)); - } - - void SendJoin(BotInfo *user, const ChannelContainer *cc) + void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status) { - SendJoin(user, cc->chan->name, cc->chan->creation_time); - for (std::map<char, ChannelMode *>::iterator it = ModeManager::ChannelModesByChar.begin(), it_end = ModeManager::ChannelModesByChar.end(); it != it_end; ++it) - { - if (cc->Status->HasFlag(it->second->Name)) - { - cc->chan->SetMode(user, it->second, user->nick); - } - } - cc->chan->SetModes(user, false, "%s", cc->chan->GetModes(true, true).c_str()); + send_cmd(user->nick, "JOIN %s %ld", c->name.c_str(), static_cast<long>(c->creation_time)); + if (status) + for (size_t i = CMODE_BEGIN + 1; i != CMODE_END; ++i) + if (status->HasFlag(static_cast<ChannelModeName>(i))) + c->SetMode(user, static_cast<ChannelModeName>(i), user->nick, false); } /* UNSQLINE */ @@ -193,8 +178,6 @@ class InspIRCdProto : public IRCDProto /* SQUIT */ void SendSquit(const Anope::string &servname, const Anope::string &message) { - if (servname.empty() || message.empty()) - return; send_cmd(Config->ServerName, "SQUIT %s :%s", servname.c_str(), message.c_str()); } @@ -292,12 +275,7 @@ class InspircdIRCdMessage : public IRCdMessage if (params[0][0] == '#' || params[0][0] == '&') do_cmode(source, params[0], params[1], params[2]); else - { - /* InspIRCd lets opers change another - users modes - */ - do_umode(source, params[0], params[1]); - } + do_umode(params[0], params[1]); return true; } @@ -510,7 +488,7 @@ class InspircdIRCdMessage : public IRCdMessage } } } - else if (capab.find("PREIX=(") != Anope::string::npos) + else if (capab.find("PREFIX=(") != Anope::string::npos) { Anope::string modes(capab.begin() + 8, capab.begin() + capab.find(')')); Anope::string chars(capab.begin() + capab.find(')') + 1, capab.end()); @@ -625,6 +603,8 @@ class InspircdIRCdMessage : public IRCdMessage if (keep_their_modes) Status.push_back(cm); } + /* Erase the , */ + buf.erase(buf.begin()); User *u = finduser(buf); if (!u) @@ -876,25 +856,26 @@ bool ChannelModeFlood::IsValid(const Anope::string &value) const return false; } -static void AddModes() -{ - ModeManager::AddUserMode(new UserMode(UMODE_CALLERID, "UMODE_CALLERID", 'g')); - ModeManager::AddUserMode(new UserMode(UMODE_HELPOP, "UMODE_HELPOP", 'h')); - ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i')); - ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o')); - ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, "UMODE_REGISTERED", 'r')); - ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w')); - ModeManager::AddUserMode(new UserMode(UMODE_CLOAK, "UMODE_CLOAK", 'x')); -} - class ProtoInspIRCd : public Module { Message message_endburst, message_rsquit, message_svsmode, message_chghost, message_chgident, message_chgname, message_sethost, message_setident, message_setname, message_fmode, message_ftopic, message_opertype, - message_idle; + message_idle, message_fjoin; InspIRCdProto ircd_proto; InspircdIRCdMessage ircd_message; + + void AddModes() + { + ModeManager::AddUserMode(new UserMode(UMODE_CALLERID, "UMODE_CALLERID", 'g')); + ModeManager::AddUserMode(new UserMode(UMODE_HELPOP, "UMODE_HELPOP", 'h')); + ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i')); + ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o')); + ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, "UMODE_REGISTERED", 'r')); + ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w')); + ModeManager::AddUserMode(new UserMode(UMODE_CLOAK, "UMODE_CLOAK", 'x')); + } + public: ProtoInspIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), message_endburst("ENDBURST", event_endburst), message_rsquit("RSQUIT", event_rsquit), @@ -903,19 +884,19 @@ class ProtoInspIRCd : public Module message_sethost("SETHOST", event_sethost), message_setident("SETIDENT", event_setident), message_setname("SETNAME", event_setname), message_fmode("FMODE", event_fmode), message_ftopic("FTOPIC", event_ftopic), message_opertype("OPERTYPE", event_opertype), - message_idle("IDLE", event_idle) + message_idle("IDLE", event_idle), message_fjoin("FJOIN", OnSJoin) { this->SetAuthor("Anope"); this->SetType(PROTOCOL); - AddModes(); - pmodule_ircd_var(myIrcd); pmodule_ircd_proto(&this->ircd_proto); pmodule_ircd_message(&this->ircd_message); Capab.SetFlag(CAPAB_NOQUIT); + this->AddModes(); + ModuleManager::Attach(I_OnUserNickChange, this); } diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index eb84601ef..958709b06 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -230,34 +230,6 @@ bool event_sethost(const Anope::string &source, const std::vector<Anope::string> return true; } -/* - * [Nov 03 22:09:58.176252 2009] debug: Received: :964 UID 964AAAAAC 1225746297 w00t2 localhost testnet.user w00t 127.0.0.1 1225746302 +iosw +ACGJKLNOQcdfgjklnoqtx :Robin Burchell <w00t@inspircd.org> - * 0: uid - * 1: ts - * 2: nick - * 3: host - * 4: dhost - * 5: ident - * 6: ip - * 7: signon - * 8+: modes and params -- IMPORTANT, some modes (e.g. +s) may have parameters. So don't assume a fixed position of realname! - * last: realname - */ - -bool event_uid(const Anope::string &source, const std::vector<Anope::string> ¶ms) -{ - Server *s = Server::Find(source); - time_t ts = convertTo<time_t>(params[1]); - - Anope::string modes = params[8]; - for (unsigned i = 9; i < params.size() - 1; ++i) - modes += " " + params[i]; - User *user = do_nick("", params[2], params[5], params[3], s->GetName(), params[params.size() - 1], ts, params[6], params[4], params[0], modes); - if (user && user->server->IsSynced()) - validate_user(user); - - return true; -} bool event_chghost(const Anope::string &source, const std::vector<Anope::string> ¶ms) { @@ -297,11 +269,11 @@ bool event_metadata(const Anope::string &source, const std::vector<Anope::string } } -/* - * possible incoming ssl_cert messages: - * Received: :409 METADATA 409AAAAAA ssl_cert :vTrSe c38070ce96e41cc144ed6590a68d45a6 <...> <...> - * Received: :409 METADATA 409AAAAAC ssl_cert :vTrSE Could not get peer certificate: error:00000000:lib(0):func(0):reason(0) - */ + /* + * possible incoming ssl_cert messages: + * Received: :409 METADATA 409AAAAAA ssl_cert :vTrSe c38070ce96e41cc144ed6590a68d45a6 <...> <...> + * Received: :409 METADATA 409AAAAAC ssl_cert :vTrSE Could not get peer certificate: error:00000000:lib(0):func(0):reason(0) + */ else if (params[1].equals_cs("ssl_cert")) { User *u = finduser(params[0]); @@ -342,15 +314,27 @@ bool event_endburst(const Anope::string &source, const std::vector<Anope::string class Inspircd12IRCdMessage : public InspircdIRCdMessage { public: + /* + * [Nov 03 22:09:58.176252 2009] debug: Received: :964 UID 964AAAAAC 1225746297 w00t2 localhost testnet.user w00t 127.0.0.1 1225746302 +iosw +ACGJKLNOQcdfgjklnoqtx :Robin Burchell <w00t@inspircd.org> + * 0: uid + * 1: ts + * 2: nick + * 3: host + * 4: dhost + * 5: ident + * 6: ip + * 7: signon + * 8+: modes and params -- IMPORTANT, some modes (e.g. +s) may have parameters. So don't assume a fixed position of realname! + * last: realname + */ bool OnUID(const Anope::string &source, const std::vector<Anope::string> ¶ms) { - Server *s = Server::Find(source); time_t ts = convertTo<time_t>(params[1]); Anope::string modes = params[8]; for (unsigned i = 9; i < params.size() - 1; ++i) modes += " " + params[i]; - User *user = do_nick("", params[2], params[5], params[3], s->GetName(), params[params.size() - 1], ts, params[6], params[4], params[0], modes); + User *user = do_nick("", params[2], params[5], params[3], source, params[params.size() - 1], ts, params[6], params[4], params[0], modes); if (user && user->server->IsSynced()) validate_user(user); diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 93928b318..e1e339635 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -105,8 +105,7 @@ bool event_opertype(const Anope::string &source, const std::vector<Anope::string { /* opertype is equivalent to mode +o because servers dont do this directly */ - User *u; - u = finduser(source); + User *u = finduser(source); if (u && !u->HasMode(UMODE_OPER)) { std::vector<Anope::string> newparams; @@ -174,9 +173,8 @@ bool event_rsquit(const Anope::string &source, const std::vector<Anope::string> bool event_setname(const Anope::string &source, const std::vector<Anope::string> ¶ms) { - User *u; + User *u = finduser(source); - u = finduser(source); if (!u) { Log(LOG_DEBUG) << "SETNAME for nonexistent user " << source; @@ -189,9 +187,8 @@ bool event_setname(const Anope::string &source, const std::vector<Anope::string> bool event_chgname(const Anope::string &source, const std::vector<Anope::string> ¶ms) { - User *u; + User *u = finduser(source); - u = finduser(source); if (!u) { Log(LOG_DEBUG) << "FNAME for nonexistent user " << source; @@ -204,9 +201,8 @@ bool event_chgname(const Anope::string &source, const std::vector<Anope::string> bool event_setident(const Anope::string &source, const std::vector<Anope::string> ¶ms) { - User *u; + User *u = finduser(source); - u = finduser(source); if (!u) { Log(LOG_DEBUG) << "SETIDENT for nonexistent user " << source; @@ -233,9 +229,8 @@ bool event_chgident(const Anope::string &source, const std::vector<Anope::string bool event_sethost(const Anope::string &source, const std::vector<Anope::string> ¶ms) { - User *u; + User *u = finduser(source); - u = finduser(source); if (!u) { Log(LOG_DEBUG) << "SETHOST for nonexistent user " << source; @@ -249,6 +244,7 @@ bool event_sethost(const Anope::string &source, const std::vector<Anope::string> bool event_chghost(const Anope::string &source, const std::vector<Anope::string> ¶ms) { User *u = finduser(source); + if (!u) { Log(LOG_DEBUG) << "FHOST for nonexistent user " << source; @@ -283,11 +279,11 @@ bool event_metadata(const Anope::string &source, const std::vector<Anope::string } } -/* - * possible incoming ssl_cert messages: - * Received: :409 METADATA 409AAAAAA ssl_cert :vTrSe c38070ce96e41cc144ed6590a68d45a6 <...> <...> - * Received: :409 METADATA 409AAAAAC ssl_cert :vTrSE Could not get peer certificate: error:00000000:lib(0):func(0):reason(0) - */ + /* + * possible incoming ssl_cert messages: + * Received: :409 METADATA 409AAAAAA ssl_cert :vTrSe c38070ce96e41cc144ed6590a68d45a6 <...> <...> + * Received: :409 METADATA 409AAAAAC ssl_cert :vTrSE Could not get peer certificate: error:00000000:lib(0):func(0):reason(0) + */ else if (params[1].equals_cs("ssl_cert")) { User *u = finduser(params[0]); @@ -343,13 +339,12 @@ class Inspircd20IRCdMessage : public InspircdIRCdMessage */ bool OnUID(const Anope::string &source, const std::vector<Anope::string> ¶ms) { - Server *s = Server::Find(source); time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0; Anope::string modes = params[8]; for (unsigned i = 9; i < params.size() - 1; ++i) modes += Anope::string(" ") + params[i]; - User *user = do_nick("", params[2], params[5], params[3], s->GetName(), params[params.size() - 1], ts, params[6], params[4], params[0], modes); + User *user = do_nick("", params[2], params[5], params[3], source, params[params.size() - 1], ts, params[6], params[4], params[0], modes); if (user && user->server->IsSynced()) validate_user(user); diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 91cb53415..85383dbf2 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -42,9 +42,6 @@ IRCDVar myIrcd[] = { /* PASS */ class ngIRCdProto : public IRCDProto { - /* ngIRCd does not use the following functions, but we need the - * empty functions in this class or the file will not compile - */ void SendAkill(const XLine *x) { } void SendAkillDel(const XLine*) { } void SendSQLine(const XLine*) { } @@ -54,20 +51,16 @@ class ngIRCdProto : public IRCDProto void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) { - if (source) - send_cmd(source->nick, "WALLOPS :%s", buf.c_str()); - else - send_cmd(Config->ServerName, "WALLOPS :%s", buf.c_str()); - } - - void SendJoin(const BotInfo *user, const Anope::string &channel, time_t chantime) - { - send_cmd(user->nick, "JOIN %s", channel.c_str()); + send_cmd(source ? source->nick : Config->ServerName, "WALLOPS :%s", buf.c_str()); } - void SendJoin(const BotInfo *user, const ChannelContainer *cc) + void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status) { - send_cmd(user->nick, "JOIN %s", cc->chan->name.c_str()); + send_cmd(user->nick, "JOIN %s", c->name.c_str()); + if (status) + for (size_t i = CMODE_BEGIN + 1; i != CMODE_END; ++i) + if (status->HasFlag(static_cast<ChannelModeName>(i))) + c->SetMode(user, static_cast<ChannelModeName>(i), user->nick, false); } void SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf) @@ -87,7 +80,7 @@ class ngIRCdProto : public IRCDProto /* Make myself known to myself in the serverlist */ SendServer(Me); /* finish the enhanced server handshake and register the connection */ - send_cmd(Config->ServerName, "376 * :End of MOTD command"); + this->SendNumeric(Config->ServerName, 376, "*", ":End of MOTD command"); } // Received: :dev.anope.de NICK DukeP 1 ~DukePyro p57ABF9C9.dip.t-dialin.net 1 +i :DukePyrolator @@ -105,12 +98,6 @@ class ngIRCdProto : public IRCDProto send_cmd(bi->nick, "PART %s", chan->name.c_str()); } - void SendNumericInternal(const Anope::string &, int numeric, const Anope::string &dest, const Anope::string &buf) - { - // This might need to be set in the call to SendNumeric instead of here, will review later -- CyberBotX - send_cmd(Config->ServerName, "%03d %s %s", numeric, dest.c_str(), buf.c_str()); - } - void SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf) { send_cmd(bi ? bi->nick : Config->ServerName, "MODE %s %s", dest->name.c_str(), buf.c_str()); @@ -118,8 +105,6 @@ class ngIRCdProto : public IRCDProto void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) { - if (buf.empty()) - return; send_cmd(bi ? bi->nick : Config->ServerName, "MODE %s %s", u->nick.c_str(), buf.c_str()); } @@ -142,33 +127,20 @@ class ngIRCdProto : public IRCDProto send_cmd(source->nick, "INVITE %s %s", nick.c_str(), chan.c_str()); } - void SendChannel(Channel *c, const Anope::string &modes) + void SendChannel(Channel *c) { - send_cmd(Config->ServerName, "CHANINFO %s %s", c->name.c_str(), modes.c_str()); + send_cmd(Config->ServerName, "CHANINFO %s %s", c->name.c_str(), get_mlock_modes(c->ci, true).c_str()); } - - bool IsNickValid(const Anope::string &nick) - { - /* TS6 Save extension -Certus */ - if (isdigit(nick[0])) - return false; - return true; - } - void SendTopic(BotInfo *bi, Channel *c) { send_cmd(bi->nick, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str()); } - }; class ngIRCdIRCdMessage : public IRCdMessage { public: - /* ngIRCd uses NJOIN instead of SJOIN, but we still need an - * empty function in this class or the file will not compile - */ - bool OnSJoin(const Anope::string&, const std::vector<Anope::string>&) { return true; } + bool OnSJoin(const Anope::string&, const std::vector<Anope::string>&) { return false; } /* * Received: :dev.anope.de MODE #anope +b *!*@*aol* @@ -185,7 +157,7 @@ class ngIRCdIRCdMessage : public IRCdMessage if (params[0][0] == '#' || params[0][0] == '&') do_cmode(source, params[0], modes, ""); else - do_umode(source, params[0], params[1]); + do_umode(params[0], params[1]); return true; } @@ -255,20 +227,16 @@ class ngIRCdIRCdMessage : public IRCdMessage { if (!params.empty()) { - Anope::string channel, mode; - size_t pos; - pos = params[0].find('\7'); + size_t pos = params[0].find('\7'); if (pos != Anope::string::npos) { - channel = params[0].substr(0, pos); - mode += '+' + params[0].substr(pos, params[0].length()) + " " + source; + Anope::string channel = params[0].substr(0, pos); + Anope::string mode = '+' + params[0].substr(pos, params[0].length()) + " " + source; do_join(source, channel, ""); do_cmode(source, channel, mode, ""); } else - { do_join(source, params[0], ""); - } } return true; } @@ -283,13 +251,11 @@ bool event_chaninfo(const Anope::string &source, const std::vector<Anope::string { Channel *c = findchan(params[0]); - Anope::string modes; - if (!c) c = new Channel(params[0]); - modes = params[1]; - + Anope::string modes = params[1]; + if (params.size() == 3) { c->ChangeTopicInternal(source, params[2], Anope::CurTime); @@ -436,42 +402,6 @@ bool event_376(const Anope::string &source, const std::vector<Anope::string> &pa } -static void AddModes() -{ - /* Add user modes */ - ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, "UMODE_ADMIN", 'a')); - ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i')); - ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o')); - ModeManager::AddUserMode(new UserMode(UMODE_RESTRICTED, "UMODE_RESTRICTED", 'r')); - ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, "UMODE_SNOMASK", 's')); - ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w')); - ModeManager::AddUserMode(new UserMode(UMODE_CLOAK, "UMODE_CLOAK", 'x')); - -// channel modes: biIklmnoPstvz - /* b/e/I */ - ModeManager::AddChannelMode(new ChannelModeBan('b')); - ModeManager::AddChannelMode(new ChannelModeInvex('I')); - - /* v/h/o/a/q */ - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, "CMODE_VOICE", 'v', '+')); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, "CMODE_OP", 'o', '@')); - - /* Add channel modes */ - ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, "CMODE_INVITE", 'i')); - ModeManager::AddChannelMode(new ChannelModeKey('k')); - ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, "CMODE_LIMIT", 'l')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, "CMODE_MODERATED", 'm')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, "CMODE_NOEXTERNAL", 'n')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_PERM, "CMODE_PERM", 'P')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, "CMODE_SECRET", 's')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, "CMODE_TOPIC", 't')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_SSL, "CMODE_SSL", 'z')); - - return; -} - - - class ProtongIRCd : public Module { Message message_kick, message_pass, message_njoin, message_chaninfo, message_005, @@ -479,6 +409,39 @@ class ProtongIRCd : public Module ngIRCdProto ircd_proto; ngIRCdIRCdMessage ircd_message; + + void AddModes() + { + /* Add user modes */ + ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, "UMODE_ADMIN", 'a')); + ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i')); + ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o')); + ModeManager::AddUserMode(new UserMode(UMODE_RESTRICTED, "UMODE_RESTRICTED", 'r')); + ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, "UMODE_SNOMASK", 's')); + ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w')); + ModeManager::AddUserMode(new UserMode(UMODE_CLOAK, "UMODE_CLOAK", 'x')); + + /* b/e/I */ + ModeManager::AddChannelMode(new ChannelModeBan('b')); + ModeManager::AddChannelMode(new ChannelModeInvex('I')); + + /* v/h/o/a/q */ + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, "CMODE_VOICE", 'v', '+')); + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, "CMODE_OP", 'o', '@')); + + /* Add channel modes */ + // channel modes: biIklmnoPstvz + ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, "CMODE_INVITE", 'i')); + ModeManager::AddChannelMode(new ChannelModeKey('k')); + ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, "CMODE_LIMIT", 'l')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, "CMODE_MODERATED", 'm')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, "CMODE_NOEXTERNAL", 'n')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_PERM, "CMODE_PERM", 'P')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, "CMODE_SECRET", 's')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, "CMODE_TOPIC", 't')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_SSL, "CMODE_SSL", 'z')); + } + public: ProtongIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), message_kick("KICK", event_kick), message_pass("PASS", event_pass), @@ -490,11 +453,11 @@ class ProtongIRCd : public Module Capab.SetFlag(CAPAB_QS); - AddModes(); - pmodule_ircd_var(myIrcd); pmodule_ircd_proto(&this->ircd_proto); pmodule_ircd_message(&this->ircd_message); + + this->AddModes(); } }; diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index a1fad8d5b..98ca554e9 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -89,10 +89,7 @@ class PlexusProto : public IRCDProto { void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) { - if (source) - send_cmd(source->GetUID(), "OPERWALL :%s", buf.c_str()); - else - send_cmd(Config->Numeric, "OPERWALL :%s", buf.c_str()); + send_cmd(source ? source->GetUID() : Config->Numeric, "OPERWALL :%s", buf.c_str()); } void SendSQLine(const XLine *x) @@ -123,14 +120,13 @@ class PlexusProto : public IRCDProto send_cmd(Config->Numeric, "UNRESV * %s", x->Mask.c_str()); } - void SendJoin(const BotInfo *user, const Anope::string &channel, time_t chantime) + void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status) { - send_cmd(Config->Numeric, "SJOIN %ld %s + :%s", static_cast<long>(chantime), channel.c_str(), user->GetUID().c_str()); - } - - void SendJoin(const BotInfo *user, const ChannelContainer *cc) - { - send_cmd(Config->Numeric, "SJOIN %ld %s +%s :%s%s", static_cast<long>(cc->chan->creation_time), cc->chan->name.c_str(), cc->chan->GetModes(true, true).c_str(), cc->Status->BuildModePrefixList().c_str(), user->GetUID().c_str()); + send_cmd(Config->Numeric, "SJOIN %ld %s +%s :%s", static_cast<long>(c->creation_time), c->name.c_str(), c->GetModes(true, true).c_str(), user->GetUID().c_str()); + if (status) + for (size_t i = CMODE_BEGIN + 1; i != CMODE_END; ++i) + if (status->HasFlag(static_cast<ChannelModeName>(i))) + c->SetMode(user, static_cast<ChannelModeName>(i), user->nick, false); } void SendAkill(const XLine *x) @@ -180,12 +176,6 @@ class PlexusProto : public IRCDProto send_cmd(bi->GetUID(), "PART %s", chan->name.c_str()); } - void SendNumericInternal(const Anope::string &, int numeric, const Anope::string &dest, const Anope::string &buf) - { - // This might need to be set in the call to SendNumeric instead of here, will review later -- CyberBotX - send_cmd(Config->Numeric, "%03d %s %s", numeric, dest.c_str(), buf.c_str()); - } - void SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf) { if (bi) @@ -229,23 +219,14 @@ class PlexusProto : public IRCDProto send_cmd(Config->Numeric, "ENCAP * SU %s", u->GetUID().c_str()); } - bool IsNickValid(const Anope::string &nick) - { - /* TS6 Save extension -Certus */ - if (isdigit(nick[0])) - return false; - - return true; - } - void SendTopic(BotInfo *bi, Channel *c) { send_cmd(bi->GetUID(), "ENCAP * TOPIC %s %s %lu :%s", c->name.c_str(), c->topic_setter.c_str(), static_cast<unsigned long>(c->topic_time + 1), c->topic.c_str()); } - void SendChannel(Channel *c, const Anope::string &modes) + void SendChannel(Channel *c) { - send_cmd(Config->Numeric, "SJOIN %ld %s %s :", static_cast<long>(c->creation_time), c->name.c_str(), modes.c_str()); + send_cmd(Config->Numeric, "SJOIN %ld %s %s :", static_cast<long>(c->creation_time), c->name.c_str(), get_mlock_modes(c->ci, true).c_str()); } }; @@ -260,13 +241,7 @@ class PlexusIRCdMessage : public IRCdMessage if (params[0][0] == '#' || params[0][0] == '&') do_cmode(source, params[0], params[2], params[1]); else - { - User *u = finduser(source); - User *u2 = finduser(params[0]); - if (!u || !u2) - return true; - do_umode(u->nick, u2->nick, params[1]); - } + do_umode(params[0], params[1]); return true; } @@ -287,8 +262,11 @@ class PlexusIRCdMessage : public IRCdMessage */ bool OnUID(const Anope::string &source, const std::vector<Anope::string> ¶ms) { - /* Source is always the server */ - User *user = do_nick("", params[0], params[4], params[9], source, params[10], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[6], params[5], params[7], params[3]); + /* An IP of 0 means the user is spoofed */ + Anope::string ip = params[6]; + if (ip == "0") + ip.clear(); + User *user = do_nick("", params[0], params[4], params[9], source, params[10], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, ip, params[5], params[7], params[3]); if (user && user->server->IsSynced()) validate_user(user); @@ -442,20 +420,23 @@ class PlexusIRCdMessage : public IRCdMessage bool event_tburst(const Anope::string &source, const std::vector<Anope::string> ¶ms) { - if (params.size() != 4) + // :rizon.server TBURST 1298674830 #lol 1298674833 Adam!Adam@i.has.a.spoof :lol + if (params.size() < 4) return true; - Anope::string setter = myStrGetToken(params[2], '!', 0); - time_t topic_time = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime; - Channel *c = findchan(params[0]); + Channel *c = findchan(params[1]); if (!c) { Log() << "TOPIC " << params[3] << " for nonexistent channel " << params[0]; return true; } + else if (c->creation_time < convertTo<time_t>(params[0])) + return true; - c->ChangeTopicInternal(setter, params.size() > 3 ? params[3] : "", topic_time); + Anope::string setter = myStrGetToken(params[3], '!', 0); + time_t topic_time = Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime; + c->ChangeTopicInternal(setter, params.size() > 4 ? params[4] : "", topic_time); return true; } @@ -477,13 +458,7 @@ bool event_mode(const Anope::string &source, const std::vector<Anope::string> &p if (params[0][0] == '#' || params[0][0] == '&') do_cmode(source, params[0], params[2], params[1]); else - { - User *u = finduser(source); - User *u2 = finduser(params[0]); - if (!u || !u2) - return true; - do_umode(u->nick, u2->nick, params[1]); - } + do_umode(params[0], params[1]); return true; } @@ -536,13 +511,13 @@ bool event_encap(const Anope::string &source, const std::vector<Anope::string> & { if (params.size() < 4) return true; -/* - * Received: :dev.anope.de ENCAP * SU DukePyrolator DukePyrolator - * params[0] = * - * params[1] = SU - * params[2] = nickname - * params[3] = account - */ + /* + * Received: :dev.anope.de ENCAP * SU DukePyrolator DukePyrolator + * params[0] = * + * params[1] = SU + * params[2] = nickname + * params[3] = account + */ else if (params[1].equals_cs("SU")) { User *u = finduser(params[2]); @@ -555,13 +530,14 @@ bool event_encap(const Anope::string &source, const std::vector<Anope::string> & u->SetMode(NickServ, UMODE_REGISTERED); } } -/* - * Received: :dev.anope.de ENCAP * CERTFP DukePyrolator :3F122A9CC7811DBAD3566BF2CEC3009007C0868F - * params[0] = * - * params[1] = CERTFP - * params[2] = nickname - * params[3] = fingerprint - */ + + /* + * Received: :dev.anope.de ENCAP * CERTFP DukePyrolator :3F122A9CC7811DBAD3566BF2CEC3009007C0868F + * params[0] = * + * params[1] = CERTFP + * params[2] = nickname + * params[3] = fingerprint + */ else if (params[1].equals_cs("CERTFP")) { User *u = finduser(params[2]); @@ -591,58 +567,6 @@ bool event_eob(const Anope::string &source, const std::vector<Anope::string> &pa return true; } -static void AddModes() -{ - /* Add user modes */ - ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, "UMODE_ADMIN", 'a')); - ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i')); - ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o')); - ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, "UMODE_SNOMASK", 's')); - ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w')); - ModeManager::AddUserMode(new UserMode(UMODE_DEAF, "UMODE_DEAF", 'D')); - ModeManager::AddUserMode(new UserMode(UMODE_SOFTCALLERID, "UMODE_SOFTCALLERID", 'G')); - ModeManager::AddUserMode(new UserMode(UMODE_NETADMIN, "UMODE_NETADMIN", 'M')); - ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, "UMODE_REGPRIV", 'R')); - ModeManager::AddUserMode(new UserMode(UMODE_SSL, "UMODE_SSL", 'S')); - ModeManager::AddUserMode(new UserMode(UMODE_WEBIRC, "UMODE_WEBIRC", 'W')); - ModeManager::AddUserMode(new UserMode(UMODE_CALLERID, "UMODE_CALLERID", 'g')); - ModeManager::AddUserMode(new UserMode(UMODE_PRIV, "UMODE_PRIV", 'p')); - ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, "UMODE_REGISTERED", 'r')); - ModeManager::AddUserMode(new UserMode(UMODE_CLOAK, "UMODE_CLOAK", 'x')); - - /* b/e/I */ - ModeManager::AddChannelMode(new ChannelModeBan('b')); - ModeManager::AddChannelMode(new ChannelModeExcept('e')); - ModeManager::AddChannelMode(new ChannelModeInvex('I')); - - /* l/k */ - ModeManager::AddChannelMode(new ChannelModeKey('k')); - ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, "CMODE_LIMIT", 'l')); - - /* v/h/o/a/q */ - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, "CMODE_VOICE", 'v', '+')); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_HALFOP, "CMODE_HALFOP", 'h', '%')); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, "CMODE_OP", 'o', '@')); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_PROTECT, "CMODE_PROTECT", 'a', '&')); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OWNER, "CMODE_OWNER", 'q', '~')); - - /* Add channel modes */ - ModeManager::AddChannelMode(new ChannelMode(CMODE_BANDWIDTH, "CMODE_BANDWIDTH", 'B')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_REGMODERATED, "CMODE_REGMODERATED", 'M')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_NONOTICE, "CMODE_NONOTICE", 'N')); - ModeManager::AddChannelMode(new ChannelModeOper('O')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_REGISTEREDONLY, "CMODE_REGISTEREDONLY", 'R')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_SSL, "CMODE_SSL", 'S')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_BLOCKCOLOR, "CMODE_BLOCKCOLOR", 'c')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, "CMODE_INVITE", 'i')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, "CMODE_MODERATED", 'm')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, "CMODE_NOEXTERNAL", 'n')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, "CMODE_PRIVATE", 'p')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, "CMODE_SECRET", 's')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, "CMODE_TOPIC", 't')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_PERM, "CMODE_PERM", 'z')); -} - class ProtoPlexus : public Module { Message message_tmode, message_bmask, message_pass, @@ -651,21 +575,75 @@ class ProtoPlexus : public Module PlexusProto ircd_proto; PlexusIRCdMessage ircd_message; + + void AddModes() + { + /* Add user modes */ + ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, "UMODE_ADMIN", 'a')); + ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i')); + ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o')); + ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, "UMODE_SNOMASK", 's')); + ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w')); + ModeManager::AddUserMode(new UserMode(UMODE_DEAF, "UMODE_DEAF", 'D')); + ModeManager::AddUserMode(new UserMode(UMODE_SOFTCALLERID, "UMODE_SOFTCALLERID", 'G')); + ModeManager::AddUserMode(new UserMode(UMODE_NETADMIN, "UMODE_NETADMIN", 'M')); + ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, "UMODE_REGPRIV", 'R')); + ModeManager::AddUserMode(new UserMode(UMODE_SSL, "UMODE_SSL", 'S')); + ModeManager::AddUserMode(new UserMode(UMODE_WEBIRC, "UMODE_WEBIRC", 'W')); + ModeManager::AddUserMode(new UserMode(UMODE_CALLERID, "UMODE_CALLERID", 'g')); + ModeManager::AddUserMode(new UserMode(UMODE_PRIV, "UMODE_PRIV", 'p')); + ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, "UMODE_REGISTERED", 'r')); + ModeManager::AddUserMode(new UserMode(UMODE_CLOAK, "UMODE_CLOAK", 'x')); + + /* b/e/I */ + ModeManager::AddChannelMode(new ChannelModeBan('b')); + ModeManager::AddChannelMode(new ChannelModeExcept('e')); + ModeManager::AddChannelMode(new ChannelModeInvex('I')); + + /* l/k */ + ModeManager::AddChannelMode(new ChannelModeKey('k')); + ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, "CMODE_LIMIT", 'l')); + + /* v/h/o/a/q */ + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, "CMODE_VOICE", 'v', '+')); + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_HALFOP, "CMODE_HALFOP", 'h', '%')); + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, "CMODE_OP", 'o', '@')); + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_PROTECT, "CMODE_PROTECT", 'a', '&')); + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OWNER, "CMODE_OWNER", 'q', '~')); + + /* Add channel modes */ + ModeManager::AddChannelMode(new ChannelMode(CMODE_BANDWIDTH, "CMODE_BANDWIDTH", 'B')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_REGMODERATED, "CMODE_REGMODERATED", 'M')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_NONOTICE, "CMODE_NONOTICE", 'N')); + ModeManager::AddChannelMode(new ChannelModeOper('O')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_REGISTEREDONLY, "CMODE_REGISTEREDONLY", 'R')); + + ModeManager::AddChannelMode(new ChannelMode(CMODE_SSL, "CMODE_SSL", 'S')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_BLOCKCOLOR, "CMODE_BLOCKCOLOR", 'c')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, "CMODE_INVITE", 'i')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, "CMODE_MODERATED", 'm')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, "CMODE_NOEXTERNAL", 'n')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, "CMODE_PRIVATE", 'p')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, "CMODE_SECRET", 's')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, "CMODE_TOPIC", 't')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_PERM, "CMODE_PERM", 'z')); + } + public: ProtoPlexus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), message_tmode("TMODE", event_tmode), message_bmask("BMASK", event_bmask), - message_pass("PASS", event_pass), message_tb("TB", event_tburst), + message_pass("PASS", event_pass), message_tb("TBURST", event_tburst), message_sid("SID", event_sid), message_encap("ENCAP", event_encap), message_eob("EOB", event_eob) { this->SetAuthor("Anope"); this->SetType(PROTOCOL); - AddModes(); - pmodule_ircd_var(myIrcd); pmodule_ircd_proto(&this->ircd_proto); pmodule_ircd_message(&this->ircd_message); + + this->AddModes(); } }; diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index c7797c166..1eaafc144 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -16,7 +16,7 @@ static Anope::string TS6UPLINK; IRCDVar myIrcd[] = { {"Ratbox 2.0+", /* ircd name */ - "+oi", /* Modes used by pseudoclients */ + "+oiS", /* Modes used by pseudoclients */ 0, /* SVSNICK */ 0, /* Vhost */ 1, /* Supports SNlines */ @@ -79,7 +79,7 @@ void ratbox_cmd_svsinfo() */ void ratbox_cmd_capab() { - send_cmd("", "CAPAB :QS EX CHW IE KLN GLN KNOCK TB UNKLN CLUSTER ENCAP"); + send_cmd("", "CAPAB :QS EX CHW IE KLN GLN KNOCK TB UNKLN CLUSTER ENCAP TS6"); } /* PASS */ @@ -92,10 +92,7 @@ class RatboxProto : public IRCDProto { void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) { - if (source) - send_cmd(source->GetUID(), "OPERWALL :%s", buf.c_str()); - else - send_cmd(Config->Numeric, "OPERWALL :%s", buf.c_str()); + send_cmd(source ? source->GetUID() : Config->Numeric, "OPERWALL :%s", buf.c_str()); } void SendSQLine(const XLine *x) @@ -126,14 +123,20 @@ class RatboxProto : public IRCDProto send_cmd(Config->Numeric, "UNRESV * %s", x->Mask.c_str()); } - void SendJoin(const BotInfo *user, const Anope::string &channel, time_t chantime) - { - send_cmd("", "SJOIN %ld %s + :%s", static_cast<long>(chantime), channel.c_str(), user->GetUID().c_str()); - } - - void SendJoin(const BotInfo *user, const ChannelContainer *cc) + void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status) { - send_cmd("", "SJOIN %ld %s +%s :%s%s", static_cast<long>(cc->chan->creation_time), cc->chan->name.c_str(), cc->chan->GetModes(true, true).c_str(), cc->Status->BuildModePrefixList().c_str(), user->GetUID().c_str()); + /* Note that we must send our modes with the SJOIN and + * can not add them to the mode stacker because ratbox + * does not allow *any* client to op itself + */ + send_cmd("", "SJOIN %ld %s +%s :%s%s", static_cast<long>(c->creation_time), c->name.c_str(), c->GetModes(true, true).c_str(), status != NULL ? status->BuildModePrefixList().c_str() : "", user->GetUID().c_str()); + /* And update our internal status for this user since this is not going through our mode handling system */ + if (status != NULL) + { + UserContainer *uc = c->FindUser(user); + if (uc != NULL) + *uc->Status = *status; + } } void SendAkill(const XLine *x) @@ -176,24 +179,13 @@ class RatboxProto : public IRCDProto send_cmd(bi->GetUID(), "PART %s", chan->name.c_str()); } - void SendNumericInternal(const Anope::string &, int numeric, const Anope::string &dest, const Anope::string &buf) - { - // This might need to be set in the call to SendNumeric instead of here, will review later -- CyberBotX - send_cmd(Config->Numeric, "%03d %s %s", numeric, dest.c_str(), buf.c_str()); - } - void SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf) { - if (bi) - send_cmd(bi->GetUID(), "MODE %s %s", dest->name.c_str(), buf.c_str()); - else - send_cmd(Config->Numeric, "MODE %s %s", dest->name.c_str(), buf.c_str()); + send_cmd(bi ? bi->GetUID() : Config->Numeric, "MODE %s %s", dest->name.c_str(), buf.c_str()); } void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) { - if (buf.empty()) - return; send_cmd(bi ? bi->GetUID() : Config->Numeric, "SVSMODE %s %s", u->nick.c_str(), buf.c_str()); } @@ -227,9 +219,9 @@ class RatboxProto : public IRCDProto send_cmd(Config->Numeric, "ENCAP * SU %s", u->GetUID().c_str()); } - void SendChannel(Channel *c, const Anope::string &modes) + void SendChannel(Channel *c) { - send_cmd("", "SJOIN %ld %s %s :", static_cast<long>(c->creation_time), c->name.c_str(), modes.c_str()); + send_cmd("", "SJOIN %ld %s %s :", static_cast<long>(c->creation_time), c->name.c_str(), get_mlock_modes(c->ci, true).c_str()); } bool IsNickValid(const Anope::string &nick) @@ -248,27 +240,11 @@ class RatboxProto : public IRCDProto { ChannelStatus status; status.SetFlag(CMODE_OP); - ChannelContainer cc(c); - cc.Status = &status; - ircdproto->SendJoin(bi, &cc); + bi->Join(c, &status); } send_cmd(bi->GetUID(), "TOPIC %s :%s", c->name.c_str(), c->topic.c_str()); if (needjoin) - { - ircdproto->SendPart(bi, c, NULL); - } - } - - void SetAutoIdentificationToken(User *u) - { - - if (!u->Account()) - return; - - Anope::string svidbuf = stringify(u->timestamp); - - u->Account()->Shrink("authenticationtoken"); - u->Account()->Extend("authenticationtoken", new ExtensibleItemRegular<Anope::string>(svidbuf)); + bi->Part(c); } }; @@ -283,33 +259,17 @@ class RatboxIRCdMessage : public IRCdMessage if (params[0][0] == '#' || params[0][0] == '&') do_cmode(source, params[0], params[2], params[1]); else - { - User *u = finduser(source); - User *u2 = finduser(params[0]); - if (!u || !u2) - return true; - do_umode(u->nick, u2->nick, params[1]); - } + do_umode(params[0], params[1]); return true; } bool OnUID(const Anope::string &source, const std::vector<Anope::string> ¶ms) { - Server *s = Server::Find(source); /* Source is always the server */ - User *user = do_nick("", params[0], params[4], params[5], s->GetName(), params[8], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[6], "*", params[7], params[3]); - if (user) - { - NickAlias *na = findnick(user->nick); - Anope::string svidbuf; - if (na && na->nc->GetExtRegular("authenticationtoken", svidbuf) && svidbuf == params[2]) - { - user->Login(na->nc); - } - else - validate_user(user); - } + User *user = do_nick("", params[0], params[4], params[5], source, params[8], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[6], "*", params[7], params[3]); + if (user && user->server->IsSynced()) + validate_user(user); return true; } @@ -338,6 +298,7 @@ class RatboxIRCdMessage : public IRCdMessage do_server(source, params[0], Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, params[2], TS6UPLINK); else do_server(source, params[0], Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, params[2], ""); + ircdproto->SendPing(Config->ServerName, params[0]); return true; } @@ -490,9 +451,40 @@ bool event_kick(const Anope::string &source, const std::vector<Anope::string> &p bool event_sid(const Anope::string &source, const std::vector<Anope::string> ¶ms) { /* :42X SID trystan.nomadirc.net 2 43X :ircd-ratbox test server */ + do_server(source, params[0], Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, params[3], params[2]); + ircdproto->SendPing(Config->ServerName, params[0]); + return true; +} + +// Debug: Received: :00BAAAAAB ENCAP * LOGIN Adam +bool event_encap(const Anope::string &source, const std::vector<Anope::string> ¶ms) +{ + if (params.size() > 2 && params[1] == "LOGIN") + { + User *u = finduser(source); + NickCore *nc = findcore(params[2]); + if (!u || !nc) + return true; + u->Login(nc); + } + + return true; +} + +bool event_pong(const Anope::string &source, const std::vector<Anope::string> ¶ms) +{ Server *s = Server::Find(source); + if (s && !s->IsSynced()) + { + s->Sync(false); - do_server(s->GetName(), params[0], Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, params[3], params[2]); + for (patricia_tree<User *, ci::ci_char_traits>::iterator it(UserListByNick); it.next();) + { + User *u = *it; + if (u->server == s && !u->IsIdentified()) + validate_user(u); + } + } return true; } @@ -536,55 +528,58 @@ bool event_bmask(const Anope::string &source, const std::vector<Anope::string> & return true; } -static void AddModes() -{ - /* Add user modes */ - ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, "UMODE_ADMIN", 'a')); - ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i')); - ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o')); - ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, "UMODE_SNOMASK", 's')); - ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w')); - - /* b/e/I */ - ModeManager::AddChannelMode(new ChannelModeBan('b')); - ModeManager::AddChannelMode(new ChannelModeExcept('e')); - ModeManager::AddChannelMode(new ChannelModeInvex('I')); - - /* v/h/o/a/q */ - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, "CMODE_VOICE", 'v', '+')); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, "CMODE_OP", 'o', '@')); - - /* Add channel modes */ - ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, "CMODE_INVITE", 'i')); - ModeManager::AddChannelMode(new ChannelModeKey('k')); - ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, "CMODE_LIMIT", 'l')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, "CMODE_MODERATED", 'm')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, "CMODE_NOEXTERNAL", 'n')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, "CMODE_PRIVATE", 'p')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, "CMODE_SECRET", 's')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, "CMODE_TOPIC", 't')); -} - class ProtoRatbox : public Module { - Message message_kick, message_tmode, message_bmask, message_pass, message_tb, message_sid; + Message message_kick, message_tmode, message_bmask, message_pass, message_tb, message_sid, message_encap, + message_pong; RatboxProto ircd_proto; RatboxIRCdMessage ircd_message; + + void AddModes() + { + /* Add user modes */ + ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, "UMODE_ADMIN", 'a')); + ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i')); + ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o')); + ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, "UMODE_SNOMASK", 's')); + ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w')); + + /* b/e/I */ + ModeManager::AddChannelMode(new ChannelModeBan('b')); + ModeManager::AddChannelMode(new ChannelModeExcept('e')); + ModeManager::AddChannelMode(new ChannelModeInvex('I')); + + /* v/h/o/a/q */ + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, "CMODE_VOICE", 'v', '+')); + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, "CMODE_OP", 'o', '@')); + + /* Add channel modes */ + ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, "CMODE_INVITE", 'i')); + ModeManager::AddChannelMode(new ChannelModeKey('k')); + ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, "CMODE_LIMIT", 'l')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, "CMODE_MODERATED", 'm')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, "CMODE_NOEXTERNAL", 'n')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, "CMODE_PRIVATE", 'p')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, "CMODE_SECRET", 's')); + ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, "CMODE_TOPIC", 't')); + } + public: ProtoRatbox(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), message_kick("KICK", event_kick), message_tmode("TMODE", event_tmode), message_bmask("BMASK", event_bmask), message_pass("PASS", event_pass), - message_tb("TB", event_tburst), message_sid("SID", event_sid) + message_tb("TB", event_tburst), message_sid("SID", event_sid), message_encap("ENCAP", event_encap), + message_pong("PONG", event_pong) { this->SetAuthor("Anope"); this->SetType(PROTOCOL); - AddModes(); - pmodule_ircd_var(myIrcd); pmodule_ircd_proto(&this->ircd_proto); pmodule_ircd_message(&this->ircd_message); + + this->AddModes(); } }; diff --git a/modules/protocol/unreal32.cpp b/modules/protocol/unreal32.cpp index 594764900..d5ee0ef2a 100644 --- a/modules/protocol/unreal32.cpp +++ b/modules/protocol/unreal32.cpp @@ -129,15 +129,11 @@ class UnrealIRCdProto : public IRCDProto void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) { - if (buf.empty()) - return; send_cmd(source->nick, "G %s %s", dest->name.c_str(), buf.c_str()); } void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) { - if (buf.empty()) - return; send_cmd(bi ? bi->nick : Config->ServerName, "v %s %s", u->nick.c_str(), buf.c_str()); } @@ -173,15 +169,13 @@ class UnrealIRCdProto : public IRCDProto } /* JOIN */ - void SendJoin(const BotInfo *user, const Anope::string &channel, time_t chantime) + void SendJoin(BotInfo *user, Channel *c, const ChannelStatus *status) { - send_cmd(Config->ServerName, "~ %ld %s :%s", static_cast<long>(chantime), channel.c_str(), user->nick.c_str()); - } - - void SendJoin(BotInfo *user, const ChannelContainer *cc) - { - send_cmd(Config->ServerName, "~ %ld %s :%s%s", static_cast<long>(cc->chan->creation_time), cc->chan->name.c_str(), cc->Status->BuildModePrefixList().c_str(), user->nick.c_str()); - cc->chan->SetModes(user, false, "%s", cc->chan->GetModes(true, true).c_str()); + send_cmd(Config->ServerName, "~ %ld %s :%s", static_cast<long>(c->creation_time), c->name.c_str(), user->nick.c_str()); + if (status) + for (size_t i = CMODE_BEGIN + 1; i != CMODE_END; ++i) + if (status->HasFlag(static_cast<ChannelModeName>(i))) + c->SetMode(user, static_cast<ChannelModeName>(i), user->nick, false); } /* unsqline @@ -209,16 +203,12 @@ class UnrealIRCdProto : public IRCDProto */ void SendSVSO(const Anope::string &source, const Anope::string &nick, const Anope::string &flag) { - if (source.empty() || nick.empty() || flag.empty()) - return; send_cmd(source, "BB %s %s", nick.c_str(), flag.c_str()); } /* NICK <newnick> */ void SendChangeBotNick(const BotInfo *oldnick, const Anope::string &newnick) { - if (!oldnick || newnick.empty()) - return; send_cmd(oldnick->nick, "& %s %ld", newnick.c_str(), static_cast<long>(Anope::CurTime)); } @@ -339,7 +329,7 @@ class UnrealIRCdProto : public IRCDProto ircdproto->SendMode(NickServ, u, "+d 1"); } - void SendChannel(Channel *c, const Anope::string &modes) + void SendChannel(Channel *c) { /* Unreal does not support updating a channels TS without actually joining a user, * so we will join and part us now @@ -347,13 +337,13 @@ class UnrealIRCdProto : public IRCDProto BotInfo *bi = whosends(c->ci); if (c->FindUser(bi) == NULL) { - bi->Join(c, true); + bi->Join(c); bi->Part(c); } else { bi->Part(c); - bi->Join(c, true); + bi->Join(c); } } }; @@ -374,7 +364,7 @@ class Unreal32IRCdMessage : public IRCdMessage if (params[0][0] == '#' || params[0][0] == '&') do_cmode(source, params[0], modes, server_source ? params[params.size() - 1] : ""); else - do_umode(source, params[0], modes); + do_umode(params[0], modes); return true; } @@ -828,7 +818,7 @@ bool event_umode2(const Anope::string &source, const std::vector<Anope::string> if (params.size() < 1) return true; - do_umode(source, source, params[0]); + do_umode(source, params[0]); return true; } @@ -981,43 +971,6 @@ bool ChannelModeFlood::IsValid(const Anope::string &value) const return true; } -static void AddModes() -{ - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, "CMODE_VOICE", 'v', '+')); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_HALFOP, "CMODE_HALFOP", 'h', '%')); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, "CMODE_OP", 'o', '@')); - /* Unreal sends +q as * and +a as ~ */ - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_PROTECT, "CMODE_PROTECT", 'a', '~')); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OWNER, "CMODE_OWNER", 'q', '*')); - - /* Add user modes */ - ModeManager::AddUserMode(new UserMode(UMODE_SERV_ADMIN, "UMODE_SERV_ADMIN", 'A')); - ModeManager::AddUserMode(new UserMode(UMODE_BOT, "UMODE_BOT", 'B')); - ModeManager::AddUserMode(new UserMode(UMODE_CO_ADMIN, "UMODE_CO_ADMIN", 'C')); - ModeManager::AddUserMode(new UserMode(UMODE_FILTER, "UMODE_FILTER", 'G')); - ModeManager::AddUserMode(new UserMode(UMODE_HIDEOPER, "UMODE_HIDEOPER", 'H')); - ModeManager::AddUserMode(new UserMode(UMODE_NETADMIN, "UMODE_NETADMIN", 'N')); - ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, "UMODE_REGPRIV", 'R')); - ModeManager::AddUserMode(new UserMode(UMODE_PROTECTED, "UMODE_PROTECTED", 'S')); - ModeManager::AddUserMode(new UserMode(UMODE_NO_CTCP, "UMODE_NO_CTCP", 'T')); - ModeManager::AddUserMode(new UserMode(UMODE_WEBTV, "UMODE_WEBTV", 'V')); - ModeManager::AddUserMode(new UserMode(UMODE_WHOIS, "UMODE_WHOIS", 'W')); - ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, "UMODE_ADMIN", 'a')); - ModeManager::AddUserMode(new UserMode(UMODE_DEAF, "UMODE_DEAF", 'd')); - ModeManager::AddUserMode(new UserMode(UMODE_GLOBOPS, "UMODE_GLOBOPS", 'g')); - ModeManager::AddUserMode(new UserMode(UMODE_HELPOP, "UMODE_HELPOP", 'h')); - ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i')); - ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o')); - ModeManager::AddUserMode(new UserMode(UMODE_PRIV, "UMODE_PRIV", 'p')); - ModeManager::AddUserMode(new UserMode(UMODE_GOD, "UMODE_GOD", 'q')); - ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, "UMODE_REGISTERED", 'r')); - ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, "UMODE_SNOMASK", 's')); - ModeManager::AddUserMode(new UserMode(UMODE_VHOST, "UMODE_VHOST", 't')); - ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w')); - ModeManager::AddUserMode(new UserMode(UMODE_CLOAK, "UMODE_CLOAK", 'x')); - ModeManager::AddUserMode(new UserMode(UMODE_SSL, "UMODE_SSL", 'z')); -} - class ProtoUnreal : public Module { Message message_away, message_join, message_kick, @@ -1035,6 +988,44 @@ class ProtoUnreal : public Module UnrealIRCdProto ircd_proto; Unreal32IRCdMessage ircd_message; + + void AddModes() + { + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, "CMODE_VOICE", 'v', '+')); + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_HALFOP, "CMODE_HALFOP", 'h', '%')); + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, "CMODE_OP", 'o', '@')); + /* Unreal sends +q as * and +a as ~ */ + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_PROTECT, "CMODE_PROTECT", 'a', '~')); + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OWNER, "CMODE_OWNER", 'q', '*')); + + /* Add user modes */ + ModeManager::AddUserMode(new UserMode(UMODE_SERV_ADMIN, "UMODE_SERV_ADMIN", 'A')); + ModeManager::AddUserMode(new UserMode(UMODE_BOT, "UMODE_BOT", 'B')); + ModeManager::AddUserMode(new UserMode(UMODE_CO_ADMIN, "UMODE_CO_ADMIN", 'C')); + ModeManager::AddUserMode(new UserMode(UMODE_FILTER, "UMODE_FILTER", 'G')); + ModeManager::AddUserMode(new UserMode(UMODE_HIDEOPER, "UMODE_HIDEOPER", 'H')); + ModeManager::AddUserMode(new UserMode(UMODE_NETADMIN, "UMODE_NETADMIN", 'N')); + ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, "UMODE_REGPRIV", 'R')); + ModeManager::AddUserMode(new UserMode(UMODE_PROTECTED, "UMODE_PROTECTED", 'S')); + ModeManager::AddUserMode(new UserMode(UMODE_NO_CTCP, "UMODE_NO_CTCP", 'T')); + ModeManager::AddUserMode(new UserMode(UMODE_WEBTV, "UMODE_WEBTV", 'V')); + ModeManager::AddUserMode(new UserMode(UMODE_WHOIS, "UMODE_WHOIS", 'W')); + ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, "UMODE_ADMIN", 'a')); + ModeManager::AddUserMode(new UserMode(UMODE_DEAF, "UMODE_DEAF", 'd')); + ModeManager::AddUserMode(new UserMode(UMODE_GLOBOPS, "UMODE_GLOBOPS", 'g')); + ModeManager::AddUserMode(new UserMode(UMODE_HELPOP, "UMODE_HELPOP", 'h')); + ModeManager::AddUserMode(new UserMode(UMODE_INVIS, "UMODE_INVIS", 'i')); + ModeManager::AddUserMode(new UserMode(UMODE_OPER, "UMODE_OPER", 'o')); + ModeManager::AddUserMode(new UserMode(UMODE_PRIV, "UMODE_PRIV", 'p')); + ModeManager::AddUserMode(new UserMode(UMODE_GOD, "UMODE_GOD", 'q')); + ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, "UMODE_REGISTERED", 'r')); + ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, "UMODE_SNOMASK", 's')); + ModeManager::AddUserMode(new UserMode(UMODE_VHOST, "UMODE_VHOST", 't')); + ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, "UMODE_WALLOPS", 'w')); + ModeManager::AddUserMode(new UserMode(UMODE_CLOAK, "UMODE_CLOAK", 'x')); + ModeManager::AddUserMode(new UserMode(UMODE_SSL, "UMODE_SSL", 'z')); + } + public: ProtoUnreal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), message_away("6", OnAway), @@ -1065,11 +1056,11 @@ class ProtoUnreal : public Module this->SetAuthor("Anope"); this->SetType(PROTOCOL); - AddModes(); - pmodule_ircd_var(myIrcd); pmodule_ircd_proto(&this->ircd_proto); pmodule_ircd_message(&this->ircd_message); + + this->AddModes(); ModuleManager::Attach(I_OnUserNickChange, this); } |