summaryrefslogtreecommitdiff
path: root/src/coremods
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-10-22 21:53:24 +0100
committerPeter Powell <petpow@saberuk.com>2017-10-28 16:16:10 +0100
commitd865b434865907bfad0a187dd403d4ca8144e469 (patch)
tree4c36b1028ab02ca8ac2d07b867819f96f38c2745 /src/coremods
parent08f6f056667df63d1673bea959c73b75393113c6 (diff)
Hide User#host and User#dhost and use accessors to modify them.
This removes the need to invalidate the cache after changing a user's hostname.
Diffstat (limited to 'src/coremods')
-rw-r--r--src/coremods/core_hostname_lookup.cpp6
-rw-r--r--src/coremods/core_oper/cmd_kill.cpp2
-rw-r--r--src/coremods/core_oper/cmd_oper.cpp2
-rw-r--r--src/coremods/core_stats.cpp10
-rw-r--r--src/coremods/core_userhost.cpp2
-rw-r--r--src/coremods/core_who.cpp6
-rw-r--r--src/coremods/core_whois.cpp4
-rw-r--r--src/coremods/core_whowas.cpp4
8 files changed, 16 insertions, 20 deletions
diff --git a/src/coremods/core_hostname_lookup.cpp b/src/coremods/core_hostname_lookup.cpp
index d150b8551..2a8426be9 100644
--- a/src/coremods/core_hostname_lookup.cpp
+++ b/src/coremods/core_hostname_lookup.cpp
@@ -145,11 +145,7 @@ class UserResolver : public DNS::Request
hostname->insert(0, "0");
bound_user->WriteNotice("*** Found your hostname (" + *hostname + (r->cached ? ") -- cached" : ")"));
- bound_user->host.assign(*hostname, 0, ServerInstance->Config->Limits.MaxHost);
- bound_user->dhost = bound_user->host;
-
- /* Invalidate cache */
- bound_user->InvalidateCache();
+ bound_user->ChangeRealHost(hostname->substr(ServerInstance->Config->Limits.MaxHost), true);
}
else
{
diff --git a/src/coremods/core_oper/cmd_kill.cpp b/src/coremods/core_oper/cmd_kill.cpp
index 8e8c4fadc..8a453f7f1 100644
--- a/src/coremods/core_oper/cmd_kill.cpp
+++ b/src/coremods/core_oper/cmd_kill.cpp
@@ -102,7 +102,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User
ServerInstance->Logs->Log("KILL", LOG_DEFAULT, "%s KILL: %s :%s!%s!%s (%s)",
IS_LOCAL(user) && IS_LOCAL(target) ? "LOCAL" : "REMOTE",
target->nick.c_str(),
- ServerInstance->Config->ServerName.c_str(), user->dhost.c_str(), user->nick.c_str(),
+ ServerInstance->Config->ServerName.c_str(), user->GetDisplayedHost().c_str(), user->nick.c_str(),
parameters[1].c_str());
if (IS_LOCAL(target))
diff --git a/src/coremods/core_oper/cmd_oper.cpp b/src/coremods/core_oper/cmd_oper.cpp
index 9c06583a8..0322a059a 100644
--- a/src/coremods/core_oper/cmd_oper.cpp
+++ b/src/coremods/core_oper/cmd_oper.cpp
@@ -34,7 +34,7 @@ CmdResult CommandOper::HandleLocal(const std::vector<std::string>& parameters, L
bool match_pass = false;
bool match_hosts = false;
- const std::string userHost = user->ident + "@" + user->host;
+ const std::string userHost = user->ident + "@" + user->GetRealHost();
const std::string userIP = user->ident + "@" + user->GetIPString();
ServerConfig::OperIndex::const_iterator i = ServerInstance->Config->oper_blocks.find(parameters[0]);
diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp
index 9d1fdf3fe..7c3484917 100644
--- a/src/coremods/core_stats.cpp
+++ b/src/coremods/core_stats.cpp
@@ -58,7 +58,7 @@ static void GenerateStatsLl(Stats::Context& stats)
for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
{
LocalUser* u = *i;
- stats.AddRow(211, u->nick+"["+u->ident+"@"+(stats.GetSymbol() == 'l' ? u->dhost : u->GetIPString())+"] "+ConvToStr(u->eh.getSendQSize())+" "+ConvToStr(u->cmds_out)+" "+ConvToStr(u->bytes_out)+" "+ConvToStr(u->cmds_in)+" "+ConvToStr(u->bytes_in)+" "+ConvToStr(ServerInstance->Time() - u->signon));
+ stats.AddRow(211, u->nick+"["+u->ident+"@"+(stats.GetSymbol() == 'l' ? u->GetDisplayedHost() : u->GetIPString())+"] "+ConvToStr(u->eh.getSendQSize())+" "+ConvToStr(u->cmds_out)+" "+ConvToStr(u->bytes_out)+" "+ConvToStr(u->cmds_in)+" "+ConvToStr(u->bytes_in)+" "+ConvToStr(ServerInstance->Time() - u->signon));
}
}
@@ -76,7 +76,7 @@ void CommandStats::DoStats(Stats::Context& stats)
ServerInstance->SNO->WriteToSnoMask('t',
"%s '%c' denied for %s (%s@%s)",
(IS_LOCAL(user) ? "Stats" : "Remote stats"),
- statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str());
+ statschar, user->nick.c_str(), user->ident.c_str(), user->GetRealHost().c_str());
stats.AddRow(481, (std::string("Permission Denied - STATS ") + statschar + " requires the servers/auspex priv."));
return;
}
@@ -87,7 +87,7 @@ void CommandStats::DoStats(Stats::Context& stats)
{
stats.AddRow(219, statschar, "End of /STATS report");
ServerInstance->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)",
- (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str());
+ (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->GetRealHost().c_str());
return;
}
@@ -167,7 +167,7 @@ void CommandStats::DoStats(Stats::Context& stats)
if (!oper->server->IsULine())
{
LocalUser* lu = IS_LOCAL(oper);
- stats.AddRow(249, oper->nick + " (" + oper->ident + "@" + oper->dhost + ") Idle: " +
+ stats.AddRow(249, oper->nick + " (" + oper->ident + "@" + oper->GetDisplayedHost() + ") Idle: " +
(lu ? ConvToStr(ServerInstance->Time() - lu->idle_lastmsg) + " secs" : "unavailable"));
idx++;
}
@@ -360,7 +360,7 @@ void CommandStats::DoStats(Stats::Context& stats)
stats.AddRow(219, statschar, "End of /STATS report");
ServerInstance->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)",
- (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str());
+ (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->GetRealHost().c_str());
return;
}
diff --git a/src/coremods/core_userhost.cpp b/src/coremods/core_userhost.cpp
index 3100995a8..7ee093cdb 100644
--- a/src/coremods/core_userhost.cpp
+++ b/src/coremods/core_userhost.cpp
@@ -72,7 +72,7 @@ CmdResult CommandUserhost::Handle (const std::vector<std::string>& parameters, U
retbuf += (u->IsAway() ? '-' : '+');
retbuf += u->ident;
retbuf += '@';
- retbuf += (((u == user) || (has_privs)) ? u->host : u->dhost);
+ retbuf += u->GetHost(u == user || has_privs);
retbuf += ' ';
}
}
diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp
index 677a1eb6d..196bf0479 100644
--- a/src/coremods/core_who.cpp
+++ b/src/coremods/core_who.cpp
@@ -128,7 +128,7 @@ bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext)
else if (opt_realname)
match = InspIRCd::Match(user->fullname, matchtext);
else if (opt_showrealhost)
- match = InspIRCd::Match(user->host, matchtext, ascii_case_insensitive_map);
+ match = InspIRCd::Match(user->GetRealHost(), matchtext, ascii_case_insensitive_map);
else if (opt_ident)
match = InspIRCd::Match(user->ident, matchtext, ascii_case_insensitive_map);
else if (opt_port)
@@ -161,7 +161,7 @@ bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext)
* -- w00t
*/
if (!match)
- match = InspIRCd::Match(user->dhost, matchtext, ascii_case_insensitive_map);
+ match = InspIRCd::Match(user->GetDisplayedHost(), matchtext, ascii_case_insensitive_map);
if (!match)
match = InspIRCd::Match(user->nick, matchtext);
@@ -198,7 +198,7 @@ void CommandWho::SendWhoLine(User* user, const std::vector<std::string>& parms,
Numeric::Numeric wholine(RPL_WHOREPLY);
wholine.push(memb ? memb->chan->name : "*").push(u->ident);
- wholine.push(opt_showrealhost ? u->host : u->dhost);
+ wholine.push(u->GetHost(opt_showrealhost));
if (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex"))
wholine.push(ServerInstance->Config->HideWhoisServer);
else
diff --git a/src/coremods/core_whois.cpp b/src/coremods/core_whois.cpp
index 81e62c8e5..c2fac7577 100644
--- a/src/coremods/core_whois.cpp
+++ b/src/coremods/core_whois.cpp
@@ -177,10 +177,10 @@ void CommandWhois::DoWhois(LocalUser* user, User* dest, unsigned long signon, un
{
WhoisContextImpl whois(user, dest, lineevprov);
- whois.SendLine(311, dest->ident, dest->dhost, '*', dest->fullname);
+ whois.SendLine(311, dest->ident, dest->GetDisplayedHost(), '*', dest->fullname);
if (whois.IsSelfWhois() || user->HasPrivPermission("users/auspex"))
{
- whois.SendLine(378, InspIRCd::Format("is connecting from %s@%s %s", dest->ident.c_str(), dest->host.c_str(), dest->GetIPString().c_str()));
+ whois.SendLine(378, InspIRCd::Format("is connecting from %s@%s %s", dest->ident.c_str(), dest->GetRealHost().c_str(), dest->GetIPString().c_str()));
}
SendChanList(whois);
diff --git a/src/coremods/core_whowas.cpp b/src/coremods/core_whowas.cpp
index 0bb47b273..af1f99737 100644
--- a/src/coremods/core_whowas.cpp
+++ b/src/coremods/core_whowas.cpp
@@ -230,8 +230,8 @@ void WhoWas::Manager::PurgeNick(WhoWas::Nick* nick)
}
WhoWas::Entry::Entry(User* user)
- : host(user->host)
- , dhost(user->dhost)
+ : host(user->GetRealHost())
+ , dhost(user->GetDisplayedHost())
, ident(user->ident)
, server(user->server->GetName())
, gecos(user->fullname)