diff options
-rw-r--r-- | include/users.h | 60 | ||||
-rw-r--r-- | src/commands/cmd_notice.cpp | 8 | ||||
-rw-r--r-- | src/commands/cmd_privmsg.cpp | 8 | ||||
-rw-r--r-- | src/commands/cmd_stats.cpp | 3 | ||||
-rw-r--r-- | src/commands/cmd_whois.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_cgiirc.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_check.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_rline.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_setidle.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_shun.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_spanningtree/idle.cpp | 3 | ||||
-rw-r--r-- | src/users.cpp | 9 | ||||
-rw-r--r-- | src/xline.cpp | 20 |
13 files changed, 79 insertions, 61 deletions
diff --git a/include/users.h b/include/users.h index c79bf7cb8..102e7783f 100644 --- a/include/users.h +++ b/include/users.h @@ -267,10 +267,6 @@ class CoreExport User : public Extensible */ time_t signon; - /** Time that the connection last sent a message, used to calculate idle time - */ - time_t idle_lastmsg; - /** Client address that the user is connected from. * Do not modify this value directly, use SetClientIP() to change it. * Port is not valid for remote users. @@ -347,12 +343,6 @@ class CoreExport User : public Extensible */ unsigned int registered:3; - /** True when DNS lookups are completed. - * The UserResolver classes res_forward and res_reverse will - * set this value once they complete. - */ - unsigned int dns_done:1; - /** Whether or not to send an snotice about this user's quitting */ unsigned int quietquit:1; @@ -364,20 +354,6 @@ class CoreExport User : public Extensible */ unsigned int quitting:1; - /** Recursion fix: user is out of SendQ and will be quit as soon as possible. - * This can't be handled normally because QuitUser itself calls Write on other - * users, which could trigger their SendQ to overrun. - */ - unsigned int quitting_sendq:1; - - /** This is true if the user matched an exception (E:Line). It is used to save time on ban checks. - */ - unsigned int exempt:1; - - /** has the user responded to their previous ping? - */ - unsigned int lastping:1; - /** What type of user is this? */ const unsigned int usertype:2; @@ -402,12 +378,6 @@ class CoreExport User : public Extensible */ User(const std::string &uid, const std::string& srv, int objtype); - /** Check if the user matches a G or K line, and disconnect them if they do. - * @param doZline True if ZLines should be checked (if IP has changed since initial connect) - * Returns true if the user matched a ban, false else. - */ - bool CheckLines(bool doZline = false); - /** Returns the full displayed host of the user * This member function returns the hostname of the user as seen by other users * on the server, in nick!ident\@host form. @@ -792,10 +762,34 @@ class CoreExport LocalUser : public User, public InviteBase */ int GetServerPort(); + /** Recursion fix: user is out of SendQ and will be quit as soon as possible. + * This can't be handled normally because QuitUser itself calls Write on other + * users, which could trigger their SendQ to overrun. + */ + unsigned int quitting_sendq:1; + + /** True when DNS lookups are completed. + * The UserResolver classes res_forward and res_reverse will + * set this value once they complete. + */ + unsigned int dns_done:1; + + /** has the user responded to their previous ping? + */ + unsigned int lastping:1; + + /** This is true if the user matched an exception (E:Line). It is used to save time on ban checks. + */ + unsigned int exempt:1; + /** Used by PING checking code */ time_t nping; + /** Time that the connection last sent a message, used to calculate idle time + */ + time_t idle_lastmsg; + /** This value contains how far into the penalty threshold the user is. * This is used either to enable fake lag or for excess flood quits */ @@ -814,6 +808,12 @@ class CoreExport LocalUser : public User, public InviteBase */ void StartDNSLookup(); + /** Check if the user matches a G or K line, and disconnect them if they do. + * @param doZline True if ZLines should be checked (if IP has changed since initial connect) + * Returns true if the user matched a ban, false else. + */ + bool CheckLines(bool doZline = false); + /** Use this method to fully connect a user. * This will send the message of the day, check G/K/E lines, etc. */ diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp index d5ef7ba1d..d0845a051 100644 --- a/src/commands/cmd_notice.cpp +++ b/src/commands/cmd_notice.cpp @@ -57,7 +57,9 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use CUList exempt_list; - user->idle_lastmsg = ServerInstance->Time(); + LocalUser* localuser = IS_LOCAL(user); + if (localuser) + localuser->idle_lastmsg = ServerInstance->Time(); if (ServerInstance->Parser->LoopCall(user, this, parameters, 0)) return CMD_SUCCESS; @@ -98,7 +100,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use if (chan) { - if (IS_LOCAL(user)) + if (localuser) { if ((chan->IsModeSet('n')) && (!chan->HasUser(user))) { @@ -166,7 +168,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use const char* destnick = parameters[0].c_str(); - if (IS_LOCAL(user)) + if (localuser) { const char* targetserver = strchr(destnick, '@'); diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp index cefdd4800..09314e8a9 100644 --- a/src/commands/cmd_privmsg.cpp +++ b/src/commands/cmd_privmsg.cpp @@ -56,7 +56,9 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us Channel *chan; CUList except_list; - user->idle_lastmsg = ServerInstance->Time(); + LocalUser* localuser = IS_LOCAL(user); + if (localuser) + localuser->idle_lastmsg = ServerInstance->Time(); if (ServerInstance->Parser->LoopCall(user, this, parameters, 0)) return CMD_SUCCESS; @@ -99,7 +101,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us if (chan) { - if (IS_LOCAL(user) && chan->GetPrefixValue(user) < VOICE_VALUE) + if (localuser && chan->GetPrefixValue(user) < VOICE_VALUE) { if (chan->IsModeSet('n') && !chan->HasUser(user)) { @@ -169,7 +171,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us const char* destnick = parameters[0].c_str(); - if (IS_LOCAL(user)) + if (localuser) { const char* targetserver = strchr(destnick, '@'); diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index 898e89a7d..c37b041a9 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -167,8 +167,9 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results) User* oper = *i; if (!ServerInstance->ULine(oper->server)) { + LocalUser* lu = IS_LOCAL(oper); results.push_back(sn+" 249 " + user->nick + " :" + oper->nick + " (" + oper->ident + "@" + oper->dhost + ") Idle: " + - (IS_LOCAL(oper) ? ConvToStr(ServerInstance->Time() - oper->idle_lastmsg) + " secs" : "unavailable")); + (lu ? ConvToStr(ServerInstance->Time() - lu->idle_lastmsg) + " secs" : "unavailable")); idx++; } } diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp index ba2ad9c15..3a07fce7b 100644 --- a/src/commands/cmd_whois.cpp +++ b/src/commands/cmd_whois.cpp @@ -74,9 +74,10 @@ CmdResult CommandWhois::Handle (const std::vector<std::string>& parameters, User * For remote users (/w remoteuser remoteuser), spanningtree will handle calling do_whois, so we can ignore this case. * Thanks to djGrrr for not being impatient while I have a crap day coding. :p -- w00t */ - if (IS_LOCAL(dest) && (ServerInstance->Config->HideWhoisServer.empty() || parameters.size() > 1)) + LocalUser* localuser = IS_LOCAL(dest); + if (localuser && (ServerInstance->Config->HideWhoisServer.empty() || parameters.size() > 1)) { - idle = abs((long)((dest->idle_lastmsg)-ServerInstance->Time())); + idle = abs((long)((localuser->idle_lastmsg)-ServerInstance->Time())); signon = dest->signon; } diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index d4ef602b3..39833f1a0 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -136,6 +136,10 @@ class CGIResolver : public Resolver User* them = ServerInstance->FindUUID(theiruid); if ((them) && (!them->quitting)) { + LocalUser* lu = IS_LOCAL(them); + if (!lu) + return; + if (notify) ServerInstance->SNO->WriteGlobalSno('a', "Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", them->nick.c_str(), them->host.c_str(), result.c_str(), typ.c_str()); @@ -144,7 +148,7 @@ class CGIResolver : public Resolver them->host = result; them->dhost = result; them->InvalidateCache(); - them->CheckLines(true); + lu->CheckLines(true); } } diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 07276445f..2c46401ae 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -96,7 +96,7 @@ class CommandCheck : public Command user->SendText(checkstr + " signon " + timestring(targuser->signon)); user->SendText(checkstr + " nickts " + timestring(targuser->age)); if (loctarg) - user->SendText(checkstr + " lastmsg " + timestring(targuser->idle_lastmsg)); + user->SendText(checkstr + " lastmsg " + timestring(loctarg->idle_lastmsg)); if (IS_AWAY(targuser)) { diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index a234c02c6..68e3594a5 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -61,7 +61,8 @@ class RLine : public XLine bool Matches(User *u) { - if (u->exempt) + LocalUser* lu = IS_LOCAL(u); + if (lu && lu->exempt) return false; std::string compare = u->nick + "!" + u->ident + "@" + u->host + " " + u->fullname; @@ -117,7 +118,7 @@ class RLineFactory : public XLineFactory RLineFactory(dynamic_reference<RegexFactory>& rx) : XLineFactory("R"), rxfactory(rx) { } - + /** Generate a RLine */ XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) diff --git a/src/modules/m_setidle.cpp b/src/modules/m_setidle.cpp index fdb29d14f..7423e2672 100644 --- a/src/modules/m_setidle.cpp +++ b/src/modules/m_setidle.cpp @@ -25,16 +25,16 @@ /** Handle /SETIDLE */ -class CommandSetidle : public Command +class CommandSetidle : public SplitCommand { public: - CommandSetidle(Module* Creator) : Command(Creator,"SETIDLE", 1) + CommandSetidle(Module* Creator) : SplitCommand(Creator,"SETIDLE", 1) { flags_needed = 'o'; syntax = "<duration>"; TRANSLATE2(TR_TEXT, TR_END); } - CmdResult Handle (const std::vector<std::string>& parameters, User *user) + CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user) { time_t idle = ServerInstance->Duration(parameters[0]); if (idle < 1) diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 21959e400..c858e62ec 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -43,7 +43,8 @@ public: bool Matches(User *u) { // E: overrides shun - if (u->exempt) + LocalUser* lu = IS_LOCAL(u); + if (lu && lu->exempt) return false; if (InspIRCd::Match(u->GetFullHost(), matchtext) || InspIRCd::Match(u->GetFullRealHost(), matchtext) || InspIRCd::Match(u->nick+"!"+u->ident+"@"+u->GetIPString(), matchtext)) @@ -107,7 +108,7 @@ class CommandShun : public Command /* 'time' is a human-readable timestring, like 2d3h2s. */ std::string target = parameters[0]; - + User *find = ServerInstance->FindNick(target); if ((find) && (find->registered == REG_ALL)) target = std::string("*!*@") + find->GetIPString(); diff --git a/src/modules/m_spanningtree/idle.cpp b/src/modules/m_spanningtree/idle.cpp index 8bc0cd2bb..70453b975 100644 --- a/src/modules/m_spanningtree/idle.cpp +++ b/src/modules/m_spanningtree/idle.cpp @@ -40,7 +40,8 @@ bool TreeSocket::Whois(const std::string &prefix, parameterlist ¶ms) User* x = ServerInstance->FindNick(params[0]); if ((x) && (IS_LOCAL(x))) { - long idle = abs((long)((x->idle_lastmsg) - ServerInstance->Time())); + LocalUser* lu = IS_LOCAL(x); + long idle = abs((long)((lu->idle_lastmsg) - ServerInstance->Time())); parameterlist par; par.push_back(prefix); par.push_back(ConvToStr(x->signon)); diff --git a/src/users.cpp b/src/users.cpp index cb07707cd..4241b8f81 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -201,10 +201,9 @@ User::User(const std::string &uid, const std::string& sid, int type) : uuid(uid), server(sid), usertype(type) { age = ServerInstance->Time(); - signon = idle_lastmsg = 0; + signon = 0; registered = 0; - quietquit = quitting = exempt = dns_done = false; - quitting_sendq = false; + quietquit = quitting = false; client_sa.sa.sa_family = AF_UNSPEC; ServerInstance->Logs->Log("USERS", DEBUG, "New UUID for user: %s", uuid.c_str()); @@ -222,6 +221,8 @@ LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::so bytes_in(0), bytes_out(0), cmds_in(0), cmds_out(0), nping(0), CommandFloodPenalty(0), already_sent(0) { + exempt = quitting_sendq = dns_done = false; + idle_lastmsg = 0; ident = "unknown"; lastping = 0; eh.SetFd(myfd); @@ -734,7 +735,7 @@ void LocalUser::CheckClass() this->nping = ServerInstance->Time() + a->GetPingTime() + ServerInstance->Config->dns_timeout; } -bool User::CheckLines(bool doZline) +bool LocalUser::CheckLines(bool doZline) { const char* check[] = { "G" , "K", (doZline) ? "Z" : NULL, NULL }; diff --git a/src/xline.cpp b/src/xline.cpp index 66d24f439..1f192e22a 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -158,7 +158,7 @@ void XLineManager::CheckELines() for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) { - User* u = (User*)(*u2); + LocalUser* u = *u2; /* This uses safe iteration to ensure that if a line expires here, it doenst trash the iterator */ LookupIter safei; @@ -328,7 +328,7 @@ void ELine::Unset() /* remove exempt from everyone and force recheck after deleting eline */ for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) { - User* u = (User*)(*u2); + LocalUser* u = *u2; u->exempt = false; } @@ -433,7 +433,7 @@ void XLineManager::ApplyLines() LocalUserList::reverse_iterator u2 = ServerInstance->Users->local_users.rbegin(); while (u2 != ServerInstance->Users->local_users.rend()) { - User* u = *u2++; + LocalUser* u = *u2++; // Don't ban people who are exempt. if (u->exempt) @@ -554,7 +554,8 @@ void XLine::DefaultApply(User* u, const std::string &line, bool bancache) bool KLine::Matches(User *u) { - if (u->exempt) + LocalUser* lu = IS_LOCAL(u); + if (lu && lu->exempt) return false; if (InspIRCd::Match(u->ident, this->identmask, ascii_case_insensitive_map)) @@ -576,7 +577,8 @@ void KLine::Apply(User* u) bool GLine::Matches(User *u) { - if (u->exempt) + LocalUser* lu = IS_LOCAL(u); + if (lu && lu->exempt) return false; if (InspIRCd::Match(u->ident, this->identmask, ascii_case_insensitive_map)) @@ -598,7 +600,8 @@ void GLine::Apply(User* u) bool ELine::Matches(User *u) { - if (u->exempt) + LocalUser* lu = IS_LOCAL(u); + if (lu && lu->exempt) return false; if (InspIRCd::Match(u->ident, this->identmask, ascii_case_insensitive_map)) @@ -615,7 +618,8 @@ bool ELine::Matches(User *u) bool ZLine::Matches(User *u) { - if (u->exempt) + LocalUser* lu = IS_LOCAL(u); + if (lu && lu->exempt) return false; if (InspIRCd::MatchCIDR(u->GetIPString(), this->ipaddr)) @@ -681,7 +685,7 @@ void ELine::OnAdd() /* When adding one eline, only check the one eline */ for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) { - User* u = (User*)(*u2); + LocalUser* u = *u2; if (this->Matches(u)) u->exempt = true; } |