diff options
| author | 2022-05-17 20:06:21 +0100 | |
|---|---|---|
| committer | 2022-05-17 20:06:21 +0100 | |
| commit | 04fba25ada45f787ff6c93f813912b81a257538a (patch) | |
| tree | 21488fabaaa50e27f47764b8d8c29963924cf7fb /src | |
| parent | Fix an oversight in commit 3be039e. (diff) | |
Deprecate the (raw)version SINFO keys and split out customversion/rawbranch.
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/m_spanningtree/main.cpp | 21 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 17 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/override_map.cpp | 11 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/sinfo.cpp | 51 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 6 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/treeserver.h | 37 |
6 files changed, 75 insertions, 68 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index cc5f27ccc..f186d3d02 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -325,16 +325,19 @@ ModResult ModuleSpanningTree::HandleVersion(const CommandBase::Params& parameter return MOD_RES_PASSTHRU; } - // If an oper wants to see the version then show the full version string instead of the normal, - // but only if it is non-empty. - // If it's empty it might be that the server is still syncing (full version hasn't arrived yet) - // or the server is a 2.0 server and does not send a full version. - bool showfull = ((user->IsOper()) && (!found->GetFullVersion().empty())); - Numeric::Numeric numeric(RPL_VERSION); - irc::tokenstream tokens(showfull ? found->GetFullVersion() : found->GetVersion()); - for (std::string token; tokens.GetTrailing(token); ) - numeric.push(token); + if (user->IsOper()) + { + numeric.push(found->rawversion + "."); + numeric.push(found->GetName()); + numeric.push("[" + found->GetId() + "] " + found->customversion); + } + else + { + numeric.push(found->rawbranch + "."); + numeric.push(found->GetPublicName()); + numeric.push(found->customversion); + } user->WriteNumeric(numeric); } else diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index d4f4c588c..7c49c58a6 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -124,14 +124,17 @@ void TreeSocket::DoBurst(TreeServer* s) void TreeSocket::SendServerInfo(TreeServer* from) { - // Send public version string - this->WriteLine(CommandSInfo::Builder(from, "version", from->GetVersion())); + this->WriteLine(CommandSInfo::Builder(from, "customversion", from->customversion)); + this->WriteLine(CommandSInfo::Builder(from, "rawbranch", from->rawbranch)); + this->WriteLine(CommandSInfo::Builder(from, "rawversion", from->rawversion)); - // Send full version string that contains more information and is shown to opers - this->WriteLine(CommandSInfo::Builder(from, "fullversion", from->GetFullVersion())); - - // Send the raw version string that just contains the base info - this->WriteLine(CommandSInfo::Builder(from, "rawversion", from->GetRawVersion())); + if (proto_version < PROTO_INSPIRCD_4) + { + this->WriteLine(CommandSInfo::Builder(from, "version", InspIRCd::Format("%s. %s :%s", from->rawbranch.c_str(), + from->GetPublicName().c_str(), from->customversion.c_str()))); + this->WriteLine(CommandSInfo::Builder(from, "fullversion", InspIRCd::Format("%s. %s :[%s] %s", from->rawversion.c_str(), + from->GetName().c_str(), from->GetId().c_str(), from->customversion.c_str()))); + } } /** Recursively send the server tree. diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp index 55d9674bd..b686b4c69 100644 --- a/src/modules/m_spanningtree/override_map.cpp +++ b/src/modules/m_spanningtree/override_map.cpp @@ -63,8 +63,8 @@ static void GetDepthAndLen(TreeServer* current, unsigned int depth, unsigned int if (current->GetName().length() > max_len) max_len = current->GetName().length(); - if (current->GetRawVersion().length() > max_version) - max_version = current->GetRawVersion().length(); + if (current->rawversion.length() > max_version) + max_version = current->rawversion.length(); for (const auto& child : current->GetChildren()) GetDepthAndLen(child, depth + 1, max_depth, max_len, max_version); @@ -86,13 +86,12 @@ static std::vector<std::string> GetMap(User* user, TreeServer* current, size_t m { buffer += " (" + current->GetId(); - const std::string& cur_vers = current->GetRawVersion(); - if (!cur_vers.empty()) - buffer += " " + cur_vers; + if (!current->rawversion.empty()) + buffer += " " + current->rawversion; buffer += ")"; - buffer.append(max_version_len - current->GetRawVersion().length(), ' '); + buffer.append(max_version_len - current->rawversion.length(), ' '); } // Pad with spaces until its at max len, max_len must always be >= my names length diff --git a/src/modules/m_spanningtree/sinfo.cpp b/src/modules/m_spanningtree/sinfo.cpp index 1ea2d1774..ea5257360 100644 --- a/src/modules/m_spanningtree/sinfo.cpp +++ b/src/modules/m_spanningtree/sinfo.cpp @@ -28,24 +28,55 @@ CmdResult CommandSInfo::HandleServer(TreeServer* server, CommandBase::Params& pa const std::string& key = params.front(); const std::string& value = params.back(); - if (key == "fullversion") + if (irc::equals(key, "customversion")) { - server->SetFullVersion(value); + server->customversion = value; } - else if (key == "version") + else if (irc::equals(key, "desc")) { - server->SetVersion(value); + // Only sent when the description of a server changes because of a rehash; not sent on burst + ServerInstance->Logs.Normal(MODNAME, "Server description of " + server->GetName() + " changed: " + value); + server->SetDesc(value); } - else if (key == "rawversion") + else if (irc::equals(key, "rawbranch")) { - server->SetRawVersion(value); + server->rawbranch = value; } - else if (key == "desc") + else if (irc::equals(key, "rawversion")) { - // Only sent when the description of a server changes because of a rehash; not sent on burst - ServerInstance->Logs.Normal(MODNAME, "Server description of " + server->GetName() + " changed: " + value); - server->SetDesc(value); + server->rawversion = value; + } + + // BEGIN DEPRECATED KEYS + else if (irc::equals(key, "fullversion")) + { + // InspIRCd-4.0.0-a10. sadie.testnet.inspircd.org :[597] Test + // version server uid custom-version + std::string unused; + irc::spacesepstream versionstream(value); + versionstream.GetToken(server->rawversion); + server->rawversion.pop_back(); + versionstream.GetToken(unused); + versionstream.GetToken(unused); + server->customversion = versionstream.GetRemaining(); + + ServerInstance->Logs.Debug(MODNAME, "Extracted entries from fullversion key: rawversion=%s customversion=%s", + server->rawversion.c_str(), server->customversion.c_str()); + } + else if (irc::equals(key, "version")) + { + // InspIRCd-4. testnet.inspircd.org :Test + std::string unused; + irc::spacesepstream versionstream(value); + versionstream.GetToken(server->rawbranch); + server->rawbranch.pop_back(); + versionstream.GetToken(unused); + server->customversion = versionstream.GetRemaining(); + + ServerInstance->Logs.Debug(MODNAME, "Extracted entries from version key: rawbranch=%s customversion=%s", + server->rawbranch.c_str(), server->customversion.c_str()); } + // END DEPRECATED KEYS return CmdResult::SUCCESS; } diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 4c65fa608..c55021e64 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -38,15 +38,15 @@ TreeServer::TreeServer() : Server(ServerInstance->Config->GetSID(), ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc) , Parent(NULL), Route(NULL) - , VersionString(INSPIRCD_BRANCH ". " + ServerInstance->Config->GetServerName() + " :" + ServerInstance->Config->CustomVersion) - , fullversion(INSPIRCD_VERSION ". " + ServerInstance->Config->ServerName + " :[" + ServerInstance->Config->GetSID() + "] " + ServerInstance->Config->CustomVersion) - , rawversion(INSPIRCD_VERSION) , Socket(NULL) , behind_bursting(0) , pingtimer(this) , ServerUser(ServerInstance->FakeClient) , age(ServerInstance->Time()) , UserCount(ServerInstance->Users.LocalUserCount()) + , customversion(ServerInstance->Config->CustomVersion) + , rawbranch(INSPIRCD_BRANCH) + , rawversion(INSPIRCD_VERSION) , Hidden(false) { AddHashEntry(); diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index bbb233380..bc55441cf 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -49,13 +49,6 @@ class TreeServer final TreeServer* Parent; /* Parent entry */ TreeServer* Route; /* Route entry */ std::vector<TreeServer*> Children; /* List of child objects */ - std::string VersionString; /* Version string or empty string */ - - /** Full version string including patch version and other info - */ - std::string fullversion; - std::string rawversion; - TreeSocket* Socket; /* Socket used to communicate with this server */ /** Counter counting how many servers are bursting in front of this server, including @@ -94,6 +87,10 @@ public: size_t UserCount; /* How many users are on this server? [note: doesn't care about +i] */ size_t OperCount = 0; /* How many opers are on this server? */ + std::string customversion; + std::string rawbranch; + std::string rawversion; + /** We use this constructor only to create the 'root' item, Utils->TreeRoot, which * represents our own server. Therefore, it has no route, no parent, and * no socket associated with it. Its version string is our own local version. @@ -143,19 +140,6 @@ public: */ bool IsDead() const { return isdead; } - /** Get server version string - */ - const std::string& GetVersion() const { return VersionString; } - - /** Get the full version string of this server - * @return The full version string of this server, including patch version and other info - */ - const std::string& GetFullVersion() const { return fullversion; } - - /** Get the raw version string of this server - */ - const std::string& GetRawVersion() const { return rawversion; } - /** Round trip time of last ping */ unsigned long rtt = 0; @@ -178,19 +162,6 @@ public: */ TreeServer* GetParent() const { return Parent; } - /** Set the server version string - */ - void SetVersion(const std::string& verstr) { VersionString = verstr; } - - /** Set the full version string - * @param verstr The version string to set - */ - void SetFullVersion(const std::string& verstr) { fullversion = verstr; } - - /** Set the raw version string - */ - void SetRawVersion(const std::string& verstr) { rawversion = verstr; } - /** Sets the description of this server. Called when the description of a remote server changes * and we are notified about it. * @param descstr The description to set |
