summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-09-27 17:02:36 -0400
committerAdam <Adam@anope.org>2010-09-27 17:02:36 -0400
commit6ca09be66341fd9f568fb0ac754df4f4c561bc1f (patch)
treeda58c10795eaa5ed9298c84d8a49f089018164ff
parent7db5e19f7499cce5b86d63f8af5ae5ecf7245bf0 (diff)
Cleaned up some unused code, moved handling of user modes around so we dont get log messages about user modes when users connect, and fixed tracking some umodes on Unreal
-rw-r--r--include/channels.h17
-rw-r--r--include/extern.h4
-rw-r--r--include/services.h1
-rw-r--r--include/users.h20
-rw-r--r--modules/protocol/bahamut.cpp9
-rw-r--r--modules/protocol/inspircd11.cpp6
-rw-r--r--modules/protocol/inspircd12.cpp9
-rw-r--r--modules/protocol/inspircd20.cpp9
-rw-r--r--modules/protocol/ratbox.cpp7
-rw-r--r--modules/protocol/unreal32.cpp28
-rw-r--r--src/channels.cpp24
-rw-r--r--src/sessions.cpp1
-rw-r--r--src/users.cpp221
13 files changed, 134 insertions, 222 deletions
diff --git a/include/channels.h b/include/channels.h
index d82e61037..41b252165 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -188,15 +188,6 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
*/
void SetMode(BotInfo *bi, ChannelModeName Name, const Anope::string &param = "", bool EnforceMLock = true);
- /**
- * Set a mode on a channel
- * @param bi The client setting the modes
- * @param Mode The mode
- * @param param Optional param arg for the mode
- * @param EnforceMLock true if mlocks should be enforced, false to override mlock
- */
- void SetMode(BotInfo *bi, char Mode, const Anope::string &param = "", bool EnforceMLock = true);
-
/** Remove a mode from a channel
* @param bi The client setting the modes
* @param cm The mode
@@ -213,14 +204,6 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
*/
void RemoveMode(BotInfo *bi, ChannelModeName Name, const Anope::string &param = "", bool EnforceMLock = true);
- /**
- * Remove a mode from a channel
- * @param bi The client setting the modes
- * @param Mode The mode
- * @param param Optional param arg for the mode
- * @param EnforceMLock true if mlocks should be enforced, false to override mlock
- */
- void RemoveMode(BotInfo *bi, char Mode, const Anope::string &param = "", bool EnforceMLock = true);
/** Clear all the modes from the channel
* @param bi The client unsetting the modes
diff --git a/include/extern.h b/include/extern.h
index 95a70657a..249ac6dfb 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -347,7 +347,7 @@ E User *finduser(const Anope::string &nick);
E Anope::string TS6SID;
-E User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid);
+E User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid, const Anope::string &modes);
E void do_umode(const Anope::string &source, int ac, const char **av);
E void do_quit(const Anope::string &source, int ac, const char **av);
@@ -361,8 +361,6 @@ E bool is_excepted_mask(ChannelInfo *ci, const Anope::string &mask);
E bool match_usermask(const Anope::string &mask, User *user);
E Anope::string create_mask(User *u);
-E void UserSetInternalModes(User *user, int ac, const char **av);
-
/******************************************************************************/
E void b64_encode(const Anope::string &src, Anope::string &target);
diff --git a/include/services.h b/include/services.h
index 8748bd290..95542c267 100644
--- a/include/services.h
+++ b/include/services.h
@@ -433,7 +433,6 @@ struct IRCDVar
int tsonmode; /* Timestamp on mode changes */
int omode; /* On the fly o:lines */
int umode; /* change user modes */
- int nickvhost; /* Users vhost sent during NICK */
int knock_needs_i; /* Check if we needed +i when setting NOKNOCK */
int svsmode_ucmode; /* Can remove User Channel Modes with SVSMODE */
int sglineenforce;
diff --git a/include/users.h b/include/users.h
index 82ca59681..5abf6bbca 100644
--- a/include/users.h
+++ b/include/users.h
@@ -233,13 +233,6 @@ class CoreExport User : public Extensible
*/
void SetMode(BotInfo *bi, UserModeName Name, const Anope::string &Param = "");
- /* Set a mode on the user
- * @param bi The client setting the mode
- * @param ModeChar The mode char
- * @param param Optional param for the mode
- */
- void SetMode(BotInfo *bi, char ModeChar, const Anope::string &Param = "");
-
/** Remove a mode on the user
* @param bi The client setting the mode
* @param um The user mode
@@ -252,18 +245,17 @@ class CoreExport User : public Extensible
*/
void RemoveMode(BotInfo *bi, UserModeName Name);
- /** Remove a mode from the user
- * @param bi The client setting the mode
- * @param ModeChar The mode char
- */
- void RemoveMode(BotInfo *bi, char ModeChar);
-
/** Set a string of modes on a user
- * @param bi The client setting the mode
+ * @param bi The client setting the modes
* @param umodes The modes
*/
void SetModes(BotInfo *bi, const char *umodes, ...);
+ /** Set a string of modes on a user internally
+ * @param umodes The modes
+ */
+ void SetModesInternal(const char *umodes, ...);
+
/** Find the channel container for Channel c that the user is on
* This is preferred over using FindUser in Channel, as there are usually more users in a channel
* than channels a user is in
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index c1a223672..efe5e4d16 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -33,7 +33,6 @@ IRCDVar myIrcd[] = {
1, /* time stamp on mode */
0, /* O:LINE */
1, /* UMODE */
- 0, /* VHOST ON NICK */
1, /* No Knock requires +i */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
@@ -446,23 +445,21 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
if (ac != 2)
{
- user = do_nick(source, av[0], av[4], av[5], av[6], av[9], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, av[8], "", "");
+ user = do_nick(source, av[0], av[4], av[5], av[6], av[9], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, av[8], "", "", av[3]);
if (user)
{
- UserSetInternalModes(user, 1, &av[3]);
-
NickAlias *na;
if (user->timestamp == convertTo<time_t>(av[7]) && (na = findnick(user->nick)))
{
user->Login(na->nc);
- user->SetMode(NickServ, CMODE_REGISTERED);
+ user->SetMode(NickServ, UMODE_REGISTERED);
}
else
validate_user(user);
}
}
else
- do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0, "", "", "");
+ do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0, "", "", "", "");
return MOD_CONT;
}
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index 8053a577a..c468c0f9a 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -34,7 +34,6 @@ IRCDVar myIrcd[] = {
0, /* time stamp on mode */
1, /* O:LINE */
1, /* UMODE */
- 1, /* VHOST ON NICK */
1, /* No Knock requires +i */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
@@ -693,10 +692,9 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
{
time_t ts = Anope::string(av[0]).is_pos_number_only() ? convertTo<time_t>(av[0]) : 0;
- user = do_nick("", av[1], av[4], av[2], source, av[7], ts, av[6], av[3], "");
+ user = do_nick("", av[1], av[4], av[2], source, av[7], ts, av[6], av[3], "", av[5]);
if (user)
{
- UserSetInternalModes(user, 1, &av[5]);
user->SetCloakedHost(av[3]);
NickAlias *na = findnick(user->nick);
@@ -712,7 +710,7 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
}
}
else
- do_nick(source, av[0], "", "", "", "", 0, "", "", "");
+ do_nick(source, av[0], "", "", "", "", 0, "", "", "", "");
return MOD_CONT;
}
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index 574fa7791..dc5e0f613 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -34,7 +34,6 @@ IRCDVar myIrcd[] = {
0, /* time stamp on mode */
0, /* O:LINE */
1, /* UMODE */
- 1, /* VHOST ON NICK */
1, /* No Knock requires +i */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
@@ -695,7 +694,7 @@ int anope_event_sethost(const Anope::string &source, int ac, const char **av)
int anope_event_nick(const Anope::string &source, int ac, const char **av)
{
- do_nick(source, av[0], "", "", "", "", 0, "", "", "");
+ do_nick(source, av[0], "", "", "", "", 0, "", "", "", "");
return MOD_CONT;
}
@@ -738,10 +737,12 @@ int anope_event_uid(const Anope::string &source, int ac, const char **av)
user->SetMode(NickServ, UMODE_REGISTERED);
}
- user = do_nick("", av[2], av[5], av[3], s->GetName(), av[ac - 1], ts, av[6], av[4], av[0]);
+ Anope::string modes = av[8];
+ for (int i = 9; i < ac - 1; ++i)
+ modes += Anope::string(" ") + av[i];
+ user = do_nick("", av[2], av[5], av[3], s->GetName(), av[ac - 1], ts, av[6], av[4], av[0], modes);
if (user)
{
- UserSetInternalModes(user, 1, &av[8]);
if (!user->server->IsSynced())
prev_u_intro = user;
else
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 4ebd9711c..5740c43b8 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -34,7 +34,6 @@ IRCDVar myIrcd[] = {
0, /* time stamp on mode */
0, /* O:LINE */
1, /* UMODE */
- 1, /* VHOST ON NICK */
1, /* No Knock requires +i */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
@@ -692,7 +691,7 @@ int anope_event_sethost(const Anope::string &source, int ac, const char **av)
int anope_event_nick(const Anope::string &source, int ac, const char **av)
{
- do_nick(source, av[0], "", "", "", "", 0, "", "", "");
+ do_nick(source, av[0], "", "", "", "", 0, "", "", "", "");
return MOD_CONT;
}
@@ -735,10 +734,12 @@ int anope_event_uid(const Anope::string &source, int ac, const char **av)
user->SetMode(NickServ, UMODE_REGISTERED);
}
- user = do_nick("", av[2], av[5], av[3], s->GetName(), av[ac - 1], ts, av[6], av[4], av[0]);
+ Anope::string modes = av[8];
+ for (int i = 9; i < ac - 1; ++i)
+ modes += Anope::string(" ") + av[i];
+ user = do_nick("", av[2], av[5], av[3], s->GetName(), av[ac - 1], ts, av[6], av[4], av[0], modes);
if (user)
{
- UserSetInternalModes(user, 1, &av[8]);
if (!user->server->IsSynced())
prev_u_intro = user;
else
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index 807abf202..cb937cf02 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -33,7 +33,6 @@ IRCDVar myIrcd[] = {
0, /* time stamp on mode */
0, /* UMODE */
0, /* O:LINE */
- 0, /* VHOST ON NICK */
0, /* No Knock requires +i */
0, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
@@ -405,11 +404,9 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
{
Server *s = Server::Find(source);
/* Source is always the server */
- user = do_nick("", av[0], av[4], av[5], s->GetName(), av[8], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, av[6], "*", av[7]);
+ user = do_nick("", av[0], av[4], av[5], s->GetName(), av[8], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, av[6], "*", av[7], av[3]);
if (user)
{
- UserSetInternalModes(user, 1, &av[3]);
-
NickAlias *na = findnick(user->nick);
Anope::string svidbuf;
if (na && na->nc->GetExtRegular("authenticationtoken", svidbuf) && svidbuf == av[2])
@@ -421,7 +418,7 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
}
}
else if (ac == 2)
- do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0, "", "", "");
+ do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0, "", "", "", "");
return MOD_CONT;
}
diff --git a/modules/protocol/unreal32.cpp b/modules/protocol/unreal32.cpp
index 81bd74aaa..d44eeca4b 100644
--- a/modules/protocol/unreal32.cpp
+++ b/modules/protocol/unreal32.cpp
@@ -33,7 +33,6 @@ IRCDVar myIrcd[] = {
1, /* time stamp on mode */
1, /* O:LINE */
1, /* UMODE */
- 1, /* VHOST ON NICK */
1, /* No Knock requires +i */
1, /* Can remove User Channel Modes with SVSMODE */
0, /* Sglines are not enforced until user reconnects */
@@ -679,10 +678,10 @@ int anope_event_umode2(const Anope::string &source, int ac, const char **av)
if (ac < 1)
return MOD_CONT;
- const char *newav[4];
+ const char *newav[2];
newav[0] = source.c_str();
newav[1] = av[0];
- do_umode(source, ac, newav);
+ do_umode(source, 2, newav);
return MOD_CONT;
}
@@ -841,11 +840,6 @@ int anope_event_sethost(const Anope::string &source, int ac, const char **av)
** parv[0] = new nickname
** parv[1] = hopcount
*/
-/*
- do_nick(const char *source, char *nick, char *username, char *host,
- char *server, char *realname, time_t ts,
- uint32 ip, char *vhost, char *uid)
-*/
int anope_event_nick(const Anope::string &source, int ac, const char **av)
{
User *user;
@@ -860,7 +854,7 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
<codemastr> it's sent when a nick collision occurs
- so we have to leave it around for now -TSL
*/
- do_nick(source, av[0], av[3], av[4], av[5], av[6], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, "", "*", "");
+ do_nick(source, av[0], av[3], av[4], av[5], av[6], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, "", "*", "", "");
}
else if (ac == 11)
{
@@ -869,12 +863,13 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
sockaddrs ip;
ip.ntop(strlen(av[9]) == 8 ? AF_INET : AF_INET6, decoded_ip.c_str());
+
+ if (av[8] && !strcmp(av[8], "*"))
+ av[8] = "";
- user = do_nick(source, av[0], av[3], av[4], av[5], av[10], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, ip.addr(), av[8], "");
+ user = do_nick(source, av[0], av[3], av[4], av[5], av[10], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, ip.addr(), av[8], "", av[7]);
if (user)
{
- UserSetInternalModes(user, 1, &av[7]);
-
NickAlias *na = findnick(user->nick);
if (na && user->timestamp == convertTo<time_t>(av[6]))
@@ -888,12 +883,13 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
}
else
{
+ if (av[8] && !strcmp(av[8], "*"))
+ av[8] = "";
+
/* NON NICKIP */
- user = do_nick(source, av[0], av[3], av[4], av[5], av[9], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, "", av[8], "");
+ user = do_nick(source, av[0], av[3], av[4], av[5], av[9], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, "", av[8], "", av[7]);
if (user)
{
- UserSetInternalModes(user, 1, &av[7]);
-
NickAlias *na = findnick(user->nick);
if (na && user->timestamp == convertTo<time_t>(av[6]))
@@ -907,7 +903,7 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
}
}
else
- do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0, "", "", "");
+ do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0, "", "", "", "");
return MOD_CONT;
}
diff --git a/src/channels.cpp b/src/channels.cpp
index 84870b1e9..8b3f053b1 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -587,18 +587,6 @@ void Channel::SetMode(BotInfo *bi, ChannelModeName Name, const Anope::string &pa
SetMode(bi, ModeManager::FindChannelModeByName(Name), param, EnforceMLock);
}
-/**
- * Set a mode on a channel
- * @param bi The client setting the modes
- * @param Mode The mode
- * @param param Optional param arg for the mode
- * @param EnforceMLock true if mlocks should be enforced, false to override mlock
- */
-void Channel::SetMode(BotInfo *bi, char Mode, const Anope::string &param, bool EnforceMLock)
-{
- SetMode(bi, ModeManager::FindChannelModeByChar(Mode), param, EnforceMLock);
-}
-
/** Remove a mode from a channel
* @param bi The client setting the modes
* @param cm The mode
@@ -649,18 +637,6 @@ void Channel::RemoveMode(BotInfo *bi, ChannelModeName Name, const Anope::string
RemoveMode(bi, ModeManager::FindChannelModeByName(Name), param, EnforceMLock);
}
-/**
- * Remove a mode from a channel
- * @param bi The client setting the modes
- * @param Mode The mode
- * @param param Optional param arg for the mode
- * @param EnforceMLock true if mlocks should be enforced, false to override mlock
- */
-void Channel::RemoveMode(BotInfo *bi, char Mode, const Anope::string &param, bool EnforceMLock)
-{
- RemoveMode(bi, ModeManager::FindChannelModeByChar(Mode), param, EnforceMLock);
-}
-
/** Get a param from the channel
* @param Name The mode
* @param Target a string to put the param into
diff --git a/src/sessions.cpp b/src/sessions.cpp
index a0ad66618..38dfedef5 100644
--- a/src/sessions.cpp
+++ b/src/sessions.cpp
@@ -98,7 +98,6 @@ Session *findsession(const Anope::string &host)
/* Attempt to add a host to the session list. If the addition of the new host
* causes the the session limit to be exceeded, kill the connecting user.
- * Returns 1 if the host was added or 0 if the user was killed.
*/
void add_session(const Anope::string &nick, const Anope::string &host, const Anope::string &hostip)
diff --git a/src/users.cpp b/src/users.cpp
index b6556175e..8ebe339ea 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -507,16 +507,6 @@ void User::SetMode(BotInfo *bi, UserModeName Name, const Anope::string &Param)
SetMode(bi, ModeManager::FindUserModeByName(Name), Param);
}
-/* Set a mode on the user
- * @param bi The client setting the mode
- * @param ModeChar The mode char
- * @param param Optional param for the mode
- */
-void User::SetMode(BotInfo *bi, char ModeChar, const Anope::string &Param)
-{
- SetMode(bi, ModeManager::FindUserModeByChar(ModeChar), Param);
-}
-
/** Remove a mode on the user
* @param bi The client setting the mode
* @param um The user mode
@@ -539,15 +529,6 @@ void User::RemoveMode(BotInfo *bi, UserModeName Name)
RemoveMode(bi, ModeManager::FindUserModeByName(Name));
}
-/** Remove a mode from the user
- * @param bi The client setting the mode
- * @param ModeChar The mode char
- */
-void User::RemoveMode(BotInfo *bi, char ModeChar)
-{
- RemoveMode(bi, ModeManager::FindUserModeByChar(ModeChar));
-}
-
/** Set a string of modes on a user
* @param bi The client setting the mode
* @param umodes The modes
@@ -596,6 +577,80 @@ void User::SetModes(BotInfo *bi, const char *umodes, ...)
}
}
+void User::SetModesInternal(const char *umodes, ...)
+{
+ char buf[BUFSIZE] = "";
+ va_list args;
+ Anope::string modebuf, sbuf;
+ int add = -1;
+ va_start(args, umodes);
+ vsnprintf(buf, BUFSIZE - 1, umodes, args);
+ va_end(args);
+
+ spacesepstream sep(buf);
+ sep.GetToken(modebuf);
+ for (unsigned i = 0, end = modebuf.length(); i < end; ++i)
+ {
+ UserMode *um;
+
+ switch (modebuf[i])
+ {
+ case '+':
+ add = 1;
+ continue;
+ case '-':
+ add = 0;
+ continue;
+ default:
+ if (add == -1)
+ continue;
+ um = ModeManager::FindUserModeByChar(modebuf[i]);
+ if (!um)
+ continue;
+ }
+
+ if (add)
+ {
+ if (um->Type == MODE_PARAM && sep.GetToken(sbuf))
+ this->SetModeInternal(um, sbuf);
+ else
+ this->SetModeInternal(um);
+ }
+ else
+ this->RemoveModeInternal(um);
+
+ switch (um->Name)
+ {
+ case UMODE_OPER:
+ if (add)
+ {
+ ++opcnt;
+ if (Config->WallOper)
+ ircdproto->SendGlobops(OperServ, "\2%s\2 is now an IRC operator.", this->nick.c_str());
+ Log(OperServ) << this->nick << " is now an IRC operator";
+ }
+ else
+ {
+ --opcnt;
+
+ Log(OperServ) << this->nick << " is no longer an IRC operator";
+ }
+ break;
+ case UMODE_REGISTERED:
+ if (add && !this->IsIdentified())
+ this->RemoveMode(NickServ, UMODE_REGISTERED);
+ break;
+ case UMODE_CLOAK:
+ case UMODE_VHOST:
+ if (!add && !this->vhost.empty())
+ this->vhost.clear();
+ this->UpdateHost();
+ default:
+ break;
+ }
+ }
+}
+
/** Find the channel container for Channel c that the user is on
* This is preferred over using FindUser in Channel, as there are usually more users in a channel
* than channels a user is in
@@ -669,30 +724,22 @@ User *finduser(const Anope::string &nick)
/* Handle a server NICK command. */
-User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid)
+User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid, const Anope::string &modes)
{
- User *user = NULL;
- Anope::string vhost2 = vhost;
-
if (source.empty())
{
- if (ircd->nickvhost && !vhost2.empty() && vhost2.equals_cs("*"))
- {
- vhost2.clear();
- }
-
/* This is a new user; create a User structure for it. */
Log(LOG_DEBUG) << "new user: " << nick;
Server *serv = Server::Find(server);
/* Allocate User structure and fill it in. */
- user = new User(nick, username, host, uid);
+ dynamic_reference<User> user = new User(nick, username, host, uid);
user->server = serv;
user->realname = realname;
user->timestamp = ts;
- if (!vhost2.empty())
- user->SetCloakedHost(vhost2);
+ if (!vhost.empty())
+ user->SetCloakedHost(vhost);
user->SetVIdent(username);
if (!ip.empty())
@@ -711,28 +758,33 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop
}
}
- Log(user, "connect") << (ircd->nickvhost && !vhost2.empty() ? Anope::string("(") + vhost2 + ")" : "") << " (" << user->realname << ") " << (user->ip() ? Anope::string("[") + user->ip.addr() + "] " : "") << "connected to the network (" << serv->GetName() << ")";
+ Log(*user, "connect") << (!vhost.empty() ? Anope::string("(") + vhost + ")" : "") << " (" << user->realname << ") " << (user->ip() ? Anope::string("[") + user->ip.addr() + "] " : "") << "connected to the network (" << serv->GetName() << ")";
EventReturn MOD_RESULT;
- FOREACH_RESULT(I_OnPreUserConnect, OnPreUserConnect(user));
+ FOREACH_RESULT(I_OnPreUserConnect, OnPreUserConnect(*user));
if (MOD_RESULT == EVENT_STOP)
- return finduser(nick);
+ return *user;
if (Config->LimitSessions && !serv->IsULined())
add_session(nick, host, user->ip() ? user->ip.addr() : "");
- XLineManager::CheckAll(user);
+ if (!user)
+ return NULL;
+
+ XLineManager::CheckAll(*user);
/* User is no longer connected, return */
- if (!finduser(nick))
+ if (!user)
return NULL;
- FOREACH_MOD(I_OnUserConnect, OnUserConnect(user));
+ FOREACH_MOD(I_OnUserConnect, OnUserConnect(*user));
+
+ return user ? *user : NULL;
}
else
{
/* An old user changing nicks. */
- user = finduser(source);
+ User *user = finduser(source);
if (!user)
{
@@ -789,9 +841,9 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop
return NULL;
}
}
- }
- return user;
+ return user;
+ }
}
/*************************************************************************/
@@ -810,7 +862,12 @@ void do_umode(const Anope::string &source, int ac, const char **av)
return;
}
- UserSetInternalModes(user, ac - 1, &av[1]);
+ Log(user, "mode") << "changes modes to " << merge_args(ac - 1, av + 1);
+
+ Anope::string modes = av[1];
+ for (int i = 2; i < ac; ++i)
+ modes += Anope::string(" ") + av[i];
+ user->SetModesInternal(modes.c_str());
}
/*************************************************************************/
@@ -972,85 +1029,3 @@ Anope::string create_mask(User *u)
return mask;
}
-/*************************************************************************/
-
-/** Set modes internally on a user
- * @param user The user
- * @param ac Number of args
- * @param av Args
- */
-void UserSetInternalModes(User *user, int ac, const char **av)
-{
- int add = -1, j = 0;
- const char *modes = av[0];
- if (!user || !modes)
- return;
-
- Log(user, "mode") << "changes modes to " << merge_args(ac, av);
-
- for (; *modes; ++modes)
- {
- UserMode *um;
-
- switch (*modes)
- {
- case '+':
- add = 1;
- continue;
- case '-':
- add = 0;
- continue;
- default:
- if (add == -1)
- continue;
- um = ModeManager::FindUserModeByChar(*modes);
- if (!um)
- continue;
- }
-
- if (um->Type == MODE_REGULAR)
- {
- if (add)
- user->SetModeInternal(um);
- else
- user->RemoveModeInternal(um);
- }
- else if (++j < ac)
- {
- if (add)
- user->SetModeInternal(um, av[j]);
- else
- user->RemoveModeInternal(um);
- }
-
- switch (um->Name)
- {
- case UMODE_OPER:
- if (add)
- {
- ++opcnt;
- if (Config->WallOper)
- ircdproto->SendGlobops(OperServ, "\2%s\2 is now an IRC operator.", user->nick.c_str());
- Log(OperServ) << user->nick << " is now an IRC operator";
- }
- else
- {
- --opcnt;
-
- Log(OperServ) << user->nick << " is no longer an IRC operator";
- }
- break;
- case UMODE_REGISTERED:
- if (add && !user->IsIdentified())
- user->RemoveMode(NickServ, UMODE_REGISTERED);
- break;
- case UMODE_CLOAK:
- case UMODE_VHOST:
- if (!add && !user->vhost.empty())
- user->vhost.clear();
- user->UpdateHost();
- default:
- break;
- }
- }
-}