From 2d189c572e3825ac9d16a5baffa08c8162cbc8a3 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 27 Feb 2024 14:44:27 +0000 Subject: Replace FRHOST with a two parameter version of FHOST. No compat layer needed here as FRHOST was added in v4. --- src/modules/m_spanningtree/commands.h | 13 +------------ src/modules/m_spanningtree/compat.cpp | 15 +++++---------- src/modules/m_spanningtree/main.cpp | 4 ++-- src/modules/m_spanningtree/uid.cpp | 11 +++++------ 4 files changed, 13 insertions(+), 30 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h index cb3b22ed3..180fcdef4 100644 --- a/src/modules/m_spanningtree/commands.h +++ b/src/modules/m_spanningtree/commands.h @@ -214,18 +214,7 @@ class CommandFHost final { public: CommandFHost(Module* Creator) - : UserOnlyServerCommand(Creator, "FHOST", 1) - { - } - CmdResult HandleRemote(RemoteUser* user, Params& params); -}; - -class CommandFRHost final - : public UserOnlyServerCommand -{ -public: - CommandFRHost(Module* Creator) - : UserOnlyServerCommand(Creator, "FRHOST", 1) + : UserOnlyServerCommand(Creator, "FHOST", 2) { } CmdResult HandleRemote(RemoteUser* user, Params& params); diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp index 35aa8e6b6..6297bbd2c 100644 --- a/src/modules/m_spanningtree/compat.cpp +++ b/src/modules/m_spanningtree/compat.cpp @@ -66,20 +66,15 @@ void TreeSocket::WriteLine(const std::string& original_line) std::string command(line, cmdstart, cmdend - cmdstart); if (proto_version == PROTO_INSPIRCD_3) { - if (irc::equals(command, "FRHOST")) + if (irc::equals(command, "FHOST") || irc::equals(command, "FIDENT")) { - // FRHOST was introduced in PROTO_INSPIRCD_4; drop it. - return; - } - else if (irc::equals(command, "FIDENT")) - { - // FIDENT has two parameters in v4; drop the real username. - // : FIDENT + // FIDENT/FHOST has two parameters in v4; drop the real username/hostname. + // : FIDENT|FHOST size_t displayend = NextToken(line, cmdend); if (displayend != std::string::npos) { if ((displayend - cmdend) == 2 && line[displayend - 1] == '*') - return; // FIDENT is only changing the real username; drop. + return; // FIDENT/FHOST is only changing the real username/hostname; drop. // Trim the rest of the line. line.erase(displayend); @@ -126,7 +121,7 @@ void TreeSocket::WriteLine(const std::string& original_line) bool TreeSocket::PreProcessOldProtocolMessage(User*& who, std::string& cmd, CommandBase::Params& params) { - if (irc::equals(cmd, "FIDENT")) + if (irc::equals(cmd, "FHOST") || irc::equals(cmd, "FIDENT")) { if (params.size() < 2) params.push_back("*"); diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index c94076e82..e07ae5ad8 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -570,7 +570,7 @@ void ModuleSpanningTree::OnChangeHost(User* user, const std::string& newhost) if (!user->IsFullyConnected() || !IS_LOCAL(user)) return; - CmdBuilder(user, "FHOST").push(newhost).Broadcast(); + CmdBuilder(user, "FHOST").push(newhost).push('*').Broadcast(); } void ModuleSpanningTree::OnChangeRealHost(User* user, const std::string& newhost) @@ -578,7 +578,7 @@ void ModuleSpanningTree::OnChangeRealHost(User* user, const std::string& newhost if (!user->IsFullyConnected() || !IS_LOCAL(user)) return; - CmdBuilder(user, "FRHOST").push(newhost).Broadcast(); + CmdBuilder(user, "FHOST").push('*').push(newhost).Broadcast(); } void ModuleSpanningTree::OnChangeRealName(User* user, const std::string& real) diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index cfaea59ed..ffd6aa223 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -151,13 +151,12 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, CommandBase::Params CmdResult CommandFHost::HandleRemote(RemoteUser* src, Params& params) { - src->ChangeDisplayedHost(params[0]); - return CmdResult::SUCCESS; -} + if (params[0] != "*") + src->ChangeDisplayedHost(params[0]); + + if (params[1] != "*") + src->ChangeRealHost(params[1], false); -CmdResult CommandFRHost::HandleRemote(RemoteUser* src, Params& params) -{ - src->ChangeRealHost(params[0], false); return CmdResult::SUCCESS; } -- cgit v1.3.1-10-gc9f91