diff options
author | Adam <Adam@anope.org> | 2014-05-21 08:50:40 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-05-21 08:50:40 -0400 |
commit | f627a3bacd0d058e94260dac1555790cafd9a926 (patch) | |
tree | 4ba71bf94b44ba07abc627ba0c26f3b8b94da439 | |
parent | 5a1257b7f0b44ee3fd4639e5be288d160ceb5095 (diff) |
Core prep for p10 stuff
-rw-r--r-- | include/messages.h | 2 | ||||
-rw-r--r-- | include/protocol.h | 9 | ||||
-rw-r--r-- | include/servers.h | 4 | ||||
-rw-r--r-- | modules/bs_autoassign.cpp | 2 | ||||
-rw-r--r-- | modules/commands/os_jupe.cpp | 2 | ||||
-rw-r--r-- | modules/database/db_old.cpp | 4 | ||||
-rw-r--r-- | modules/m_proxyscan.cpp | 2 | ||||
-rw-r--r-- | modules/m_rewrite.cpp | 2 | ||||
-rw-r--r-- | modules/m_xmlrpc_main.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/bahamut.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/inspircd12.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/ngircd.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/plexus.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/unreal.cpp | 2 | ||||
-rw-r--r-- | modules/pseudoclients/botserv.cpp | 2 | ||||
-rw-r--r-- | modules/pseudoclients/nickserv.cpp | 2 | ||||
-rw-r--r-- | src/bots.cpp | 36 | ||||
-rw-r--r-- | src/config.cpp | 2 | ||||
-rw-r--r-- | src/init.cpp | 2 | ||||
-rw-r--r-- | src/logger.cpp | 2 | ||||
-rw-r--r-- | src/messages.cpp | 14 | ||||
-rw-r--r-- | src/process.cpp | 71 | ||||
-rw-r--r-- | src/protocol.cpp | 49 | ||||
-rw-r--r-- | src/regchannel.cpp | 2 | ||||
-rw-r--r-- | src/servers.cpp | 49 | ||||
-rw-r--r-- | src/uplink.cpp | 15 | ||||
-rw-r--r-- | src/users.cpp | 17 |
27 files changed, 165 insertions, 137 deletions
diff --git a/include/messages.h b/include/messages.h index 3bf096d7c..7b22a6ef4 100644 --- a/include/messages.h +++ b/include/messages.h @@ -82,7 +82,7 @@ namespace Message struct CoreExport Mode : IRCDMessage { - Mode(Module *creator, const Anope::string &mname = "MODE") : IRCDMessage(creator, mname, 2) { } + Mode(Module *creator, const Anope::string &mname = "MODE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override; }; diff --git a/include/protocol.h b/include/protocol.h index 48520ca43..216adb6cb 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -40,6 +40,9 @@ class CoreExport IRCDProto : public Service virtual void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf); const Anope::string &GetProtocolName(); + virtual void Parse(const Anope::string &, Anope::string &, Anope::string &, std::vector<Anope::string> &); + virtual Anope::string Format(const Anope::string &source, const Anope::string &message); + /* Modes used by default by our clients */ Anope::string DefaultPseudoclientModes; /* Can we force change a users's nick? */ @@ -64,11 +67,17 @@ class CoreExport IRCDProto : public Service bool CanCertFP; /* Whether this IRCd requires unique IDs for each user or server. See TS6/P10. */ bool RequiresID; + /* If this IRCd has unique ids, whether the IDs and nicknames are ambiguous */ + bool AmbiguousID; /* The maximum number of modes we are allowed to set with one MODE command */ unsigned MaxModes; /* The maximum number of bytes a line may have */ unsigned MaxLine; + /* Retrieves the next free UID or SID */ + virtual Anope::string UID_Retrieve(); + virtual Anope::string SID_Retrieve(); + /** Sets the server in NOOP mode. If NOOP mode is enabled, no users * will be able to oper on the server. * @param s The server diff --git a/include/servers.h b/include/servers.h index 7a2a594f1..054b881df 100644 --- a/include/servers.h +++ b/include/servers.h @@ -23,10 +23,6 @@ extern CoreExport Server *Me; namespace Servers { - /* Retrieves the next free TS6 UID or SID */ - extern CoreExport const Anope::string TS6_UID_Retrieve(); - extern CoreExport const Anope::string TS6_SID_Retrieve(); - /* Gets our uplink. Note we don't actually have an "uplink", this is just * the only server whose uplink *is* Me that is not a juped server. * @return Our uplink, or NULL if not uplinked to anything diff --git a/modules/bs_autoassign.cpp b/modules/bs_autoassign.cpp index 4c41ad357..aa5fd5626 100644 --- a/modules/bs_autoassign.cpp +++ b/modules/bs_autoassign.cpp @@ -22,7 +22,7 @@ class BSAutoAssign : public Module if (bot.empty()) return; - BotInfo *bi = BotInfo::Find(bot); + BotInfo *bi = BotInfo::Find(bot, true); if (bi == NULL) { Log(this) << "bs_autoassign is configured to assign bot " << bot << ", but it does not exist?"; diff --git a/modules/commands/os_jupe.cpp b/modules/commands/os_jupe.cpp index 7d9c2dd6a..d3b25905e 100644 --- a/modules/commands/os_jupe.cpp +++ b/modules/commands/os_jupe.cpp @@ -36,7 +36,7 @@ class CommandOSJupe : public Command { Anope::string rbuf = "Juped by " + source.GetNick() + (!reason.empty() ? ": " + reason : ""); /* Generate the new sid before quitting the old server, so they can't collide */ - Anope::string sid = Servers::TS6_SID_Retrieve(); + Anope::string sid = IRCD->SID_Retrieve(); if (server) { IRCD->SendSquit(server, rbuf); diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp index b73afbc41..27b2e4fe9 100644 --- a/modules/database/db_old.cpp +++ b/modules/database/db_old.cpp @@ -719,7 +719,7 @@ static void LoadBots() READ(read_int32(&created, f)); READ(read_int16(&chancount, f)); - BotInfo *bi = BotInfo::Find(nick); + BotInfo *bi = BotInfo::Find(nick, true); if (!bi) bi = new BotInfo(nick, user, host, real); bi->created = created; @@ -975,7 +975,7 @@ static void LoadChannels() } READ(read_string(buffer, f)); - ci->bi = BotInfo::Find(buffer); + ci->bi = BotInfo::Find(buffer, true); READ(read_int32(&tmp32, f)); if (tmp32 & OLD_BS_DONTKICKOPS) diff --git a/modules/m_proxyscan.cpp b/modules/m_proxyscan.cpp index 6df764166..78417fdf6 100644 --- a/modules/m_proxyscan.cpp +++ b/modules/m_proxyscan.cpp @@ -340,7 +340,7 @@ class ModuleProxyScan : public Module if (!this->con_notice.empty() && !this->con_source.empty()) { - BotInfo *bi = BotInfo::Find(this->con_source); + BotInfo *bi = BotInfo::Find(this->con_source, true); if (bi) user->SendMessage(bi, this->con_notice); } diff --git a/modules/m_rewrite.cpp b/modules/m_rewrite.cpp index 51795d825..c4e63586d 100644 --- a/modules/m_rewrite.cpp +++ b/modules/m_rewrite.cpp @@ -115,7 +115,7 @@ class RewriteCommand : public Command { Anope::string new_message = r->Process(source, full_params); Log(LOG_DEBUG) << "m_rewrite: Rewrote '" << source.command << (!params.empty() ? " " + params[0] : "") << "' to '" << new_message << "' using '" << r->source_message << "'"; - source.service = BotInfo::Find(r->client); + source.service = BotInfo::Find(r->client, true); if (!source.service) return; Command::Run(source, new_message); diff --git a/modules/m_xmlrpc_main.cpp b/modules/m_xmlrpc_main.cpp index a66503f87..1a496c65c 100644 --- a/modules/m_xmlrpc_main.cpp +++ b/modules/m_xmlrpc_main.cpp @@ -74,7 +74,7 @@ class MyXMLRPCEvent : public XMLRPCEvent request.reply("error", "Invalid parameters"); else { - BotInfo *bi = BotInfo::Find(service); + BotInfo *bi = BotInfo::Find(service, true); if (!bi) request.reply("error", "Invalid service"); else diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 206bca250..a8252c8c5 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -175,7 +175,7 @@ class BahamutIRCdProto : public IRCDProto if (uc != NULL) uc->status.Clear(); - BotInfo *setter = BotInfo::Find(user->nick); + BotInfo *setter = BotInfo::Find(user->GetUID()); for (size_t i = 0; i < cs.Modes().length(); ++i) c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 8b17d4140..5fb226d99 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -269,7 +269,7 @@ class InspIRCd12Proto : public IRCDProto if (uc != NULL) uc->status.Clear(); - BotInfo *setter = BotInfo::Find(user->nick); + BotInfo *setter = BotInfo::Find(user->GetUID()); for (size_t i = 0; i < cs.Modes().length(); ++i) c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 81ba28a6a..86ced45ed 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -101,7 +101,7 @@ class ngIRCdProto : public IRCDProto if (uc != NULL) uc->status.Clear(); - BotInfo *setter = BotInfo::Find(user->nick); + BotInfo *setter = BotInfo::Find(user->GetUID()); for (size_t i = 0; i < cs.Modes().length(); ++i) c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index 04d90be7e..e65699f1c 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -67,7 +67,7 @@ class PlexusProto : public IRCDProto if (uc != NULL) uc->status.Clear(); - BotInfo *setter = BotInfo::Find(user->nick); + BotInfo *setter = BotInfo::Find(user->GetUID()); for (size_t i = 0; i < cs.Modes().length(); ++i) c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index fd7cb8e81..304da6788 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -167,7 +167,7 @@ class UnrealIRCdProto : public IRCDProto if (uc != NULL) uc->status.Clear(); - BotInfo *setter = BotInfo::Find(user->nick); + BotInfo *setter = BotInfo::Find(user->GetUID()); for (size_t i = 0; i < cs.Modes().length(); ++i) c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp index 144433631..48d604a6c 100644 --- a/modules/pseudoclients/botserv.cpp +++ b/modules/pseudoclients/botserv.cpp @@ -198,7 +198,7 @@ class BotServCore : public Module void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) anope_override { - BotInfo *bi = BotInfo::Find(target->nick); + BotInfo *bi = BotInfo::Find(target->GetUID()); if (bi) /* Bots get rejoined */ bi->Join(channel, &status); diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index 0c314e500..e5ae04091 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -67,7 +67,7 @@ class NickServRelease : public User, public Timer public: NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->GetModule("nickserv")->Get<const Anope::string>("enforceruser", "user"), - Config->GetModule("nickserv")->Get<const Anope::string>("enforcerhost", "services.localhost.net"), "", "", Me, "Services Enforcer", Anope::CurTime, "", Servers::TS6_UID_Retrieve(), NULL), Timer(delay), nick(na->nick) + Config->GetModule("nickserv")->Get<const Anope::string>("enforcerhost", "services.localhost.net"), "", "", Me, "Services Enforcer", Anope::CurTime, "", IRCD->UID_Retrieve(), NULL), Timer(delay), nick(na->nick) { /* Erase the current release timer and use the new one */ Anope::map<NickServRelease *>::iterator nit = NickServReleases.find(this->nick); diff --git a/src/bots.cpp b/src/bots.cpp index 9ce918a91..16e6a1cf9 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -21,7 +21,7 @@ Serialize::Checker<botinfo_map> BotListByNick("BotInfo"), BotListByUID("BotInfo"); -BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", Servers::TS6_UID_Retrieve(), NULL), Serializable("BotInfo"), channels("ChannelInfo"), botmodes(bmodes) +BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", IRCD ? IRCD->UID_Retrieve() : "", NULL), Serializable("BotInfo"), channels("ChannelInfo"), botmodes(bmodes) { this->lastmsg = this->created = Anope::CurTime; this->introduced = false; @@ -96,7 +96,7 @@ Serializable* BotInfo::Unserialize(Serializable *obj, Serialize::Data &data) BotInfo *bi; if (obj) bi = anope_dynamic_static_cast<BotInfo *>(obj); - else if (!(bi = BotInfo::Find(nick))) + else if (!(bi = BotInfo::Find(nick, true))) bi = new BotInfo(nick, user, host, realname); data["created"] >> bi->created; @@ -118,7 +118,7 @@ void BotInfo::GenerateUID() UserListByUID.erase(this->uid); } - this->uid = Servers::TS6_UID_Retrieve(); + this->uid = IRCD->UID_Retrieve(); (*BotListByUID)[this->uid] = this; UserListByUID[this->uid] = this; } @@ -215,9 +215,9 @@ void BotInfo::Part(Channel *c, const Anope::string &reason) IRCD->SendPart(this, c, "%s", !reason.empty() ? reason.c_str() : ""); - FOREACH_MOD(OnPartChannel, (this, c, c->name, reason)); - c->DeleteUser(this); + + FOREACH_MOD(OnPartChannel, (this, c, c->name, reason)); } void BotInfo::OnMessage(User *u, const Anope::string &message) @@ -248,22 +248,28 @@ CommandInfo *BotInfo::GetCommand(const Anope::string &cname) BotInfo* BotInfo::Find(const Anope::string &nick, bool nick_only) { - BotInfo *bi = NULL; - if (!nick_only && isdigit(nick[0]) && IRCD->RequiresID) + if (!nick_only && IRCD != NULL && IRCD->RequiresID) { botinfo_map::iterator it = BotListByUID->find(nick); if (it != BotListByUID->end()) - bi = it->second; + { + BotInfo *bi = it->second; + bi->QueueUpdate(); + return bi; + } + + if (IRCD->AmbiguousID) + return NULL; } - else + + botinfo_map::iterator it = BotListByNick->find(nick); + if (it != BotListByNick->end()) { - botinfo_map::iterator it = BotListByNick->find(nick); - if (it != BotListByNick->end()) - bi = it->second; + BotInfo *bi = it->second; + bi->QueueUpdate(); + return bi; } - if (bi) - bi->QueueUpdate(); - return bi; + return NULL; } diff --git a/src/config.cpp b/src/config.cpp index 110045786..3ce4251e7 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -394,7 +394,7 @@ Conf::Conf() : Block("") LogInfo l(logage, rawio, debug); - l.bot = BotInfo::Find(log->Get<const Anope::string>("bot", "Global")); + l.bot = BotInfo::Find(log->Get<const Anope::string>("bot", "Global"), true); spacesepstream(log->Get<const Anope::string>("target")).GetTokens(l.targets); spacesepstream(log->Get<const Anope::string>("source")).GetTokens(l.sources); spacesepstream(log->Get<const Anope::string>("admin")).GetTokens(l.admin); diff --git a/src/init.cpp b/src/init.cpp index 07f847d70..da91e2fcf 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -527,7 +527,7 @@ void Anope::Init(int ac, char **av) /* Auto assign sid if applicable */ if (IRCD->RequiresID) { - Anope::string sid = Servers::TS6_SID_Retrieve(); + Anope::string sid = IRCD->SID_Retrieve(); if (Me->GetSID() == Me->GetName()) Me->SetSID(sid); for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) diff --git a/src/logger.cpp b/src/logger.cpp index 4297bcab0..977af0a5f 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -90,7 +90,7 @@ Log::Log(LogType t, CommandSource &src, Command *_c, ChannelInfo *_ci) : u(src.G size_t sl = c->name.find('/'); this->bi = NULL; if (sl != Anope::string::npos) - this->bi = BotInfo::Find(c->name.substr(0, sl)); + this->bi = BotInfo::Find(c->name.substr(0, sl), true); this->category = c->name; } diff --git a/src/messages.cpp b/src/messages.cpp index 8e92d19c2..d6fd99143 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -208,19 +208,23 @@ void Kill::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) void Message::Mode::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { + Anope::string buf; + for (unsigned i = 1; i < params.size(); ++i) + buf += " " + params[i]; + if (IRCD->IsChannelValid(params[0])) { Channel *c = Channel::Find(params[0]); if (c) - c->SetModesInternal(source, params[1], 0); + c->SetModesInternal(source, buf.substr(1), 0); } else { User *u = User::Find(params[0]); if (u) - u->SetModesInternal(source, "%s", params[1].c_str()); + u->SetModesInternal(source, "%s", buf.substr(1).c_str()); } } @@ -313,10 +317,12 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m * us, and strip it off. */ Anope::string botname = receiver; size_t s = receiver.find('@'); + bool nick_only = false; if (s != Anope::string::npos) { Anope::string servername(receiver.begin() + s + 1, receiver.end()); botname = botname.substr(0, s); + nick_only = true; if (!servername.equals_ci(Me->GetName())) return; } @@ -330,7 +336,7 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m return; } - BotInfo *bi = BotInfo::Find(botname); + BotInfo *bi = BotInfo::Find(botname, nick_only); if (bi) { @@ -469,7 +475,7 @@ void Whois::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) if (u && u->server == Me) { - const BotInfo *bi = BotInfo::Find(u->nick); + const BotInfo *bi = BotInfo::Find(u->GetUID()); IRCD->SendNumeric(311, source.GetSource(), "%s %s %s * :%s", u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->realname.c_str()); if (bi) IRCD->SendNumeric(307, source.GetSource(), "%s :is a registered nick", bi->nick.c_str()); diff --git a/src/process.cpp b/src/process.cpp index 16373b144..2d7a1561a 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -24,34 +24,10 @@ void Anope::Process(const Anope::string &buffer) if (buffer.empty()) return; - spacesepstream buf_sep(buffer); - - Anope::string source; - if (buffer[0] == ':') - { - buf_sep.GetToken(source); - source.erase(0, 1); - } - - Anope::string command; - if (!buf_sep.GetToken(command)) - return; - - Anope::string buf_token; + Anope::string source, command; std::vector<Anope::string> params; - while (buf_sep.GetToken(buf_token)) - { - if (buf_token[0] == ':') - { - if (!buf_sep.StreamEnd()) - params.push_back(buf_token.substr(1) + " " + buf_sep.GetRemaining()); - else - params.push_back(buf_token.substr(1)); - break; - } - else - params.push_back(buf_token); - } + + IRCD->Parse(buffer, source, command, params); if (Anope::ProtocolDebug) { @@ -65,6 +41,12 @@ void Anope::Process(const Anope::string &buffer) Log() << "params " << i << ": " << params[i]; } + if (command.empty()) + { + Log(LOG_DEBUG) << "No command? " << buffer; + return; + } + static const Anope::string proto_name = ModuleManager::FindFirstOf(PROTOCOL) ? ModuleManager::FindFirstOf(PROTOCOL)->name : ""; MessageSource src(source); @@ -91,3 +73,38 @@ void Anope::Process(const Anope::string &buffer) m->Run(src, params); } +void IRCDProto::Parse(const Anope::string &buffer, Anope::string &source, Anope::string &command, std::vector<Anope::string> ¶ms) +{ + spacesepstream sep(buffer); + + if (buffer[0] == ':') + { + sep.GetToken(source); + source.erase(0, 1); + } + + sep.GetToken(command); + + for (Anope::string token; sep.GetToken(token);) + { + if (token[0] == ':') + { + if (!sep.StreamEnd()) + params.push_back(token.substr(1) + " " + sep.GetRemaining()); + else + params.push_back(token.substr(1)); + break; + } + else + params.push_back(token); + } +} + +Anope::string IRCDProto::Format(const Anope::string &source, const Anope::string &message) +{ + if (!source.empty()) + return ":" + source + " " + message; + else + return message; +} + diff --git a/src/protocol.cpp b/src/protocol.cpp index a32f521f2..17b43e292 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -26,7 +26,7 @@ IRCDProto::IRCDProto(Module *creator, const Anope::string &p) : Service(creator, { DefaultPseudoclientModes = "+io"; CanSVSNick = CanSVSJoin = CanSetVHost = CanSetVIdent = CanSNLine = CanSQLine = CanSQLineChannel - = CanSZLine = CanSVSHold = CanSVSO = CanCertFP = RequiresID = false; + = CanSZLine = CanSVSHold = CanSVSO = CanCertFP = RequiresID = AmbiguousID = false; MaxModes = 3; MaxLine = 512; @@ -45,6 +45,53 @@ const Anope::string &IRCDProto::GetProtocolName() return this->proto_name; } +static inline char& nextID(char &c) +{ + if (c == 'Z') + c = '0'; + else if (c != '9') + ++c; + else + c = 'A'; + return c; +} + +Anope::string IRCDProto::UID_Retrieve() +{ + if (!IRCD || !IRCD->RequiresID) + return ""; + + static Anope::string current_uid = "AAAAAA"; + + do + { + int current_len = current_uid.length() - 1; + while (current_len >= 0 && nextID(current_uid[current_len--]) == 'A'); + } + while (User::Find(Me->GetSID() + current_uid) != NULL); + + return Me->GetSID() + current_uid; +} + +Anope::string IRCDProto::SID_Retrieve() +{ + if (!IRCD || !IRCD->RequiresID) + return ""; + + static Anope::string current_sid = Config->GetBlock("serverinfo")->Get<const Anope::string>("id"); + if (current_sid.empty()) + current_sid = "00A"; + + do + { + int current_len = current_sid.length() - 1; + while (current_len >= 0 && nextID(current_sid[current_len--]) == 'A'); + } + while (Server::Find(current_sid) != NULL); + + return current_sid; +} + void IRCDProto::SendKill(const MessageSource &source, const Anope::string &target, const Anope::string &reason) { UplinkSocket::Message(source) << "KILL " << target << " :" << reason; diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 7e0ce300c..5c00e291a 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -271,7 +271,7 @@ Serializable* ChannelInfo::Unserialize(Serializable *obj, Serialize::Data &data) } catch (const ConvertException &) { } } - BotInfo *bi = BotInfo::Find(sbi); + BotInfo *bi = BotInfo::Find(sbi, true); if (*ci->bi != bi) { if (bi) diff --git a/src/servers.cpp b/src/servers.cpp index e1b66baa8..3427c2beb 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -95,7 +95,7 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano { User *u = it->second; - BotInfo *bi = BotInfo::Find(u->nick); + BotInfo *bi = BotInfo::Find(u->GetUID()); if (bi) { XLine x(bi->nick, "Reserved for services"); @@ -352,53 +352,6 @@ Server *Server::Find(const Anope::string &name, bool name_only) return NULL; } -static inline char& nextID(char &c) -{ - if (c == 'Z') - c = '0'; - else if (c != '9') - ++c; - else - c = 'A'; - return c; -} - -const Anope::string Servers::TS6_UID_Retrieve() -{ - if (!IRCD || !IRCD->RequiresID) - return ""; - - static Anope::string current_uid = "AAAAAA"; - - do - { - int current_len = current_uid.length() - 1; - while (current_len >= 0 && nextID(current_uid[current_len--]) == 'A'); - } - while (User::Find(Me->GetSID() + current_uid) != NULL); - - return Me->GetSID() + current_uid; -} - -const Anope::string Servers::TS6_SID_Retrieve() -{ - if (!IRCD || !IRCD->RequiresID) - return ""; - - static Anope::string current_sid = Config->GetBlock("serverinfo")->Get<const Anope::string>("id"); - if (current_sid.empty()) - current_sid = "00A"; - - do - { - int current_len = current_sid.length() - 1; - while (current_len >= 0 && nextID(current_sid[current_len--]) == 'A'); - } - while (Server::Find(current_sid) != NULL); - - return current_sid; -} - Server* Servers::GetUplink() { for (unsigned i = 0; Me && i < Me->GetLinks().size(); ++i) diff --git a/src/uplink.cpp b/src/uplink.cpp index 80727487a..549df85b3 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -77,7 +77,7 @@ UplinkSocket::~UplinkSocket() { /* Don't use quitmsg here, it may contain information you don't want people to see */ IRCD->SendQuit(u, "Shutting down"); - BotInfo* bi = BotInfo::Find(u->nick); + BotInfo* bi = BotInfo::Find(u->GetUID()); if (bi != NULL) bi->introduced = false; } @@ -195,14 +195,7 @@ UplinkSocket::Message::~Message() return; } - if (!message_source.empty()) - { - UplinkSock->Write(":" + message_source + " " + this->buffer.str()); - Log(LOG_RAWIO) << "Sent: :" << message_source << " " << this->buffer.str(); - } - else - { - UplinkSock->Write(this->buffer.str()); - Log(LOG_RAWIO) << "Sent: " << this->buffer.str(); - } + Anope::string sent = IRCD->Format(message_source, this->buffer.str()); + UplinkSock->Write(sent); + Log(LOG_RAWIO) << "Sent: " << sent; } diff --git a/src/users.cpp b/src/users.cpp index 8a4246e2f..2a04fca20 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -118,7 +118,7 @@ User* User::OnIntroduce(const Anope::string &snick, const Anope::string &sident, // How IRCds handle collisions varies a lot, for safety well just always kill both sides // With properly set qlines, this can almost never happen anyway - User *u = User::Find(snick); + User *u = User::Find(snick, true); if (u) { Collide(u, !suid.empty() ? suid : snick, "Nick collision"); @@ -814,18 +814,19 @@ bool User::BadPassword() User* User::Find(const Anope::string &name, bool nick_only) { - if (!nick_only && isdigit(name[0]) && IRCD->RequiresID) + if (!nick_only && IRCD->RequiresID) { user_map::iterator it = UserListByUID.find(name); if (it != UserListByUID.end()) return it->second; + + if (IRCD->AmbiguousID) + return NULL; } - else - { - user_map::iterator it = UserListByNick.find(name); - if (it != UserListByNick.end()) - return it->second; - } + + user_map::iterator it = UserListByNick.find(name); + if (it != UserListByNick.end()) + return it->second; return NULL; } |