void PopulateUserInfo(User* user, ParamM& userinfo)
{
userinfo["nick"] = user->nick;
- userinfo["host"] = user->host;
+ userinfo["host"] = user->GetRealHost();
userinfo["ip"] = user->GetIPString();
userinfo["gecos"] = user->fullname;
userinfo["ident"] = user->ident;
*/
std::string cachedip;
+ /** If set then the hostname which is displayed to users. */
+ std::string displayhost;
+
+ /** The real hostname of this user. */
+ std::string realhost;
+
/** The user's mode list.
* Much love to the STL for giving us an easy to use bitset, saving us RAM.
* if (modes[modeid]) is set, then the mode is set.
*/
typedef insp::intrusive_list<Membership> ChanList;
- /** Hostname of connection.
- * This should be valid as per RFC1035.
- */
- std::string host;
-
/** Time that the object was instantiated (used for TS calculation etc)
*/
time_t age;
*/
std::string ident;
- /** The host displayed to non-opers (used for cloaking etc).
- * This usually matches the value of User::host.
- */
- std::string dhost;
-
/** The users full name (GECOS).
*/
std::string fullname;
*/
const std::string& GetIPString();
+ /** Retrieves this user's hostname.
+ * @param uncloak If true then return the real host; otherwise, the display host.
+ */
+ const std::string& GetHost(bool uncloak) const;
+
+ /** Retrieves this user's displayed hostname. */
+ const std::string& GetDisplayedHost() const;
+
+ /** Retrieves this user's real hostname. */
+ const std::string& GetRealHost() const;
+
/** Get CIDR mask, using default range, for this user
*/
irc::sockets::cidr_mask GetCIDRMask();
*/
bool SharesChannelWith(User *other);
- /** Change the displayed host of a user.
- * ALWAYS use this function, rather than writing User::dhost directly,
- * as this triggers module events allowing the change to be syncronized to
- * remote servers.
- * @param host The new hostname to set
- * @return True if the change succeeded, false if it didn't
- * (a module vetoed the change).
+ /** Change the displayed hostname of this user.
+ * @param host The new displayed hostname of this user.
+ * @return True if the hostname was changed successfully; otherwise, false.
*/
bool ChangeDisplayedHost(const std::string& host);
+ /** Change the real hostname of this user.
+ * @param host The new real hostname of this user.
+ * @param resetdisplay Whether to reset the display host to this value.
+ */
+ void ChangeRealHost(const std::string& host, bool resetdisplay);
+
/** Change the ident (username) of a user.
* ALWAYS use this function, rather than writing User::ident directly,
* as this triggers module events allowing the change to be syncronized to
if (InspIRCd::Match(nickIdent, prefix, NULL))
{
std::string suffix(mask, at + 1);
- if (InspIRCd::Match(user->host, suffix, NULL) ||
- InspIRCd::Match(user->dhost, suffix, NULL) ||
+ if (InspIRCd::Match(user->GetRealHost(), suffix, NULL) ||
+ InspIRCd::Match(user->GetDisplayedHost(), suffix, NULL) ||
InspIRCd::MatchCIDR(user->GetIPString(), suffix, NULL))
return true;
}
}
ServerInstance->SNO->WriteToSnoMask('a', "%s denied for %s (%s@%s)",
- command.c_str(), user->nick.c_str(), user->ident.c_str(), user->host.c_str());
+ command.c_str(), user->nick.c_str(), user->ident.c_str(), user->GetRealHost().c_str());
return;
}
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
{
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))
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]);
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));
}
}
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;
}
{
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;
}
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++;
}
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;
}
retbuf += (u->IsAway() ? '-' : '+');
retbuf += u->ident;
retbuf += '@';
- retbuf += (((u == user) || (has_privs)) ? u->host : u->dhost);
+ retbuf += u->GetHost(u == user || has_privs);
retbuf += ' ';
}
}
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)
* -- 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);
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
{
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);
}
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)
}
else if (!newline.compare(i, 5, "$host", 5))
{
- result.append(user->host);
+ result.append(user->GetRealHost());
i += 4;
}
else if (!newline.compare(i, 5, "$chan", 5))
}
else if (!newline.compare(i, 6, "$vhost", 6))
{
- result.append(user->dhost);
+ result.append(user->GetDisplayedHost());
i += 5;
}
else if (!newline.compare(i, 12, "$requirement", 12))
if (now > (dat->lastnotify + (time_t)notify_cooldown))
{
user->WriteNumeric(RPL_TARGNOTIFY, dest->nick, "has been informed that you messaged them.");
- dest->WriteRemoteNumeric(RPL_UMODEGMSG, user->nick, InspIRCd::Format("%s@%s", user->ident.c_str(), user->dhost.c_str()), InspIRCd::Format("is messaging you, and you have umode +g. Use /ACCEPT +%s to allow.",
+ dest->WriteRemoteNumeric(RPL_UMODEGMSG, user->nick, InspIRCd::Format("%s@%s", user->ident.c_str(), user->GetDisplayedHost().c_str()), InspIRCd::Format("is messaging you, and you have umode +g. Use /ACCEPT +%s to allow.",
user->nick.c_str()));
dat->lastnotify = now;
}
return false;
// Does the user's hostname match our hostmask?
- if (InspIRCd::Match(user->host, hostmask, ascii_case_insensitive_map))
+ if (InspIRCd::Match(user->GetRealHost(), hostmask, ascii_case_insensitive_map))
return true;
// Does the user's IP address match our hostmask?
// The user matched a WebIRC block!
gateway.set(user, parameters[1]);
- realhost.set(user, user->host);
+ realhost.set(user, user->GetRealHost());
realip.set(user, user->GetIPString());
if (notify)
ServerInstance->SNO->WriteGlobalSno('w', "Connecting user %s is using a WebIRC gateway; changing their IP/host from %s/%s to %s/%s.",
- user->nick.c_str(), user->GetIPString().c_str(), user->host.c_str(), parameters[3].c_str(), newhost.c_str());
+ user->nick.c_str(), user->GetIPString().c_str(), user->GetRealHost().c_str(), parameters[3].c_str(), newhost.c_str());
// Set the IP address and hostname sent via WEBIRC.
ChangeIP(user, parameters[3]);
- user->host = user->dhost = newhost;
- user->InvalidateCache();
+ user->ChangeRealHost(newhost, true);
return CMD_SUCCESS;
}
return;
if (notify)
- ServerInstance->SNO->WriteGlobalSno('w', "Connecting user %s detected as using CGI:IRC (%s), changing real host to %s", them->nick.c_str(), them->host.c_str(), ans_record.rdata.c_str());
+ ServerInstance->SNO->WriteGlobalSno('w', "Connecting user %s detected as using CGI:IRC (%s), changing real host to %s", them->nick.c_str(), them->GetRealHost().c_str(), ans_record.rdata.c_str());
- them->host = them->dhost = ans_record.rdata;
- them->InvalidateCache();
+ them->ChangeRealHost(ans_record.rdata, true);
lu->CheckLines(true);
}
}
User* them = ServerInstance->FindUUID(theiruid);
if ((them) && (!them->quitting))
{
- ServerInstance->SNO->WriteToSnoMask('w', "Connecting user %s detected as using CGI:IRC (%s), but their host can't be resolved!", them->nick.c_str(), them->host.c_str());
+ ServerInstance->SNO->WriteToSnoMask('w', "Connecting user %s detected as using CGI:IRC (%s), but their host can't be resolved!", them->nick.c_str(), them->GetRealHost().c_str());
}
}
void HandleIdent(LocalUser* user, const std::string& newip)
{
- cmd.realhost.set(user, user->host);
+ cmd.realhost.set(user, user->GetRealHost());
cmd.realip.set(user, user->GetIPString());
ChangeIP(user, newip);
- user->host = user->dhost = user->GetIPString();
- user->InvalidateCache();
+ user->ChangeRealHost(user->GetIPString(), true);
RecheckClass(user);
// Don't create the resolver if the core couldn't put the user in a connect class or when dns is disabled
waiting.set(user, count - 1);
delete r;
if (cmd.notify)
- ServerInstance->SNO->WriteToSnoMask('w', "Connecting user %s detected as using CGI:IRC (%s), but I could not resolve their hostname; %s", user->nick.c_str(), user->host.c_str(), ex.GetReason().c_str());
+ ServerInstance->SNO->WriteToSnoMask('w', "Connecting user %s detected as using CGI:IRC (%s), but I could not resolve their hostname; %s", user->nick.c_str(), user->GetRealHost().c_str(), ex.GetReason().c_str());
}
}
{
for (std::vector<std::string>::const_iterator iter = hosts.begin(); iter != hosts.end(); ++iter)
{
- if (!InspIRCd::Match(user->host, *iter, ascii_case_insensitive_map) && !InspIRCd::MatchCIDR(user->GetIPString(), *iter, ascii_case_insensitive_map))
+ if (!InspIRCd::Match(user->GetRealHost(), *iter, ascii_case_insensitive_map) && !InspIRCd::MatchCIDR(user->GetIPString(), *iter, ascii_case_insensitive_map))
continue;
CheckIdent(user); // Nothing on failure.
const UserManager::CloneCounts& clonecount = ServerInstance->Users->GetCloneCounts(i->first);
context.Write("member", InspIRCd::Format("%-3u %s%s (%s@%s) %s ", clonecount.global,
i->second->GetAllPrefixChars().c_str(), i->first->nick.c_str(),
- i->first->ident.c_str(), i->first->dhost.c_str(), i->first->fullname.c_str()));
+ i->first->ident.c_str(), i->first->GetDisplayedHost().c_str(), i->first->fullname.c_str()));
}
const ModeParser::ListModeList& listmodes = ServerInstance->Modes->GetListModes();
const user_hash& users = ServerInstance->Users->GetUsers();
for (user_hash::const_iterator a = users.begin(); a != users.end(); ++a)
{
- if (InspIRCd::Match(a->second->host, parameters[0], ascii_case_insensitive_map) || InspIRCd::Match(a->second->dhost, parameters[0], ascii_case_insensitive_map))
+ if (InspIRCd::Match(a->second->GetRealHost(), parameters[0], ascii_case_insensitive_map) || InspIRCd::Match(a->second->GetDisplayedHost(), parameters[0], ascii_case_insensitive_map))
{
/* host or vhost matches mask */
context.Write("match", ConvToStr(++x) + " " + a->second->GetFullRealHost() + " " + a->second->GetIPString() + " " + a->second->fullname);
if ((dest->ChangeDisplayedHost(parameters[1])) && (!user->server->IsULine()))
{
// fix by brain - ulines set hosts silently
- ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used CHGHOST to make the displayed host of "+dest->nick+" become "+dest->dhost);
+ ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used CHGHOST to make the displayed host of "+dest->nick+" become "+dest->GetDisplayedHost());
}
}
XLine* xline;
try
{
- mask = ((method[0] == 'Z') ? curr->GetIPString() : "*@" + curr->host);
+ mask = ((method[0] == 'Z') ? curr->GetIPString() : "*@" + curr->GetRealHost());
xline = xlf->Generate(ServerInstance->Time(), 60*60, user->nick, reason, mask);
}
catch (ModuleException&)
if (adding)
{
// assume this is more correct
- if (user->registered != REG_ALL && user->host != user->dhost)
+ if (user->registered != REG_ALL && user->GetRealHost() != user->GetDisplayedHost())
return MODEACTION_DENY;
std::string* cloak = ext.get(user);
* and make it match the displayed one.
*/
user->SetMode(this, false);
- user->ChangeDisplayedHost(user->host.c_str());
+ user->ChangeDisplayedHost(user->GetRealHost().c_str());
return MODEACTION_ALLOW;
}
}
OnUserConnect(lu);
std::string* cloak = cu.ext.get(user);
/* Check if they have a cloaked host, but are not using it */
- if (cloak && *cloak != user->dhost)
+ if (cloak && *cloak != user->GetDisplayedHost())
{
const std::string cloakMask = user->nick + "!" + user->ident + "@" + *cloak;
if (InspIRCd::Match(cloakMask, mask))
if (cloak)
return;
- cu.ext.set(dest, GenCloak(dest->client_sa, dest->GetIPString(), dest->host));
+ cu.ext.set(dest, GenCloak(dest->client_sa, dest->GetIPString(), dest->GetRealHost()));
}
};
CmdResult Handle(const std::vector<std::string> ¶meters, User* user)
{
- const std::string userHost = user->ident + "@" + user->host;
+ const std::string userHost = user->ident + "@" + user->GetRealHost();
const std::string userIP = user->ident + "@" + user->GetIPString();
ConfigTagList tags = ServerInstance->Config->ConfTags("title");
}
}
- std::string mask = target->nick+"!"+target->ident+"@"+target->dhost;
+ std::string mask = target->nick+"!"+target->ident+"@"+target->GetDisplayedHost();
std::string default_length = ServerInstance->Config->ConfValue("dccallow")->getString("length");
unsigned long length;
return MOD_RES_PASSTHRU;
user->WriteNotice("The user " + u->nick + " is not accepting DCC SENDs from you. Your file " + filename + " was not sent.");
- u->WriteNotice(user->nick + " (" + user->ident + "@" + user->dhost + ") attempted to send you a file named " + filename + ", which was blocked.");
+ u->WriteNotice(user->nick + " (" + user->ident + "@" + user->GetDisplayedHost() + ") attempted to send you a file named " + filename + ", which was blocked.");
u->WriteNotice("If you trust " + user->nick + " and were expecting this, you can type /DCCALLOW HELP for information on the DCCALLOW system.");
return MOD_RES_DENY;
}
else if ((blockchat) && (stdalgo::string::equalsci(type, "CHAT")))
{
user->WriteNotice("The user " + u->nick + " is not accepting DCC CHAT requests from you.");
- u->WriteNotice(user->nick + " (" + user->ident + "@" + user->dhost + ") attempted to initiate a DCC CHAT session, which was blocked.");
+ u->WriteNotice(user->nick + " (" + user->ident + "@" + user->GetDisplayedHost() + ") attempted to initiate a DCC CHAT session, which was blocked.");
u->WriteNotice("If you trust " + user->nick + " and were expecting this, you can type /DCCALLOW HELP for information on the DCCALLOW system.");
return MOD_RES_DENY;
}
if (!oper->server->IsULine() && (stats.GetSource()->IsOper() || !oper->IsModeSet(hm)))
{
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"));
count++;
}
void OnChangeIdent(User* user, const std::string& newident) CXX11_OVERRIDE
{
- DoHostCycle(user, newident, user->dhost, "Changing ident");
+ DoHostCycle(user, newident, user->GetDisplayedHost(), "Changing ident");
}
void OnChangeHost(User* user, const std::string& newhost) CXX11_OVERRIDE
data << "<user>";
data << "<nickname>" << u->nick << "</nickname><uuid>" << u->uuid << "</uuid><realhost>"
- << u->host << "</realhost><displayhost>" << u->dhost << "</displayhost><gecos>"
+ << u->GetRealHost() << "</realhost><displayhost>" << u->GetDisplayedHost() << "</displayhost><gecos>"
<< Sanitize(u->fullname) << "</gecos><server>" << u->server->GetName() << "</server>";
if (u->IsAway())
data << "<away>" << Sanitize(u->awaymsg) << "</away><awaytime>" << u->awaytime << "</awaytime>";
void OnChangeIdent(User* user, const std::string& newident) CXX11_OVERRIDE
{
- DoChgHost(user, newident, user->dhost);
+ DoChgHost(user, newident, user->GetDisplayedHost());
}
void OnChangeHost(User* user, const std::string& newhost) CXX11_OVERRIDE
return MOD_RES_PASSTHRU;
std::string acceptedhosts = tag->getString("host");
- std::string hostname = user->ident + "@" + user->host;
+ std::string hostname = user->ident + "@" + user->GetRealHost();
if (!InspIRCd::MatchMask(acceptedhosts, hostname, user->GetIPString()))
return MOD_RES_PASSTHRU;
if (f->ban)
{
Modes::ChangeList changelist;
- changelist.push_add(ServerInstance->Modes->FindMode('b', MODETYPE_CHANNEL), "*!*@" + user->dhost);
+ changelist.push_add(ServerInstance->Modes->FindMode('b', MODETYPE_CHANNEL), "*!*@" + user->GetDisplayedHost());
ServerInstance->Modes->Process(ServerInstance->FakeClient, dest, NULL, changelist);
}
if (settings->Action == ChannelSettings::ACT_BAN)
{
Modes::ChangeList changelist;
- changelist.push_add(ServerInstance->Modes->FindMode('b', MODETYPE_CHANNEL), "*!*@" + user->dhost);
+ changelist.push_add(ServerInstance->Modes->FindMode('b', MODETYPE_CHANNEL), "*!*@" + user->GetDisplayedHost());
ServerInstance->Modes->Process(ServerInstance->FakeClient, chan, NULL, changelist);
}
if (lu && lu->exempt)
return false;
- const std::string host = u->nick + "!" + u->ident + "@" + u->host + " " + u->fullname;
+ const std::string host = u->nick + "!" + u->ident + "@" + u->GetRealHost() + " " + u->fullname;
const std::string ip = u->nick + "!" + u->ident + "@" + u->GetIPString() + " " + u->fullname;
return (regex->Matches(host) || regex->Matches(ip));
}
void SendHostIP()
{
parameterlist params;
- params.push_back(user->host);
+ params.push_back(user->GetRealHost());
params.push_back(user->GetIPString());
params.push_back(SSLIOHook::IsSSL(&user->eh) ? "S" : "P");
if (user->ChangeDisplayedHost(parameters[0]))
{
- ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SETHOST to change their displayed host to "+user->dhost);
+ ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SETHOST to change their displayed host to "+user->GetDisplayedHost());
return CMD_SUCCESS;
}
void HandleFast(User* dest, User* src)
{
dest->WriteNotice("*** " + src->nick + " (" + src->ident + "@" +
- (dest->HasPrivPermission("users/auspex") ? src->host : src->dhost) +
+ src->GetHost(dest->HasPrivPermission("users/auspex")) +
") did a /whois on you");
}
return CMD_SUCCESS;
}
- ServerInstance->SNO->WriteToSnoMask('O',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server->GetName().c_str(), u->nick.c_str(),u->ident.c_str(), u->host.c_str(), opertype.c_str());
+ ServerInstance->SNO->WriteToSnoMask('O',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server->GetName().c_str(), u->nick.c_str(),u->ident.c_str(), u->GetRealHost().c_str(), opertype.c_str());
return CMD_SUCCESS;
}
RemoteUser* _new = new SpanningTree::RemoteUser(params[0], remoteserver);
ServerInstance->Users->clientlist[params[2]] = _new;
_new->nick = params[2];
- _new->host = params[3];
- _new->dhost = params[4];
+ _new->ChangeRealHost(params[3], false);
+ _new->ChangeDisplayedHost(params[4]);
_new->ident = params[5];
_new->fullname = params.back();
_new->registered = REG_ALL;
push(user->uuid);
push_int(user->age);
push(user->nick);
- push(user->host);
- push(user->dhost);
+ push(user->GetRealHost());
+ push(user->GetDisplayedHost());
push(user->ident);
push(user->GetIPString());
push_int(user->signon);
std::string hostname(user->ident);
- hostname.append("@").append(user->host);
+ hostname.append("@").append(user->GetRealHost());
if (InspIRCd::MatchMask(pattern, hostname, user->GetIPString()))
{
{
// The away state should only be sent if the client requests away notifications for a nick but 2.0 always sends them so we do that too
if (target->IsAway())
- user->WriteNumeric(RPL_NOWISAWAY, target->nick, target->ident, target->dhost, (unsigned long)target->awaytime, "is away");
+ user->WriteNumeric(RPL_NOWISAWAY, target->nick, target->ident, target->GetDisplayedHost(), (unsigned long)target->awaytime, "is away");
else
- user->WriteNumeric(RPL_NOWON, target->nick, target->ident, target->dhost, (unsigned long)target->age, "is online");
+ user->WriteNumeric(RPL_NOWON, target->nick, target->ident, target->GetDisplayedHost(), (unsigned long)target->age, "is online");
}
else if (show_offline)
user->WriteNumeric(RPL_NOWOFF, nick, "*", "*", "0", "is offline");
User* target = IRCv3::Monitor::Manager::FindNick(nick);
if (target)
- user->WriteNumeric(RPL_WATCHOFF, target->nick, target->ident, target->dhost, (unsigned long)target->age, "stopped watching");
+ user->WriteNumeric(RPL_WATCHOFF, target->nick, target->ident, target->GetDisplayedHost(), (unsigned long)target->age, "stopped watching");
else
user->WriteNumeric(RPL_WATCHOFF, nick, "*", "*", "0", "stopped watching");
}
return;
Numeric::Numeric num(numeric);
- num.push(nick).push(user->ident).push(user->dhost).push(ConvToStr(shownts)).push(numerictext);
+ num.push(nick).push(user->ident).push(user->GetDisplayedHost()).push(ConvToStr(shownts)).push(numerictext);
for (IRCv3::Monitor::WatcherList::const_iterator i = list->begin(); i != list->end(); ++i)
{
LocalUser* curr = *i;
user->quitting = true;
ServerInstance->Logs->Log("USERS", LOG_DEBUG, "QuitUser: %s=%s '%s'", user->uuid.c_str(), user->nick.c_str(), quitreason.c_str());
- user->Write("ERROR :Closing link: (%s@%s) [%s]", user->ident.c_str(), user->host.c_str(), operreason ? operreason->c_str() : quitreason.c_str());
+ user->Write("ERROR :Closing link: (%s@%s) [%s]", user->ident.c_str(), user->GetRealHost().c_str(), operreason ? operreason->c_str() : quitreason.c_str());
std::string reason;
reason.assign(quitreason, 0, ServerInstance->Config->Limits.MaxQuit);
eh.SetFd(myfd);
memcpy(&client_sa, client, sizeof(irc::sockets::sockaddrs));
memcpy(&server_sa, servaddr, sizeof(irc::sockets::sockaddrs));
- dhost = host = GetIPString();
+ ChangeRealHost(GetIPString(), true);
}
User::~User()
return this->cached_makehost;
// XXX: Is there really a need to cache this?
- this->cached_makehost = ident + "@" + host;
+ this->cached_makehost = ident + "@" + GetRealHost();
return this->cached_makehost;
}
return this->cached_fullhost;
// XXX: Is there really a need to cache this?
- this->cached_fullhost = nick + "!" + ident + "@" + dhost;
+ this->cached_fullhost = nick + "!" + ident + "@" + GetDisplayedHost();
return this->cached_fullhost;
}
return this->cached_fullrealhost;
// XXX: Is there really a need to cache this?
- this->cached_fullrealhost = nick + "!" + ident + "@" + host;
+ this->cached_fullrealhost = nick + "!" + ident + "@" + GetRealHost();
return this->cached_fullrealhost;
}
}
ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')",
- nick.c_str(), ident.c_str(), host.c_str(), oper->name.c_str(), opername.c_str());
+ nick.c_str(), ident.c_str(), GetRealHost().c_str(), oper->name.c_str(), opername.c_str());
this->WriteNumeric(RPL_YOUAREOPER, InspIRCd::Format("You are now %s %s", strchr("aeiouAEIOU", oper->name[0]) ? "an" : "a", oper->name.c_str()));
ServerInstance->Logs->Log("OPER", LOG_DEFAULT, "%s opered as type: %s", GetFullRealHost().c_str(), oper->name.c_str());
return cachedip;
}
+const std::string& User::GetHost(bool uncloak) const
+{
+ return uncloak ? GetRealHost() : GetDisplayedHost();
+}
+
+const std::string& User::GetDisplayedHost() const
+{
+ return displayhost.empty() ? realhost : displayhost;
+}
+
+const std::string& User::GetRealHost() const
+{
+ return realhost;
+}
+
irc::sockets::cidr_mask User::GetCIDRMask()
{
int range = 0;
bool User::ChangeDisplayedHost(const std::string& shost)
{
- if (dhost == shost)
+ if (GetDisplayedHost() == shost)
return true;
if (IS_LOCAL(this))
FOREACH_MOD(OnChangeHost, (this,shost));
- this->dhost.assign(shost, 0, ServerInstance->Config->Limits.MaxHost);
+ if (realhost == shost)
+ this->displayhost.clear();
+ else
+ this->displayhost.assign(shost, 0, ServerInstance->Config->Limits.MaxHost);
+
this->InvalidateCache();
if (IS_LOCAL(this))
- this->WriteNumeric(RPL_YOURDISPLAYEDHOST, this->dhost, "is now your displayed host");
+ this->WriteNumeric(RPL_YOURDISPLAYEDHOST, this->GetDisplayedHost(), "is now your displayed host");
return true;
}
+void User::ChangeRealHost(const std::string& host, bool resetdisplay)
+{
+ if (displayhost == host)
+ return;
+
+ if (displayhost.empty() && !resetdisplay)
+ displayhost = realhost;
+
+ else if (displayhost == host || resetdisplay)
+ displayhost.clear();
+
+ realhost = host;
+ this->InvalidateCache();
+}
+
bool User::ChangeIdent(const std::string& newident)
{
if (this->ident == newident)
/* check if host matches.. */
if (!InspIRCd::MatchCIDR(this->GetIPString(), c->GetHost(), NULL) &&
- !InspIRCd::MatchCIDR(this->host, c->GetHost(), NULL))
+ !InspIRCd::MatchCIDR(this->GetRealHost(), c->GetHost(), NULL))
{
ServerInstance->Logs->Log("CONNECTCLASS", LOG_DEBUG, "No host match (for %s)", c->GetHost().c_str());
continue;
if (InspIRCd::Match(u->ident, this->identmask, ascii_case_insensitive_map))
{
- if (InspIRCd::MatchCIDR(u->host, this->hostmask, ascii_case_insensitive_map) ||
+ if (InspIRCd::MatchCIDR(u->GetRealHost(), this->hostmask, ascii_case_insensitive_map) ||
InspIRCd::MatchCIDR(u->GetIPString(), this->hostmask, ascii_case_insensitive_map))
{
return true;
if (InspIRCd::Match(u->ident, this->identmask, ascii_case_insensitive_map))
{
- if (InspIRCd::MatchCIDR(u->host, this->hostmask, ascii_case_insensitive_map) ||
+ if (InspIRCd::MatchCIDR(u->GetRealHost(), this->hostmask, ascii_case_insensitive_map) ||
InspIRCd::MatchCIDR(u->GetIPString(), this->hostmask, ascii_case_insensitive_map))
{
return true;
if (InspIRCd::Match(u->ident, this->identmask, ascii_case_insensitive_map))
{
- if (InspIRCd::MatchCIDR(u->host, this->hostmask, ascii_case_insensitive_map) ||
+ if (InspIRCd::MatchCIDR(u->GetRealHost(), this->hostmask, ascii_case_insensitive_map) ||
InspIRCd::MatchCIDR(u->GetIPString(), this->hostmask, ascii_case_insensitive_map))
{
return true;