summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-03-12 11:43:21 +0000
committerSadie Powell <sadie@witchery.services>2024-03-12 11:43:21 +0000
commita302f8f1be25037227725aa77fc9f4f8f1f400b5 (patch)
tree19c1eaab1322309c904f4c010a634be62efb737b /modules
parent04e1a4f5c8c4172ca36dd79dfd0731f4aba873a5 (diff)
Refactor sending vhosts in the InspIRCd protocol module.
Diffstat (limited to 'modules')
-rw-r--r--modules/protocol/inspircd.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp
index 2c1908faf..b8654b96c 100644
--- a/modules/protocol/inspircd.cpp
+++ b/modules/protocol/inspircd.cpp
@@ -102,20 +102,24 @@ private:
return nicks.substr(1);
}
- static void SendChgIdentInternal(const Anope::string &nick, const Anope::string &vIdent)
+ static void SendChgIdentInternal(const Anope::string &uid, const Anope::string &vIdent)
{
if (!Servers::Capab.count("CHGIDENT"))
- Log() << "CHGIDENT not loaded!";
- else
- Uplink::Send("CHGIDENT", nick, vIdent);
+ {
+ Log() << "Unable to change the vident of " << uid << " as the remote server does not have the chgident module loaded.";
+ return;
+ }
+ Uplink::Send("ENCAP", uid.substr(0, 3), "CHGIDENT", uid, vIdent);
}
- static void SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost)
+ static void SendChgHostInternal(const Anope::string &uid, const Anope::string &vhost)
{
if (!Servers::Capab.count("CHGHOST"))
- Log() << "CHGHOST not loaded!";
- else
- Uplink::Send("CHGHOST", nick, vhost);
+ {
+ Log() << "Unable to change the vhost of " << uid << " as the remote server does not have the chghost module loaded.";
+ return;
+ }
+ Uplink::Send("ENCAP", uid.substr(0, 3), "CHGHOST", uid, vhost);
}
static void SendAddLine(const Anope::string &xtype, const Anope::string &mask, time_t duration, const Anope::string &addedby, const Anope::string &reason)
@@ -504,9 +508,10 @@ public:
void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override
{
if (!vIdent.empty())
- this->SendChgIdentInternal(u->nick, vIdent);
+ this->SendChgIdentInternal(u->GetUID(), vIdent);
+
if (!vhost.empty())
- this->SendChgHostInternal(u->nick, vhost);
+ this->SendChgHostInternal(u->GetUID(), vhost);
}
void SendSVSHold(const Anope::string &nick, time_t t) override
@@ -624,10 +629,10 @@ public:
if (na)
{
if (!na->GetVhostIdent().empty())
- Uplink::Send("ENCAP", uid.substr(0, 3), "CHGIDENT", uid, na->GetVhostIdent());
+ SendChgHostInternal(uid, na->GetVhostIdent());
if (!na->GetVhostHost().empty())
- Uplink::Send("ENCAP", uid.substr(0, 3), "CHGHOST", uid, na->GetVhostHost());
+ SendChgHostInternal(uid, na->GetVhostHost());
// Mark this SASL session as pending user introduction.
SASLUser su;