summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/users.h9
-rw-r--r--modules/nickserv/nickserv.cpp2
-rw-r--r--modules/protocol/inspircd.cpp6
-rw-r--r--src/bots.cpp19
-rw-r--r--src/messages.cpp6
-rw-r--r--src/servers.cpp10
-rw-r--r--src/users.cpp21
7 files changed, 41 insertions, 32 deletions
diff --git a/include/users.h b/include/users.h
index dff68fef2..92515678f 100644
--- a/include/users.h
+++ b/include/users.h
@@ -107,14 +107,14 @@ protected:
* @param suid The unique identifier of the user.
* @param nc The account the user is identified as, if any
*/
- User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickCore *nc);
+ User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const std::vector<Anope::string> &smodeparams, const Anope::string &suid, NickCore *nc);
/** Destroy a user.
*/
virtual ~User();
public:
- static User *OnIntroduce(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickCore *nc);
+ static User *OnIntroduce(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickCore *nc, const std::vector<Anope::string> &smodeparams = {});
/** Update the nickname of a user record accordingly, should be
* called from ircd protocol.
@@ -307,9 +307,10 @@ public:
/** Set a string of modes on a user internally
* @param setter who/what is setting the mode
- * @param umodes The modes
+ * @param umodes The mode letters
+ * @param umodeparams The mode values
*/
- void SetModesInternal(const MessageSource &source, const Anope::string &umodes);
+ void SetModesInternal(const MessageSource &source, const Anope::string &umodes, const std::vector<Anope::string> &umodeparams = {});
/** Get modes set for this user.
* @return A string of modes set on the user
diff --git a/modules/nickserv/nickserv.cpp b/modules/nickserv/nickserv.cpp
index 6fce83aa6..1718af690 100644
--- a/modules/nickserv/nickserv.cpp
+++ b/modules/nickserv/nickserv.cpp
@@ -98,7 +98,7 @@ class NickServRelease final
public:
NickServRelease(Module *me, 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", Me->GetName()), "", "", Me, "Services Enforcer", Anope::CurTime, "", IRCD->UID_Retrieve(), NULL)
+ : User(na->nick, Config->GetModule("nickserv")->Get<const Anope::string>("enforceruser", "user"), Config->GetModule("nickserv")->Get<const Anope::string>("enforcerhost", Me->GetName()), "", "", Me, "Services Enforcer", Anope::CurTime, "", {}, IRCD->UID_Retrieve(), NULL)
, Timer(me, delay)
, nick(na->nick)
{
diff --git a/modules/protocol/inspircd.cpp b/modules/protocol/inspircd.cpp
index 334d9609e..00ed2bf49 100644
--- a/modules/protocol/inspircd.cpp
+++ b/modules/protocol/inspircd.cpp
@@ -2397,10 +2397,6 @@ struct IRCDMessageUID final
size_t offset = params[8][0] == '+' ? 0 : 1;
auto ts = IRCD->ExtractTimestamp(params[1]);
- Anope::string modes = params[8+offset];
- for (unsigned i = 9+offset; i < params.size() - 1; ++i)
- modes += " " + params[i];
-
NickAlias *na = NULL;
if (SASL::sasl)
for (std::list<SASLUser>::iterator it = saslusers.begin(); it != saslusers.end();)
@@ -2418,7 +2414,7 @@ struct IRCDMessageUID final
++it;
}
- User *u = User::OnIntroduce(params[2], params[5+offset], params[3], params[4], params[6+offset], source.GetServer(), params[params.size() - 1], ts, modes, params[0], na ? *na->nc : NULL);
+ auto *u = User::OnIntroduce(params[2], params[5+offset], params[3], params[4], params[6+offset], source.GetServer(), params[params.size() - 1], ts, params[8 + offset], params[0], na ? *na->nc : NULL, { params.begin() + 9 + offset, params.end() - 1 });
if (u)
u->signon = IRCD->ExtractTimestamp(params[7+offset]);
}
diff --git a/src/bots.cpp b/src/bots.cpp
index 0fb5c682d..b109f8680 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -20,7 +20,11 @@
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, "", IRCD ? IRCD->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;
@@ -35,9 +39,16 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
// If we're synchronised with the uplink already, send the bot.
if (Me && Me->IsSynced())
{
- Anope::string tmodes = !this->botmodes.empty() ? ("+" + this->botmodes) : IRCD->DefaultPseudoclientModes;
- if (!tmodes.empty())
- this->SetModesInternal(this, tmodes);
+ spacesepstream modesep(this->botmodes.empty() ? IRCD->DefaultPseudoclientModes : "+" + this->botmodes);
+
+ Anope::string modechars;
+ modesep.GetToken(modechars);
+
+ std::vector<Anope::string> modeparams;
+ modesep.GetTokens(modeparams);
+
+ if (!modechars.empty())
+ this->SetModesInternal(this, modechars, modeparams);
XLine x(this->nick, "Reserved for services");
IRCD->SendSQLine(NULL, &x);
diff --git a/src/messages.cpp b/src/messages.cpp
index 9e6f6ebb0..b21a27f37 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -214,10 +214,6 @@ void Kill::Run(MessageSource &source, const std::vector<Anope::string> &params,
void Message::Mode::Run(MessageSource &source, const std::vector<Anope::string> &params, const Anope::map<Anope::string> &tags)
{
- 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]);
@@ -230,7 +226,7 @@ void Message::Mode::Run(MessageSource &source, const std::vector<Anope::string>
User *u = User::Find(params[0]);
if (u)
- u->SetModesInternal(source, buf.substr(1));
+ u->SetModesInternal(source, params[1], { params.begin() + 2, params.end() });
}
}
diff --git a/src/servers.cpp b/src/servers.cpp
index 1435ee743..ca418aec0 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -50,9 +50,15 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano
/* Now do mode related stuff as we know what modes exist .. */
for (auto &[_, bi] : *BotListByNick)
{
- Anope::string modes = !bi->botmodes.empty() ? ("+" + bi->botmodes) : IRCD->DefaultPseudoclientModes;
+ spacesepstream modesep(bi->botmodes.empty() ? IRCD->DefaultPseudoclientModes : "+" + bi->botmodes);
- bi->SetModesInternal(bi, modes);
+ Anope::string modechars;
+ modesep.GetToken(modechars);
+
+ std::vector<Anope::string> modeparams;
+ modesep.GetTokens(modeparams);
+
+ bi->SetModesInternal(bi, modechars, modeparams);
for (const auto &botchannel : bi->botchannels)
{
size_t h = botchannel.find('#');
diff --git a/src/users.cpp b/src/users.cpp
index 4e01c6989..e39114654 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -31,7 +31,8 @@ time_t MaxUserTime = 0;
std::list<User *> User::quitting_users;
-User::User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &uip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickCore *account) : ip(uip)
+User::User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &uip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const std::vector<Anope::string> &smodeparams, const Anope::string &suid, NickCore *account)
+ : ip(uip)
{
if (snick.empty() || sident.empty() || shost.empty())
throw CoreException("Bad args passed to User::User");
@@ -49,7 +50,7 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
this->server = sserver;
this->realname = srealname;
this->timestamp = this->signon = ts;
- this->SetModesInternal(sserver, smodes);
+ this->SetModesInternal(sserver, smodes, smodeparams);
this->uid = suid;
this->super_admin = false;
this->nc = NULL;
@@ -110,7 +111,7 @@ static void Collide(User *u, const Anope::string &id, const Anope::string &type)
CollideKill(u, type);
}
-User *User::OnIntroduce(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickCore *nc)
+User *User::OnIntroduce(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &sip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickCore *nc, const std::vector<Anope::string> &smodeparams)
{
// 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
@@ -132,7 +133,7 @@ User *User::OnIntroduce(const Anope::string &snick, const Anope::string &sident,
}
}
- return new User(snick, sident, shost, svhost, sip, sserver, srealname, ts, smodes, suid, nc);
+ return new User(snick, sident, shost, svhost, sip, sserver, srealname, ts, smodes, smodeparams, suid, nc);
}
void User::ChangeNick(const Anope::string &newnick, time_t ts)
@@ -672,16 +673,14 @@ void User::SetModes(BotInfo *bi, const Anope::string &umodes)
}
}
-void User::SetModesInternal(const MessageSource &source, const Anope::string &umodes)
+void User::SetModesInternal(const MessageSource &source, const Anope::string &umodes, const std::vector<Anope::string> &umodeparams)
{
if (this->server && this->server->IsSynced() && Anope::string(umodes) != "+")
Log(this, "mode") << "changes modes to " << umodes;
int add = -1;
- Anope::string modebuf;
- spacesepstream sep(umodes);
- sep.GetToken(modebuf);
- for (auto mode : modebuf)
+ auto paramit = umodeparams.begin();
+ for (const auto mode : umodes)
{
UserMode *um;
@@ -704,8 +703,8 @@ void User::SetModesInternal(const MessageSource &source, const Anope::string &um
if (add)
{
Anope::string sbuf;
- if (um->type == MODE_PARAM && sep.GetToken(sbuf))
- this->SetModeInternal(source, um, sbuf);
+ if (um->type == MODE_PARAM && paramit != umodeparams.end())
+ this->SetModeInternal(source, um, *paramit++);
else
this->SetModeInternal(source, um);
}