mirror of
https://github.com/anope/anope.git
synced 2026-06-29 12:16:38 +02:00
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
This commit is contained in:
@@ -188,15 +188,6 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
|
||||
*/
|
||||
void SetMode(BotInfo *bi, ChannelModeName Name, const Anope::string ¶m = "", 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 ¶m = "", 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 ¶m = "", 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 ¶m = "", bool EnforceMLock = true);
|
||||
|
||||
/** Clear all the modes from the channel
|
||||
* @param bi The client unsetting the modes
|
||||
|
||||
+1
-3
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
+6
-14
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ¶m, 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 ¶m, 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
|
||||
|
||||
@@ -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)
|
||||
|
||||
+100
-125
@@ -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);
|
||||
|
||||
/* User is no longer connected, return */
|
||||
if (!finduser(nick))
|
||||
if (!user)
|
||||
return NULL;
|
||||
|
||||
FOREACH_MOD(I_OnUserConnect, OnUserConnect(user));
|
||||
XLineManager::CheckAll(*user);
|
||||
|
||||
/* User is no longer connected, return */
|
||||
if (!user)
|
||||
return NULL;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user