diff options
65 files changed, 301 insertions, 264 deletions
diff --git a/include/clientprotocol.h b/include/clientprotocol.h index ebcb35ffc..3a1da079c 100644 --- a/include/clientprotocol.h +++ b/include/clientprotocol.h @@ -127,7 +127,7 @@ public: if (sourcestr) return sourcestr; if (sourceuser) - return &sourceuser->GetFullHost(); + return &sourceuser->GetMask(); return nullptr; } diff --git a/include/modules/shun.h b/include/modules/shun.h index a162c0581..95f5bba6b 100644 --- a/include/modules/shun.h +++ b/include/modules/shun.h @@ -47,10 +47,10 @@ public: 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)) + if (InspIRCd::Match(u->GetMask(), matchtext) || InspIRCd::Match(u->GetRealMask(), matchtext) || InspIRCd::Match(u->nick+"!"+u->ident+"@"+u->GetAddress(), matchtext)) return true; - if (InspIRCd::MatchCIDR(u->GetIPString(), matchtext, ascii_case_insensitive_map)) + if (InspIRCd::MatchCIDR(u->GetAddress(), matchtext, ascii_case_insensitive_map)) return true; return false; diff --git a/include/modules/sql.h b/include/modules/sql.h index 2f7557fdd..986a30204 100644 --- a/include/modules/sql.h +++ b/include/modules/sql.h @@ -236,7 +236,7 @@ inline void SQL::PopulateUserInfo(User* user, ParamMap& userinfo) { userinfo["nick"] = user->nick; userinfo["host"] = user->GetRealHost(); - userinfo["ip"] = user->GetIPString(); + userinfo["ip"] = user->GetAddress(); userinfo["real"] = user->GetRealName(); userinfo["ident"] = user->ident; userinfo["server"] = user->server->GetName(); diff --git a/include/users.h b/include/users.h index 068d0cdc0..1db7c4de3 100644 --- a/include/users.h +++ b/include/users.h @@ -311,25 +311,23 @@ class CoreExport User : public Extensible { private: - /** Cached nick!ident\@dhost value using the displayed hostname - */ - std::string cached_fullhost; + /** Cached value for GetAddress. */ + std::string cached_address; - /** Cached ident\@ip value using the real IP address - */ - std::string cached_hostip; + /** Cached value for GetUserAddress. */ + std::string cached_useraddress; - /** Cached ident\@realhost value using the real hostname - */ - std::string cached_makehost; + /** Cached value for GetUserHost. */ + std::string cached_userhost; - /** Cached nick!ident\@realhost value using the real hostname - */ - std::string cached_fullrealhost; + /** Cached value for GetRealUserHost. */ + std::string cached_realuserhost; - /** Set by GetIPString() to avoid constantly re-grabbing IP via sockets voodoo. - */ - std::string cachedip; + /** Cached value for GetMask. */ + std::string cached_mask; + + /** Cached value for GetRealMask. */ + std::string cached_realmask; /** If set then the hostname which is displayed to users. */ std::string displayhost; @@ -478,11 +476,6 @@ public: /** What type of user is this? */ const uint8_t usertype:2; - /** Get client IP string from sockaddr, using static internal buffer - * @return The IP string - */ - const std::string& GetIPString(); - /** Retrieves this user's hostname. * @param uncloak If true then return the real host; otherwise, the display host. */ @@ -504,6 +497,36 @@ public: */ irc::sockets::cidr_mask GetCIDRMask() const; + /** Retrieves the remote address (IPv4, IPv6, UNIX socket path) as a string. + * If this method has not been called before then it will be cached. + */ + virtual const std::string& GetAddress(); + + /*** Retrieves the user@address mask for the user as a string. + * If this method has not been called before then it will be cached. + */ + virtual const std::string& GetUserAddress(); + + /*** Retrieves the user@dhost mask for the user as a string. + * If this method has not been called before then it will be cached. + */ + virtual const std::string& GetUserHost(); + + /*** Retrieves the user@rhost mask for the user as a string. + * If this method has not been called before then it will be cached. + */ + virtual const std::string& GetRealUserHost(); + + /*** Retrieves the nick!user@dhost mask for the user as a string. + * If this method has not been called before then it will be cached. + */ + virtual const std::string& GetMask(); + + /*** Retrieves the nick!user@dhost mask for the user as a string. + * If this method has not been called before then it will be cached. + */ + virtual const std::string& GetRealMask(); + /** Changes the remote socket address for this user. * @param sa The new socket address. */ @@ -514,21 +537,6 @@ public: */ User(const std::string& uid, Server* srv, Type objtype); - /** 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. - * @return The full masked host of the user - */ - virtual const std::string& GetFullHost(); - - /** Returns the full real 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. If any form of hostname cloaking is in operation, - * e.g. through a module, then this method will ignore it and return the true hostname. - * @return The full real host of the user - */ - virtual const std::string& GetFullRealHost(); - /** This clears any cached results that are used for GetFullRealHost() etc. * The results of these calls are cached as generating them can be generally expensive. */ @@ -606,18 +614,6 @@ public: */ inline bool HasSnomaskPermission(char chr) const { return IsOper() && oper->CanUseSnomask(chr); } - /** Creates a usermask with real host. - * Takes a buffer to use and fills the given buffer with the hostmask in the format user\@host - * @return the usermask in the format user\@host - */ - const std::string& MakeHost(); - - /** Creates a usermask with real ip. - * Takes a buffer to use and fills the given buffer with the ipmask in the format user\@ip - * @return the usermask in the format user\@ip - */ - const std::string& MakeHostIP(); - /** Logs this user into the specified server operator account. * @param account The account to log this user in to. * @param automatic Whether this is an automatic login attempt. @@ -908,21 +904,27 @@ class CoreExport FakeUser final : public User { public: - FakeUser(const std::string& uid, Server* srv) - : User(uid, srv, TYPE_SERVER) - { - nick = srv->GetName(); - } + /** Creates a new fake user with the specified sid and server details. + * @param sid A server id in the format [0-9][A-Z0-9][A-Z0-9]. + * @param srv The server instance to configure this fake user from. + */ + FakeUser(const std::string& sid, Server* srv); - FakeUser(const std::string& uid, const std::string& sname, const std::string& sdesc) - : User(uid, new Server(uid, sname, sdesc), TYPE_SERVER) - { - nick = sname; - } + /** Creates a new fake user with the specified sid, server name, and server description. + * @param sid A server id in the format [0-9][A-Z0-9][A-Z0-9]. + * @param sname The name of the server. + * @param sdesc The description of the server. + */ + FakeUser(const std::string& sid, const std::string& sname, const std::string& sdesc); + /** @copydoc Cullable::Cull. */ Cullable::Result Cull() override; - const std::string& GetFullHost() override; - const std::string& GetFullRealHost() override; + + /** @copydoc User::GetMask. */ + const std::string& GetMask() override; + + /** @copydoc User::GetRealMask. */ + const std::string& GetRealMask() override; }; /* Faster than dynamic_cast */ diff --git a/src/channels.cpp b/src/channels.cpp index aee61bbd5..013f009f7 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -61,7 +61,7 @@ void Channel::SetTopic(User* u, const std::string& ntopic, time_t topicts, const // Always update setter and set time if (!setter) - setter = ServerInstance->Config->FullHostInTopic ? &u->GetFullHost() : &u->nick; + setter = ServerInstance->Config->FullHostInTopic ? &u->GetMask() : &u->nick; this->setby.assign(*setter, 0, ServerInstance->Config->Limits.GetMaxMask()); this->topicset = topicts; @@ -298,7 +298,7 @@ bool Channel::CheckBan(User* user, const std::string& mask) std::string suffix(mask, at + 1); if (InspIRCd::Match(user->GetRealHost(), suffix, nullptr) || InspIRCd::Match(user->GetDisplayedHost(), suffix, nullptr) || - InspIRCd::MatchCIDR(user->GetIPString(), suffix, nullptr)) + InspIRCd::MatchCIDR(user->GetAddress(), suffix, nullptr)) return true; } return false; diff --git a/src/coremods/core_hostname_lookup.cpp b/src/coremods/core_hostname_lookup.cpp index fd5f2af66..e9e06c7a5 100644 --- a/src/coremods/core_hostname_lookup.cpp +++ b/src/coremods/core_hostname_lookup.cpp @@ -52,10 +52,10 @@ protected: // Handles errors which happen during DNS resolution. static void HandleError(LocalUser* user, const std::string& message) { - user->WriteNotice("*** " + message + "; using your IP address (" + user->GetIPString() + ") instead."); + user->WriteNotice("*** " + message + "; using your IP address (" + user->GetAddress() + ") instead."); bool display_is_real = user->GetDisplayedHost() == user->GetRealHost(); - user->ChangeRealHost(user->GetIPString(), display_is_real); + user->ChangeRealHost(user->GetAddress(), display_is_real); dl->Unset(user); } @@ -160,7 +160,7 @@ class UserHostResolver final { public: UserHostResolver(DNS::Manager* mgr, Module* me, LocalUser* user) - : UserResolver(mgr, me, user, user->GetIPString(), DNS::QUERY_PTR) + : UserResolver(mgr, me, user, user->GetAddress(), DNS::QUERY_PTR) { } diff --git a/src/coremods/core_info/core_info.cpp b/src/coremods/core_info/core_info.cpp index ca094581e..5fde2b0ed 100644 --- a/src/coremods/core_info/core_info.cpp +++ b/src/coremods/core_info/core_info.cpp @@ -174,7 +174,7 @@ public: void OnUserConnect(LocalUser* user) override { - user->WriteNumeric(RPL_WELCOME, INSP_FORMAT("Welcome to the {} IRC Network {}", ServerInstance->Config->Network, user->GetFullRealHost())); + user->WriteNumeric(RPL_WELCOME, INSP_FORMAT("Welcome to the {} IRC Network {}", ServerInstance->Config->Network, user->GetRealMask())); user->WriteNumeric(RPL_YOURHOST, INSP_FORMAT("Your host is {}, running version {}", ServerInstance->Config->GetServerName(), INSPIRCD_BRANCH)); user->WriteNumeric(RPL_CREATED, InspIRCd::TimeString(ServerInstance->startup_time, "This server was created %H:%M:%S %b %d %Y")); user->WriteNumeric(numeric004); diff --git a/src/coremods/core_oper/cmd_die.cpp b/src/coremods/core_oper/cmd_die.cpp index a8291eb57..87cf382e7 100644 --- a/src/coremods/core_oper/cmd_die.cpp +++ b/src/coremods/core_oper/cmd_die.cpp @@ -62,15 +62,15 @@ CmdResult CommandDie::Handle(User* user, const Params& parameters) { if (irc::equals(parameters[0], ServerInstance->Config->ServerName)) { - const std::string diebuf = "*** DIE command from " + user->GetFullHost() + ". Terminating."; + const std::string diebuf = "*** DIE command from " + user->GetMask() + ". Terminating."; ServerInstance->Logs.Error(MODNAME, diebuf); DieRestart::SendError(diebuf); ServerInstance->Exit(EXIT_STATUS_DIE); } else { - ServerInstance->Logs.Error(MODNAME, "Failed /DIE command from {}", user->GetFullRealHost()); - ServerInstance->SNO.WriteGlobalSno('a', "Failed DIE command from {}.", user->GetFullRealHost()); + ServerInstance->Logs.Error(MODNAME, "Failed /DIE command from {}", user->GetRealMask()); + ServerInstance->SNO.WriteGlobalSno('a', "Failed DIE command from {}.", user->GetRealMask()); return CmdResult::FAILURE; } } diff --git a/src/coremods/core_oper/cmd_kill.cpp b/src/coremods/core_oper/cmd_kill.cpp index 04d416c06..8e64a0f5d 100644 --- a/src/coremods/core_oper/cmd_kill.cpp +++ b/src/coremods/core_oper/cmd_kill.cpp @@ -115,9 +115,9 @@ CmdResult CommandKill::Handle(User* user, const Params& parameters) if ((!hideservicekills) || (!user->server->IsService())) { if (IS_LOCAL(user) && IS_LOCAL(target)) - ServerInstance->SNO.WriteGlobalSno('k', "Local kill by {}: {} ({})", user->nick, target->GetFullRealHost(), parameters[1]); + ServerInstance->SNO.WriteGlobalSno('k', "Local kill by {}: {} ({})", user->nick, target->GetRealMask(), parameters[1]); else - ServerInstance->SNO.WriteToSnoMask('K', "Remote kill by {}: {} ({})", user->nick, target->GetFullRealHost(), parameters[1]); + ServerInstance->SNO.WriteToSnoMask('K', "Remote kill by {}: {} ({})", user->nick, target->GetRealMask(), parameters[1]); } if (IS_LOCAL(target)) diff --git a/src/coremods/core_oper/cmd_oper.cpp b/src/coremods/core_oper/cmd_oper.cpp index 6cfe14ccd..d00fed6b1 100644 --- a/src/coremods/core_oper/cmd_oper.cpp +++ b/src/coremods/core_oper/cmd_oper.cpp @@ -50,7 +50,7 @@ CmdResult CommandOper::HandleLocal(LocalUser* user, const Params& parameters) if (it == ServerInstance->Config->OperAccounts.end()) { ServerInstance->SNO.WriteGlobalSno('o', "{} ({}) [{}] failed to log into the \x02{}\x02 oper account because no account with that name exists.", - user->nick, user->MakeHost(), user->GetIPString(), parameters[0]); + user->nick, user->GetRealUserHost(), user->GetAddress(), parameters[0]); return FailedOper(user, parameters[0]); } @@ -59,7 +59,7 @@ CmdResult CommandOper::HandleLocal(LocalUser* user, const Params& parameters) if (!account->CheckPassword(parameters[1])) { ServerInstance->SNO.WriteGlobalSno('o', "{} ({}) [{}] failed to log into the \x02{}\x02 oper account because they specified the wrong password.", - user->nick, user->MakeHost(), user->GetIPString(), parameters[0]); + user->nick, user->GetRealUserHost(), user->GetAddress(), parameters[0]); return FailedOper(user, parameters[0]); } diff --git a/src/coremods/core_oper/cmd_restart.cpp b/src/coremods/core_oper/cmd_restart.cpp index 4c827c19b..18b90d5a3 100644 --- a/src/coremods/core_oper/cmd_restart.cpp +++ b/src/coremods/core_oper/cmd_restart.cpp @@ -47,7 +47,7 @@ CmdResult CommandRestart::Handle(User* user, const Params& parameters) ServerInstance->Logs.Normal(MODNAME, "Restart: {}", user->nick); if (irc::equals(parameters[0], ServerInstance->Config->ServerName)) { - ServerInstance->SNO.WriteGlobalSno('a', "RESTART command from {}, restarting server.", user->GetFullRealHost()); + ServerInstance->SNO.WriteGlobalSno('a', "RESTART command from {}, restarting server.", user->GetRealMask()); DieRestart::SendError("Server restarting."); @@ -72,7 +72,7 @@ CmdResult CommandRestart::Handle(User* user, const Params& parameters) } else { - ServerInstance->SNO.WriteGlobalSno('a', "Failed RESTART Command from {}.", user->GetFullRealHost()); + ServerInstance->SNO.WriteGlobalSno('a', "Failed RESTART Command from {}.", user->GetRealMask()); } return CmdResult::FAILURE; } diff --git a/src/coremods/core_oper/core_oper.cpp b/src/coremods/core_oper/core_oper.cpp index 17a32bd4c..5f4edf702 100644 --- a/src/coremods/core_oper/core_oper.cpp +++ b/src/coremods/core_oper/core_oper.cpp @@ -84,13 +84,13 @@ public: ModResult OnPreOperLogin(LocalUser* user, const std::shared_ptr<OperAccount>& oper, bool automatic) override { const std::string hosts = oper->GetConfig()->getString("host"); - if (InspIRCd::MatchMask(hosts, user->MakeHost(), user->MakeHostIP())) + if (InspIRCd::MatchMask(hosts, user->GetRealUserHost(), user->GetUserAddress())) return MOD_RES_PASSTHRU; // Host matches. if (!automatic) { ServerInstance->SNO.WriteGlobalSno('o', "{} ({}) [{}] failed to log into the \x02{}\x02 oper account because they are connecting from the wrong user@host.", - user->nick, user->MakeHost(), user->GetIPString(), oper->GetName()); + user->nick, user->GetRealUserHost(), user->GetAddress(), oper->GetName()); } return MOD_RES_DENY; // Host does not match. } @@ -105,7 +105,7 @@ public: user->oper->GetType())); ServerInstance->SNO.WriteToSnoMask('o', "{} ({}) [{}] is now a server operator of type \x02{}\x02 ({}using account \x02{}\x02).", - user->nick, user->MakeHost(), user->GetIPString(), user->oper->GetType(), + user->nick, user->GetRealUserHost(), user->GetAddress(), user->oper->GetType(), automatic ? "automatically " : "", user->oper->GetName()); const std::string vhost = luser->oper->GetConfig()->getString("vhost"); @@ -216,7 +216,7 @@ public: extra += INSP_FORMAT("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime); } - stats.AddGenericRow(INSP_FORMAT("\x02{}\x02 ({}){}", oper->nick, oper->MakeHost(), extra)); + stats.AddGenericRow(INSP_FORMAT("\x02{}\x02 ({}){}", oper->nick, oper->GetRealUserHost(), extra)); } stats.AddGenericRow(INSP_FORMAT("{} server operator{} total", opers, opers ? "s" : "")); return MOD_RES_DENY; diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp index 4b732d7b1..95601fa55 100644 --- a/src/coremods/core_stats.cpp +++ b/src/coremods/core_stats.cpp @@ -94,7 +94,7 @@ static void GenerateStatsLl(Stats::Context& stats) stats.AddRow(211, INSP_FORMAT("nick[ident@{}] sendq cmds_out bytes_out cmds_in bytes_in time_open", stats.GetSymbol() == 'l' ? "host" : "ip")); for (auto* u : ServerInstance->Users.GetLocalUsers()) - 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)); + stats.AddRow(211, u->nick+"["+u->ident+"@"+(stats.GetSymbol() == 'l' ? u->GetDisplayedHost() : u->GetAddress())+"] "+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)); } void CommandStats::DoStats(Stats::Context& stats) @@ -109,7 +109,7 @@ void CommandStats::DoStats(Stats::Context& stats) if (!isPublic && !isRemoteOper && !isLocalOperWithPrivs) { const char* what = IS_LOCAL(user) ? "Stats" : "Remote stats"; - ServerInstance->SNO.WriteToSnoMask('t', "{} '{}' denied for {} ({})", what, statschar, user->nick, user->MakeHost()); + ServerInstance->SNO.WriteToSnoMask('t', "{} '{}' denied for {} ({})", what, statschar, user->nick, user->GetRealUserHost()); stats.AddRow(481, (std::string("Permission Denied - STATS ") + statschar + " requires the servers/auspex priv.")); return; } @@ -118,7 +118,7 @@ void CommandStats::DoStats(Stats::Context& stats) if (res == MOD_RES_DENY) { const char* what = IS_LOCAL(user) ? "Stats" : "Remote stats"; - ServerInstance->SNO.WriteToSnoMask('t', "{} '{}' denied for {} ({})", what, statschar, user->nick, user->MakeHost()); + ServerInstance->SNO.WriteToSnoMask('t', "{} '{}' denied for {} ({})", what, statschar, user->nick, user->GetRealUserHost()); stats.AddRow(219, statschar, "End of /STATS report"); return; } diff --git a/src/coremods/core_user/core_user.cpp b/src/coremods/core_user/core_user.cpp index 20c3c1d36..8dad123cf 100644 --- a/src/coremods/core_user/core_user.cpp +++ b/src/coremods/core_user/core_user.cpp @@ -181,7 +181,7 @@ public: bool hostmatches = false; for (const auto& host : klass->GetHosts()) { - if (InspIRCd::MatchCIDR(user->GetIPString(), host) || InspIRCd::MatchCIDR(user->GetRealHost(), host)) + if (InspIRCd::MatchCIDR(user->GetAddress(), host) || InspIRCd::MatchCIDR(user->GetRealHost(), host)) { hostmatches = true; break; @@ -191,7 +191,7 @@ public: { const std::string hosts = stdalgo::string::join(klass->GetHosts()); ServerInstance->Logs.Debug("CONNECTCLASS", "The {} connect class is not suitable as neither the host ({}) nor the IP ({}) matches {}.", - klass->GetName(), user->GetRealHost(), user->GetIPString(), hosts); + klass->GetName(), user->GetRealHost(), user->GetAddress(), hosts); return MOD_RES_DENY; } @@ -239,7 +239,7 @@ public: if (klass->maxconnwarn) { ServerInstance->SNO.WriteToSnoMask('a', "WARNING: maximum local connections for the {} class ({}) exceeded by {}", - klass->GetName(), klass->maxlocal, user->GetIPString()); + klass->GetName(), klass->maxlocal, user->GetAddress()); } return; } @@ -250,7 +250,7 @@ public: if (klass->maxconnwarn) { ServerInstance->SNO.WriteToSnoMask('a', "WARNING: maximum global connections for the {} class ({}) exceeded by {}", - klass->GetName(), klass->maxglobal, user->GetIPString()); + klass->GetName(), klass->maxglobal, user->GetAddress()); } return; } diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp index 49c6cf6e3..f363494bf 100644 --- a/src/coremods/core_who.cpp +++ b/src/coremods/core_who.cpp @@ -309,7 +309,7 @@ bool CommandWho::MatchUser(LocalUser* source, User* user, WhoData& data) // The source wants to match against users' IP addresses. else if (data.flags['i']) - match = source_can_see_target && InspIRCd::MatchCIDR(user->GetIPString(), data.matchtext, ascii_case_insensitive_map); + match = source_can_see_target && InspIRCd::MatchCIDR(user->GetAddress(), data.matchtext, ascii_case_insensitive_map); // The source wants to match against users' modes. else if (data.flags['m']) @@ -479,7 +479,7 @@ void CommandWho::SendWhoLine(LocalUser* source, const std::vector<std::string>& // Include the user's IP address. if (data.whox_fields['i']) - wholine.push(source_can_see_target ? user->GetIPString() : "255.255.255.255"); + wholine.push(source_can_see_target ? user->GetAddress() : "255.255.255.255"); // Include the user's hostname. if (data.whox_fields['h']) diff --git a/src/coremods/core_whois.cpp b/src/coremods/core_whois.cpp index ae2c31cfc..42cc85873 100644 --- a/src/coremods/core_whois.cpp +++ b/src/coremods/core_whois.cpp @@ -202,7 +202,7 @@ void CommandWhois::DoWhois(LocalUser* user, User* dest, time_t signon, unsigned whois.SendLine(RPL_WHOISUSER, dest->ident, dest->GetDisplayedHost(), '*', dest->GetRealName()); if (!dest->server->IsService() && (whois.IsSelfWhois() || user->HasPrivPermission("users/auspex"))) { - whois.SendLine(RPL_WHOISACTUALLY, dest->MakeHost(), dest->GetIPString(), "is connecting from"); + whois.SendLine(RPL_WHOISACTUALLY, dest->GetRealUserHost(), dest->GetAddress(), "is connecting from"); } SendChanList(whois); diff --git a/src/coremods/core_xline/cmd_eline.cpp b/src/coremods/core_xline/cmd_eline.cpp index 92f847f56..987b80962 100644 --- a/src/coremods/core_xline/cmd_eline.cpp +++ b/src/coremods/core_xline/cmd_eline.cpp @@ -49,7 +49,7 @@ CmdResult CommandEline::Handle(User* user, const Params& parameters) if (find) { ih.first = find->GetBanIdent(); - ih.second = find->GetIPString(); + ih.second = find->GetAddress(); target = ih.first + "@" + ih.second; } else diff --git a/src/coremods/core_xline/cmd_gline.cpp b/src/coremods/core_xline/cmd_gline.cpp index 4737170d3..06c048b9a 100644 --- a/src/coremods/core_xline/cmd_gline.cpp +++ b/src/coremods/core_xline/cmd_gline.cpp @@ -50,7 +50,7 @@ CmdResult CommandGline::Handle(User* user, const Params& parameters) if (find) { ih.first = find->GetBanIdent(); - ih.second = find->GetIPString(); + ih.second = find->GetAddress(); target = ih.first + "@" + ih.second; } else diff --git a/src/coremods/core_xline/cmd_kline.cpp b/src/coremods/core_xline/cmd_kline.cpp index 7560557d3..49e2faf66 100644 --- a/src/coremods/core_xline/cmd_kline.cpp +++ b/src/coremods/core_xline/cmd_kline.cpp @@ -50,7 +50,7 @@ CmdResult CommandKline::Handle(User* user, const Params& parameters) if (find) { ih.first = find->GetBanIdent(); - ih.second = find->GetIPString(); + ih.second = find->GetAddress(); target = ih.first + "@" + ih.second; } else diff --git a/src/coremods/core_xline/cmd_zline.cpp b/src/coremods/core_xline/cmd_zline.cpp index a4de0adc3..c48524ab4 100644 --- a/src/coremods/core_xline/cmd_zline.cpp +++ b/src/coremods/core_xline/cmd_zline.cpp @@ -55,7 +55,7 @@ CmdResult CommandZline::Handle(User* user, const Params& parameters) auto* u = ServerInstance->Users.Find(target, true); if (u) { - target = u->GetIPString(); + target = u->GetAddress(); } const char* ipaddr = target.c_str(); @@ -119,5 +119,5 @@ CmdResult CommandZline::Handle(User* user, const Params& parameters) bool CommandZline::IPMatcher::Check(User* user, const std::string& ip) const { - return InspIRCd::MatchCIDR(user->GetIPString(), ip, ascii_case_insensitive_map); + return InspIRCd::MatchCIDR(user->GetAddress(), ip, ascii_case_insensitive_map); } diff --git a/src/coremods/core_xline/core_xline.cpp b/src/coremods/core_xline/core_xline.cpp index 6f0617176..e7e38fac3 100644 --- a/src/coremods/core_xline/core_xline.cpp +++ b/src/coremods/core_xline/core_xline.cpp @@ -54,8 +54,8 @@ bool InsaneBan::MatchesEveryone(const std::string& mask, MatcherBase& test, User bool InsaneBan::IPHostMatcher::Check(User* user, const std::string& mask) const { - return ((InspIRCd::MatchCIDR(user->MakeHost(), mask, ascii_case_insensitive_map)) || - (InspIRCd::MatchCIDR(user->MakeHostIP(), mask, ascii_case_insensitive_map))); + return ((InspIRCd::MatchCIDR(user->GetRealUserHost(), mask, ascii_case_insensitive_map)) || + (InspIRCd::MatchCIDR(user->GetUserAddress(), mask, ascii_case_insensitive_map))); } class CoreModXLine final @@ -153,7 +153,7 @@ public: if (user->IsFullyConnected()) { ServerInstance->SNO.WriteGlobalSno('x', "Q-lined nickname {} from {}: {}", - newnick, user->GetFullRealHost(), xline->reason); + newnick, user->GetRealMask(), xline->reason); } // Send a numeric because if we deny then the core doesn't reply anything diff --git a/src/modules/m_account.cpp b/src/modules/m_account.cpp index 12e6eae8a..9db381d28 100644 --- a/src/modules/m_account.cpp +++ b/src/modules/m_account.cpp @@ -70,12 +70,12 @@ public: if (value.empty()) { // Logged out. - user->WriteNumeric(RPL_LOGGEDOUT, user->GetFullHost(), "You are now logged out"); + user->WriteNumeric(RPL_LOGGEDOUT, user->GetMask(), "You are now logged out"); } else { // Logged in. - user->WriteNumeric(RPL_LOGGEDIN, user->GetFullHost(), value, INSP_FORMAT("You are now logged in as {}", value)); + user->WriteNumeric(RPL_LOGGEDIN, user->GetMask(), value, INSP_FORMAT("You are now logged in as {}", value)); } } @@ -319,7 +319,7 @@ public: if (!automatic) { ServerInstance->SNO.WriteGlobalSno('o', "{} ({}) [{}] failed to log into the \x02{}\x02 oper account because they are not logged into the correct user account.", - user->nick, user->MakeHost(), user->GetIPString(), oper->GetName()); + user->nick, user->GetRealUserHost(), user->GetAddress(), oper->GetName()); } return MOD_RES_DENY; // Account required but it does not match. } diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index 310903eea..6cb06f5d9 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -311,11 +311,11 @@ public: } std::string ipmask(user->nick); - ipmask.append(1, '!').append(user->MakeHostIP()); + ipmask.append(1, '!').append(user->GetUserAddress()); for (const auto& redirect : *redirects) { - if(InspIRCd::Match(user->GetFullRealHost(), redirect.banmask) || InspIRCd::Match(user->GetFullHost(), redirect.banmask) || InspIRCd::MatchCIDR(ipmask, redirect.banmask)) + if (InspIRCd::Match(user->GetRealMask(), redirect.banmask) || InspIRCd::Match(user->GetMask(), redirect.banmask) || InspIRCd::MatchCIDR(ipmask, redirect.banmask)) { /* This prevents recursion when a user sets multiple ban redirects in a chain * (thanks Potter) diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 516d1d513..678d923cb 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -426,8 +426,7 @@ public: if (now > (dat->lastnotify + long(notify_cooldown))) { user->WriteNumeric(RPL_TARGNOTIFY, dest->nick, "has been informed that you messaged them."); - dest->WriteRemoteNumeric(RPL_UMODEGMSG, user->nick, - INSP_FORMAT("{}@{}", user->ident, user->GetDisplayedHost()), + dest->WriteRemoteNumeric(RPL_UMODEGMSG, user->nick, user->GetUserHost(), INSP_FORMAT("is messaging you, and you have user mode +{} set. Use /ACCEPT +{} to allow.", myumode.GetModeChar(), user->nick) ); dat->lastnotify = now; diff --git a/src/modules/m_chancreate.cpp b/src/modules/m_chancreate.cpp index f2cf6e2db..2ecffeda5 100644 --- a/src/modules/m_chancreate.cpp +++ b/src/modules/m_chancreate.cpp @@ -42,7 +42,7 @@ public: { if ((created) && (IS_LOCAL(memb->user))) { - ServerInstance->SNO.WriteGlobalSno('j', "Channel {} created by {}", memb->chan->name, memb->user->GetFullRealHost()); + ServerInstance->SNO.WriteGlobalSno('j', "Channel {} created by {}", memb->chan->name, memb->user->GetRealMask()); } } }; diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index eb2229d7b..c3b8efd4c 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -44,7 +44,7 @@ struct HistoryItem final : ts(ServerInstance->Time()) , text(details.text) , type(details.type) - , sourcemask(source->GetFullHost()) + , sourcemask(source->GetMask()) { tags.reserve(details.tags_out.size()); for (const auto& [tagname, tagvalue] : details.tags_out) diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 110621510..9f9c69647 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -166,8 +166,8 @@ public: { LocalUser* localtarget = IS_LOCAL(targetuser); /* /check on a user */ - context.Write("nuh", targetuser->GetFullHost()); - context.Write("realnuh", targetuser->GetFullRealHost()); + context.Write("nuh", targetuser->GetMask()); + context.Write("realnuh", targetuser->GetRealMask()); context.Write("realname", targetuser->GetRealName()); context.Write("modes", targetuser->GetModeLetters()); context.Write("snomasks", GetSnomasks(targetuser)); @@ -212,7 +212,7 @@ public: context.Write("serializer", localtarget->serializer->name.substr(11)); } else - context.Write("onip", targetuser->GetIPString()); + context.Write("onip", targetuser->GetAddress()); CheckContext::List chanlist(context, "onchans"); for (const auto* memb : targetuser->chans) @@ -244,7 +244,7 @@ public: */ const UserManager::CloneCounts& clonecount = ServerInstance->Users.GetCloneCounts(u); context.Write("member", INSP_FORMAT("{} {}{} ({}\x0F)", clonecount.global, memb->GetAllPrefixChars(), - u->GetFullHost(), u->GetRealName())); + u->GetMask(), u->GetRealName())); } for (auto* lm : ServerInstance->Modes.GetListModes()) @@ -275,7 +275,7 @@ public: if (InspIRCd::Match(u->GetDisplayedHost(), parameters[0], ascii_case_insensitive_map)) matches.push_back("dhost"); - if (InspIRCd::MatchCIDR(u->GetIPString(), parameters[0])) + if (InspIRCd::MatchCIDR(u->GetAddress(), parameters[0])) matches.push_back("ipaddr"); if (InspIRCd::MatchCIDR(u->GetRealName(), parameters[0])) @@ -285,7 +285,7 @@ public: { const std::string whatmatch = stdalgo::string::join(matches, ','); context.Write("match", INSP_FORMAT("{} {} {} {} {} {} {} :{}", ++x, whatmatch, u->nick, u->ident, - u->GetRealHost(), u->GetDisplayedHost(), u->GetIPString(), u->GetRealName())); + u->GetRealHost(), u->GetDisplayedHost(), u->GetAddress(), u->GetRealName())); matches.clear(); } } diff --git a/src/modules/m_clearchan.cpp b/src/modules/m_clearchan.cpp index bc6849258..170faeccf 100644 --- a/src/modules/m_clearchan.cpp +++ b/src/modules/m_clearchan.cpp @@ -119,7 +119,7 @@ public: XLine* xline; try { - mask = (method[0] == 'Z') ? curr->GetIPString() : (curr->GetBanIdent() + "@" + curr->GetRealHost()); + mask = (method[0] == 'Z') ? curr->GetAddress() : (curr->GetBanIdent() + "@" + curr->GetRealHost()); xline = xlf->Generate(ServerInstance->Time(), 60*60, user->nick, reason, mask); } catch (const ModuleException&) diff --git a/src/modules/m_cloak.cpp b/src/modules/m_cloak.cpp index 0f1e8f256..84dbc5d6c 100644 --- a/src/modules/m_cloak.cpp +++ b/src/modules/m_cloak.cpp @@ -138,7 +138,7 @@ public: cloaks->push_back(cloak); ServerInstance->Logs.Debug(MODNAME, "Cloaked {} ({}/{}) as {} using the {} method.", - user->uuid, user->GetIPString(), user->GetRealHost(), + user->uuid, user->GetAddress(), user->GetRealHost(), cloak, cloakmethod->GetName()); } ext.Set(user, cloaks); diff --git a/src/modules/m_cloak_md5.cpp b/src/modules/m_cloak_md5.cpp index dc6f33613..45bb07e6a 100644 --- a/src/modules/m_cloak_md5.cpp +++ b/src/modules/m_cloak_md5.cpp @@ -255,7 +255,7 @@ struct CloakInfo final if (!Hash || !user->client_sa.is_ip()) return {}; - return GenCloak(user->client_sa, user->GetIPString(), user->GetRealHost()); + return GenCloak(user->client_sa, user->GetAddress(), user->GetRealHost()); } std::string Generate(const std::string& hostip) override diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp index 49bf1796e..ccc9c37f8 100644 --- a/src/modules/m_customtitle.cpp +++ b/src/modules/m_customtitle.cpp @@ -48,7 +48,7 @@ struct CustomTitle final bool MatchUser(User* user) const { - return InspIRCd::MatchMask(host, user->MakeHost(), user->MakeHostIP()); + return InspIRCd::MatchMask(host, user->GetRealUserHost(), user->GetUserAddress()); } bool CheckPass(const std::string& pass) const diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 24f2c4758..20dfc5897 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -447,7 +447,7 @@ public: { for (const auto& dccallow : *dl) { - if (InspIRCd::Match(user->GetFullHost(), dccallow.hostmask)) + if (InspIRCd::Match(user->GetMask(), dccallow.hostmask)) return MOD_RES_PASSTHRU; } } diff --git a/src/modules/m_disable.cpp b/src/modules/m_disable.cpp index e791236f0..c4d58d74d 100644 --- a/src/modules/m_disable.cpp +++ b/src/modules/m_disable.cpp @@ -149,7 +149,7 @@ public: // The user has tried to execute a disabled command! user->CommandFloodPenalty += 2000; - WriteLog("{} was blocked from executing the disabled {} command", user->GetFullRealHost(), command); + WriteLog("{} was blocked from executing the disabled {} command", user->GetRealMask(), command); if (fakenonexistent) { @@ -179,7 +179,7 @@ public: // The user has tried to change a disabled mode! const char* what = change.mh->GetModeType() == MODETYPE_CHANNEL ? "channel" : "user"; WriteLog("{} was blocked from {}setting the disabled {} mode {} ({})", - user->GetFullRealHost().c_str(), change.adding ? "" : "un", + user->GetRealMask().c_str(), change.adding ? "" : "un", what, change.mh->GetModeChar(), change.mh->name.c_str()); if (fakenonexistent) diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index f30b1e44c..556a5339d 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -314,7 +314,7 @@ public: { const std::string reason = Template::Replace(config->reason, { { "dnsbl", config->name }, - { "ip", them->GetIPString() }, + { "ip", them->GetAddress() }, { "result", ConvToStr(result) }, }); @@ -344,23 +344,23 @@ public: } case DNSBLEntry::Action::KLINE: { - AddLine<KLine>("K-line", reason, config->xlineduration, them->GetBanIdent(), them->GetIPString()); + AddLine<KLine>("K-line", reason, config->xlineduration, them->GetBanIdent(), them->GetAddress()); break; } case DNSBLEntry::Action::GLINE: { - AddLine<GLine>("G-line", reason, config->xlineduration, them->GetBanIdent(), them->GetIPString()); + AddLine<GLine>("G-line", reason, config->xlineduration, them->GetBanIdent(), them->GetAddress()); break; } case DNSBLEntry::Action::ZLINE: { - AddLine<ZLine>("Z-line", reason, config->xlineduration, them->GetIPString()); + AddLine<ZLine>("Z-line", reason, config->xlineduration, them->GetAddress()); break; } } ServerInstance->SNO.WriteGlobalSno('d', "Connecting user {} ({}) detected as being on the '{}' DNS blacklist with result {}", - them->GetFullRealHost(), them->GetIPString(), config->name, result); + them->GetRealMask(), them->GetAddress(), config->name, result); } else config->stats_misses++; @@ -394,7 +394,7 @@ public: return; ServerInstance->SNO.WriteGlobalSno('d', "An error occurred whilst checking whether {} ({}) is on the '{}' DNS blacklist: {}", - them->GetFullRealHost(), them->GetIPString(), config->name, data.dns->GetErrorStr(q->error)); + them->GetRealMask(), them->GetAddress(), config->name, data.dns->GetErrorStr(q->error)); } }; @@ -478,7 +478,7 @@ public: else return; - ServerInstance->Logs.Debug(MODNAME, "Reversed IP {} -> {}", user->GetIPString(), reversedip); + ServerInstance->Logs.Debug(MODNAME, "Reversed IP {} -> {}", user->GetAddress(), reversedip); data.countext.Set(user, dnsbls.size()); diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index f66e207b3..859a26265 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -463,7 +463,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar } else if (f->action == FA_SHUN && (ServerInstance->XLines->GetFactory("SHUN"))) { - auto* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); + auto* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was shunned for {} (expires on {}) because their message to {} matched {} ({})", user->nick, sh->Displayable(), Duration::ToString(f->duration), InspIRCd::TimeString(ServerInstance->Time() + f->duration), @@ -477,7 +477,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar } else if (f->action == FA_GLINE) { - auto* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, "*", user->GetIPString()); + auto* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, "*", user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was G-lined for {} (expires on {}) because their message to {} matched {} ({})", user->nick, gl->Displayable(), Duration::ToString(f->duration), InspIRCd::TimeString(ServerInstance->Time() + f->duration), @@ -491,7 +491,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar } else if (f->action == FA_ZLINE) { - auto* zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); + auto* zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was Z-lined for {} (expires on {}) because their message to {} matched {} ({})", user->nick, zl->Displayable(), Duration::ToString(f->duration), InspIRCd::TimeString(ServerInstance->Time() + f->duration), @@ -568,7 +568,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& if (f->action == FA_GLINE) { /* Note: We G-line *@IP so that if their host doesn't resolve the G-line still applies. */ - auto* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, "*", user->GetIPString()); + auto* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, "*", user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was G-lined for {} (expires on {}) because their {} message matched {} ({})", user->nick, gl->Displayable(), Duration::ToString(f->duration), @@ -584,7 +584,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& } if (f->action == FA_ZLINE) { - auto* zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); + auto* zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was Z-lined for {} (expires on {}) because their {} message matched {} ({})", user->nick, zl->Displayable(), Duration::ToString(f->duration), @@ -601,7 +601,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& else if (f->action == FA_SHUN && (ServerInstance->XLines->GetFactory("SHUN"))) { /* Note: We shun *!*@IP so that if their host doesnt resolve the shun still applies. */ - auto* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); + auto* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('f', "{} ({}) was shunned for {} (expires on {}) because their {} message matched {} ({})", user->nick, sh->Displayable(), Duration::ToString(f->duration), diff --git a/src/modules/m_gateway.cpp b/src/modules/m_gateway.cpp index a61910985..1c4e3970a 100644 --- a/src/modules/m_gateway.cpp +++ b/src/modules/m_gateway.cpp @@ -66,7 +66,7 @@ public: return true; // Does the user's IP address match this hostmask? - if (InspIRCd::MatchCIDR(user->GetIPString(), mask, ascii_case_insensitive_map)) + if (InspIRCd::MatchCIDR(user->GetAddress(), mask, ascii_case_insensitive_map)) return true; } @@ -118,7 +118,7 @@ public: return true; // Does the user's IP address match this hostmask? - if (InspIRCd::MatchCIDR(user->GetIPString(), mask, ascii_case_insensitive_map)) + if (InspIRCd::MatchCIDR(user->GetAddress(), mask, ascii_case_insensitive_map)) return true; } @@ -265,7 +265,7 @@ public: if (!ipaddr.from_ip_port(parameters[3], user->client_sa.port())) { ServerInstance->SNO.WriteGlobalSno('w', "Connecting user {} ({}) tried to use WEBIRC but gave an invalid IP address.", - user->uuid, user->GetIPString()); + user->uuid, user->GetAddress()); ServerInstance->Users.QuitUser(user, "WEBIRC: IP address is invalid: " + parameters[3]); return CmdResult::FAILURE; } @@ -273,10 +273,10 @@ public: // The user matched a WebIRC block! extban.gateway.Set(user, parameters[1]); realhost.Set(user, user->GetRealHost()); - realip.Set(user, user->GetIPString()); + realip.Set(user, user->GetAddress()); ServerInstance->SNO.WriteGlobalSno('w', "Connecting user {} is using the {} WebIRC gateway; changing their IP from {} to {}.", - user->uuid, parameters[1], user->GetIPString(), parameters[3]); + user->uuid, parameters[1], user->GetAddress(), parameters[3]); // If we have custom flags then deal with them. WebIRC::FlagMap flags; @@ -320,7 +320,7 @@ public: } ServerInstance->SNO.WriteGlobalSno('w', "Connecting user {} ({}) tried to use WEBIRC but didn't match any configured WebIRC hosts.", - user->uuid, user->GetIPString()); + user->uuid, user->GetAddress()); ServerInstance->Users.QuitUser(user, "WEBIRC: you don't match any configured WebIRC hosts."); return CmdResult::FAILURE; } @@ -455,11 +455,11 @@ public: // Store the hostname and IP of the gateway for later use. cmdwebirc.realhost.Set(user, user->GetRealHost()); - cmdwebirc.realip.Set(user, user->GetIPString()); + cmdwebirc.realip.Set(user, user->GetAddress()); const std::string& newident = host.GetIdent(); ServerInstance->SNO.WriteGlobalSno('w', "Connecting user {} is using an ident gateway; changing their IP from {} to {} and their ident from {} to {}.", - user->uuid, user->GetIPString(), address.addr(), user->ident, newident); + user->uuid, user->GetAddress(), address.addr(), user->ident, newident); user->ChangeIdent(newident); user->ChangeRemoteAddress(address); diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index 6970ab2ce..6234f7c93 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -174,7 +174,7 @@ public: extra += INSP_FORMAT("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime); } - stats.AddGenericRow(INSP_FORMAT("\x02{}\x02 ({}){}", oper->nick, oper->MakeHost(), extra)); + stats.AddGenericRow(INSP_FORMAT("\x02{}\x02 ({}){}", oper->nick, oper->GetRealUserHost(), extra)); } stats.AddGenericRow(INSP_FORMAT("{} server operator{} total", opers, opers ? "s" : "")); return MOD_RES_DENY; diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp index be2956c73..6efab2b20 100644 --- a/src/modules/m_hostchange.cpp +++ b/src/modules/m_hostchange.cpp @@ -106,10 +106,10 @@ public: if (!ports.empty() && !ports.count(user->server_sa.port())) return false; - if (InspIRCd::MatchCIDR(user->MakeHost(), mask)) + if (InspIRCd::MatchCIDR(user->GetRealUserHost(), mask)) return true; - return InspIRCd::MatchCIDR(user->MakeHostIP(), mask); + return InspIRCd::MatchCIDR(user->GetUserAddress(), mask); } void Wrap(const std::string& value, std::string& out) const diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 06efed523..fcc0e65d7 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -265,7 +265,7 @@ namespace Stats .Attribute("nickchanged", u->nickchanged) .Attribute("modes", u->GetModeLetters().substr(1)) .Attribute("ident", u->ident) - .Attribute("ipaddress", u->GetIPString()); + .Attribute("ipaddress", u->GetAddress()); if (u->IsAway()) { diff --git a/src/modules/m_ircv3_ctctags.cpp b/src/modules/m_ircv3_ctctags.cpp index 0e808d2c8..9af2f52ad 100644 --- a/src/modules/m_ircv3_ctctags.cpp +++ b/src/modules/m_ircv3_ctctags.cpp @@ -173,7 +173,7 @@ private: // Drop attempts to send a tag message to a server. This usually happens when the // server is started in debug mode and a client tries to send a typing notification // to a query window created by the debug message. - if (!target && irc::equals(parameters[0], ServerInstance->FakeClient->GetFullHost())) + if (!target && irc::equals(parameters[0], ServerInstance->FakeClient->GetMask())) return CmdResult::FAILURE; } } diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index 330d50c58..ea0764d5d 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -138,7 +138,7 @@ public: if (notify & KN_SEND_NUMERIC) { Numeric::Numeric numeric(RPL_KNOCK); - numeric.push(c->name).push(user->GetFullHost()).push("is KNOCKing: " + parameters[1]); + numeric.push(c->name).push(user->GetMask()).push("is KNOCKing: " + parameters[1]); ClientProtocol::Messages::Numeric numericmsg(numeric, c->name); c->Write(ServerInstance->GetRFCEvents().numeric, numericmsg, status); diff --git a/src/modules/m_ldapauth.cpp b/src/modules/m_ldapauth.cpp index 642dbad88..b10945a43 100644 --- a/src/modules/m_ldapauth.cpp +++ b/src/modules/m_ldapauth.cpp @@ -124,7 +124,7 @@ public: if (!checkingAttributes && requiredattributes.empty()) { if (verbose) - ServerInstance->SNO.WriteToSnoMask('c', "Successful connection from {} (dn={})", user->GetFullRealHost(), DN); + ServerInstance->SNO.WriteToSnoMask('c', "Successful connection from {} (dn={})", user->GetRealMask(), DN); // We're done, there are no attributes to check SetVHost(user, DN); @@ -143,7 +143,7 @@ public: passed = true; if (verbose) - ServerInstance->SNO.WriteToSnoMask('c', "Successful connection from {} (dn={})", user->GetFullRealHost(), DN); + ServerInstance->SNO.WriteToSnoMask('c', "Successful connection from {} (dn={})", user->GetRealMask(), DN); SetVHost(user, DN); authed->Set(user); @@ -181,7 +181,7 @@ public: if (verbose) { ServerInstance->SNO.WriteToSnoMask('c', "Forbidden connection from {} (dn={}) (unable to validate attributes)", - user->GetFullRealHost(), DN); + user->GetRealMask(), DN); } ServerInstance->Users.QuitUser(user, killreason); delete this; @@ -205,7 +205,7 @@ public: if (verbose) { ServerInstance->SNO.WriteToSnoMask('c', "Forbidden connection from {} ({})", - user->GetFullRealHost(), err.getError()); + user->GetRealMask(), err.getError()); } ServerInstance->Users.QuitUser(user, killreason); } @@ -400,7 +400,7 @@ public: for (const auto& whitelistedcidr : whitelistedcidrs) { - if (InspIRCd::MatchCIDR(user->GetIPString(), whitelistedcidr, ascii_case_insensitive_map)) + if (InspIRCd::MatchCIDR(user->GetAddress(), whitelistedcidr, ascii_case_insensitive_map)) { ldapAuthed.Set(user, true); return MOD_RES_PASSTHRU; @@ -410,7 +410,7 @@ public: if (user->password.empty()) { if (verbose) - ServerInstance->SNO.WriteToSnoMask('c', "Forbidden connection from {} (no password provided)", user->GetFullRealHost()); + ServerInstance->SNO.WriteToSnoMask('c', "Forbidden connection from {} (no password provided)", user->GetRealMask()); ServerInstance->Users.QuitUser(user, killreason); return MOD_RES_DENY; } @@ -418,7 +418,7 @@ public: if (!LDAP) { if (verbose) - ServerInstance->SNO.WriteToSnoMask('c', "Forbidden connection from {} (unable to find LDAP provider)", user->GetFullRealHost()); + ServerInstance->SNO.WriteToSnoMask('c', "Forbidden connection from {} (unable to find LDAP provider)", user->GetRealMask()); ServerInstance->Users.QuitUser(user, killreason); return MOD_RES_DENY; } diff --git a/src/modules/m_ldapoper.cpp b/src/modules/m_ldapoper.cpp index 342fbc3f3..40be350de 100644 --- a/src/modules/m_ldapoper.cpp +++ b/src/modules/m_ldapoper.cpp @@ -226,7 +226,7 @@ public: return MOD_RES_PASSTHRU; std::string acceptedhosts = it->second->GetConfig()->getString("host"); - if (!InspIRCd::MatchMask(acceptedhosts, user->MakeHost(), user->MakeHostIP())) + if (!InspIRCd::MatchMask(acceptedhosts, user->GetRealUserHost(), user->GetUserAddress())) return MOD_RES_PASSTHRU; if (!LDAP) diff --git a/src/modules/m_operlog.cpp b/src/modules/m_operlog.cpp index 8460f7f96..bdb32b9ce 100644 --- a/src/modules/m_operlog.cpp +++ b/src/modules/m_operlog.cpp @@ -54,7 +54,7 @@ public: Command* thiscommand = ServerInstance->Parser.GetHandler(command); if ((thiscommand) && (thiscommand->access_needed == CmdAccess::OPERATOR)) { - std::string msg = "[" + user->GetFullRealHost() + "] " + command + " " + stdalgo::string::join(parameters); + std::string msg = "[" + user->GetRealMask() + "] " + command + " " + stdalgo::string::join(parameters); if (tosnomask) ServerInstance->SNO.WriteGlobalSno('o', msg); else diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index 0c694208f..4c804fe09 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -55,7 +55,7 @@ public: return false; const std::string host = u->nick + "!" + u->ident + "@" + u->GetRealHost() + " " + u->GetRealName(); - const std::string ip = u->nick + "!" + u->ident + "@" + u->GetIPString() + " " + u->GetRealName(); + const std::string ip = u->nick + "!" + u->ident + "@" + u->GetAddress() + " " + u->GetRealName(); return (regex->IsMatch(host) || regex->IsMatch(ip)); } @@ -68,18 +68,18 @@ public: { if (ZlineOnMatch) { - auto* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, MODNAME "@" + ServerInstance->Config->ServerName, reason, u->GetIPString()); + auto* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, MODNAME "@" + ServerInstance->Config->ServerName, reason, u->GetAddress()); if (ServerInstance->XLines->AddLine(zl, nullptr)) { if (!duration) { ServerInstance->SNO.WriteToSnoMask('x', "{} added a permanent Z-line on {}: {}", - zl->source, u->GetIPString(), zl->reason); + zl->source, u->GetAddress(), zl->reason); } else { ServerInstance->SNO.WriteToSnoMask('x', "{} added a timed Z-line on {}, expires in {} (on {}): {}", - zl->source, u->GetIPString(), Duration::ToString(zl->duration), + zl->source, u->GetAddress(), Duration::ToString(zl->duration), InspIRCd::TimeString(zl->duration), zl->reason); } added_zline = true; diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index c9f585cbe..85aba2d0f 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -188,7 +188,7 @@ private: std::vector<std::string> params; params.reserve(3); params.push_back(user->GetRealHost()); - params.push_back(user->GetIPString()); + params.push_back(user->GetAddress()); params.emplace_back(sslapi && sslapi->GetCertificate(user) ? "S" : "P"); SendSASL(user, "*", 'H', params); diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index e07c3b973..18d6e495d 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -90,10 +90,10 @@ public: // Allow if the source matches an <securehost> entry. for (const auto& allowhost : allowlist) { - if (InspIRCd::Match(user->MakeHost(), allowhost, ascii_case_insensitive_map)) + if (InspIRCd::Match(user->GetRealUserHost(), allowhost, ascii_case_insensitive_map)) return MOD_RES_PASSTHRU; - if (InspIRCd::Match(user->MakeHostIP(), allowhost, ascii_case_insensitive_map)) + if (InspIRCd::Match(user->GetUserAddress(), allowhost, ascii_case_insensitive_map)) return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 20bafbadb..b51d18651 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -77,7 +77,7 @@ public: auto* find = ServerInstance->Users.Find(target, true); if (find) - target = "*!" + find->GetBanIdent() + "@" + find->GetIPString(); + target = "*!" + find->GetBanIdent() + "@" + find->GetAddress(); if (parameters.size() == 1) { diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 4c3c8d26e..15690fb47 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -439,7 +439,7 @@ private: if (!(entry.flags & flag)) continue; - if (InspIRCd::Match(source->GetFullHost(), entry.mask)) + if (InspIRCd::Match(source->GetMask(), entry.mask)) return entry.flags & SilenceEntry::SF_EXEMPT; } diff --git a/src/modules/m_spanningtree/ftopic.cpp b/src/modules/m_spanningtree/ftopic.cpp index 19c2e36ea..4ecf5d616 100644 --- a/src/modules/m_spanningtree/ftopic.cpp +++ b/src/modules/m_spanningtree/ftopic.cpp @@ -45,7 +45,7 @@ CmdResult CommandFTopic::Handle(User* user, Params& params) const std::string& newtopic = params.back(); // If there is a setter in the message use that, otherwise use the message source - const std::string& setter = ((params.size() > 4) ? params[3] : (ServerInstance->Config->FullHostInTopic ? user->GetFullHost() : user->nick)); + const std::string& setter = ((params.size() > 4) ? params[3] : (ServerInstance->Config->FullHostInTopic ? user->GetMask() : user->nick)); /* * If the topics were updated at the exact same second, accept diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 2354f5587..3e6ba9ec9 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -611,7 +611,7 @@ void ModuleSpanningTree::OnUserQuit(User* user, const std::string& reason, const if (!hide) { ServerInstance->SNO.WriteToSnoMask('Q', "Client exiting on server {}: {} ({}) [{}]", user->server->GetName(), - user->GetFullRealHost(), user->GetIPString(), oper_message); + user->GetRealMask(), user->GetAddress(), oper_message); } } diff --git a/src/modules/m_spanningtree/nick.cpp b/src/modules/m_spanningtree/nick.cpp index a4c5cb120..daea6d236 100644 --- a/src/modules/m_spanningtree/nick.cpp +++ b/src/modules/m_spanningtree/nick.cpp @@ -42,7 +42,7 @@ CmdResult CommandNick::HandleRemote(::RemoteUser* user, Params& params) { // 'x' is the already existing user using the same nick as params[0] // 'user' is the user trying to change nick to the in use nick - bool they_change = SpanningTreeUtilities::DoCollision(x, TreeServer::Get(user), newts, user->ident, user->GetIPString(), user->uuid, "NICK"); + bool they_change = SpanningTreeUtilities::DoCollision(x, TreeServer::Get(user), newts, user->ident, user->GetAddress(), user->uuid, "NICK"); if (they_change) { // Remote client lost, or both lost, rewrite this nick change as a change to uuid before diff --git a/src/modules/m_spanningtree/nickcollide.cpp b/src/modules/m_spanningtree/nickcollide.cpp index c44196e92..97a63e7e3 100644 --- a/src/modules/m_spanningtree/nickcollide.cpp +++ b/src/modules/m_spanningtree/nickcollide.cpp @@ -70,7 +70,7 @@ bool SpanningTreeUtilities::DoCollision(User* u, TreeServer* server, time_t remo { /* first, let's see if ident@host matches. */ const std::string& localident = u->ident; - const std::string& localip = u->GetIPString(); + const std::string& localip = u->GetAddress(); bool SamePerson = (localident == remoteident) && (localip == remoteip); @@ -91,7 +91,7 @@ bool SpanningTreeUtilities::DoCollision(User* u, TreeServer* server, time_t remo } ServerInstance->Logs.Debug(MODNAME, "Nick collision on \"{}\" caused by {}: {}/{}/{}@{} {} <-> {}/{}/{}@{} {}", u->nick, collidecmd, - u->uuid, localts, u->ident, u->GetIPString(), bChangeLocal, + u->uuid, localts, u->ident, u->GetAddress(), bChangeLocal, remoteuid, remotets, remoteident, remoteip, bChangeRemote); /* diff --git a/src/modules/m_spanningtree/opertype.cpp b/src/modules/m_spanningtree/opertype.cpp index 74892d4b3..4e994124d 100644 --- a/src/modules/m_spanningtree/opertype.cpp +++ b/src/modules/m_spanningtree/opertype.cpp @@ -110,7 +110,7 @@ CmdResult CommandOpertype::HandleRemote(RemoteUser* u, CommandBase::Params& para } ServerInstance->SNO.WriteToSnoMask('O', "From {}: {} ({}) [{}] is now a server operator of type \x02{}\x02{}.", - u->server->GetName(), u->nick, u->MakeHost(), u->GetIPString(), u->oper->GetType(), extra); + u->server->GetName(), u->nick, u->GetRealUserHost(), u->GetAddress(), u->oper->GetType(), extra); return CmdResult::SUCCESS; } diff --git a/src/modules/m_spanningtree/override_squit.cpp b/src/modules/m_spanningtree/override_squit.cpp index 95bd2fea3..5f39d95fd 100644 --- a/src/modules/m_spanningtree/override_squit.cpp +++ b/src/modules/m_spanningtree/override_squit.cpp @@ -45,7 +45,7 @@ ModResult ModuleSpanningTree::HandleSquit(const CommandBase::Params& parameters, if (s->IsLocal()) { ServerInstance->SNO.WriteToSnoMask('l', "SQUIT: Server \002{}\002 removed from network by {}", parameters[0], user->nick); - s->SQuit("Server quit by " + user->GetFullRealHost()); + s->SQuit("Server quit by " + user->GetRealMask()); } else { diff --git a/src/modules/m_spanningtree/rsquit.cpp b/src/modules/m_spanningtree/rsquit.cpp index d57510bb0..1a9426e8b 100644 --- a/src/modules/m_spanningtree/rsquit.cpp +++ b/src/modules/m_spanningtree/rsquit.cpp @@ -59,7 +59,7 @@ CmdResult CommandRSQuit::Handle(User* user, const Params& parameters) // We have been asked to remove server_target. const char* reason = parameters.size() == 2 ? parameters[1].c_str() : "No reason"; ServerInstance->SNO.WriteToSnoMask('l', "RSQUIT: Server \002{}\002 removed from network by {} ({})", parameters[0], user->nick, reason); - server_target->SQuit("Server quit by " + user->GetFullRealHost() + " (" + reason + ")"); + server_target->SQuit("Server quit by " + user->GetRealMask() + " (" + reason + ")"); } return CmdResult::SUCCESS; diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index 96dfa9fff..7e8ff1383 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -137,7 +137,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, CommandBase::Params if (dosend) { ServerInstance->SNO.WriteToSnoMask('C', "Client connecting at {}: {} ({}) [{}\x0F]", remoteserver->GetName(), - _new->GetFullRealHost(), _new->GetIPString(), _new->GetRealName()); + _new->GetRealMask(), _new->GetAddress(), _new->GetRealName()); } FOREACH_MOD(OnPostConnect, (_new)); @@ -179,7 +179,7 @@ CommandUID::Builder::Builder(User* user) push(user->GetRealHost()); push(user->GetDisplayedHost()); push(user->ident); - push(user->GetIPString()); + push(user->GetAddress()); push_int(user->signon); push(user->GetModeLetters(true)); push_last(user->GetRealName()); diff --git a/src/modules/m_sqlauth.cpp b/src/modules/m_sqlauth.cpp index 3692c0373..d31ad53b3 100644 --- a/src/modules/m_sqlauth.cpp +++ b/src/modules/m_sqlauth.cpp @@ -70,7 +70,7 @@ public: if (!hashprov) { if (verbose) - ServerInstance->SNO.WriteGlobalSno('a', "Forbidden connection from {} (a provider for {} was not loaded)", user->GetFullRealHost(), kdf); + ServerInstance->SNO.WriteGlobalSno('a', "Forbidden connection from {} (a provider for {} was not loaded)", user->GetRealMask(), kdf); pendingExt.Set(user, AUTH_STATE_FAIL); return; } @@ -79,7 +79,7 @@ public: if (!pwcolumn.empty() && !res.HasColumn(pwcolumn, colindex)) { if (verbose) - ServerInstance->SNO.WriteGlobalSno('a', "Forbidden connection from {} (the column specified ({}) was not returned)", user->GetFullRealHost(), pwcolumn); + ServerInstance->SNO.WriteGlobalSno('a', "Forbidden connection from {} (the column specified ({}) was not returned)", user->GetRealMask(), pwcolumn); pendingExt.Set(user, AUTH_STATE_FAIL); return; } @@ -95,7 +95,7 @@ public: } if (verbose) - ServerInstance->SNO.WriteGlobalSno('a', "Forbidden connection from {} (password from the SQL query did not match the user provided password)", user->GetFullRealHost()); + ServerInstance->SNO.WriteGlobalSno('a', "Forbidden connection from {} (password from the SQL query did not match the user provided password)", user->GetRealMask()); pendingExt.Set(user, AUTH_STATE_FAIL); return; } @@ -105,7 +105,7 @@ public: else { if (verbose) - ServerInstance->SNO.WriteGlobalSno('a', "Forbidden connection from {} (SQL query returned no matches)", user->GetFullRealHost()); + ServerInstance->SNO.WriteGlobalSno('a', "Forbidden connection from {} (SQL query returned no matches)", user->GetRealMask()); pendingExt.Set(user, AUTH_STATE_FAIL); } } @@ -117,7 +117,7 @@ public: return; pendingExt.Set(user, AUTH_STATE_FAIL); if (verbose) - ServerInstance->SNO.WriteGlobalSno('a', "Forbidden connection from {} (SQL query failed: {})", user->GetFullRealHost(), error.ToString()); + ServerInstance->SNO.WriteGlobalSno('a', "Forbidden connection from {} (SQL query failed: {})", user->GetRealMask(), error.ToString()); } }; @@ -181,7 +181,7 @@ public: if (!SQL) { - ServerInstance->SNO.WriteGlobalSno('a', "Forbidden connection from {} (SQL database not present)", user->GetFullRealHost()); + ServerInstance->SNO.WriteGlobalSno('a', "Forbidden connection from {} (SQL database not present)", user->GetRealMask()); ServerInstance->Users.QuitUser(user, killreason); return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index f08c99e0c..5341f5c96 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -165,7 +165,7 @@ public: void SetCertificate(User* user, ssl_cert* cert) override { ServerInstance->Logs.Debug(MODNAME, "Setting TLS client certificate for {}: {}", - user->GetFullHost(), sslext.ToNetwork(user, cert)); + user->GetMask(), sslext.ToNetwork(user, cert)); sslext.Set(user, cert); } }; @@ -342,7 +342,7 @@ public: if (!automatic) { ServerInstance->SNO.WriteGlobalSno('o', "{} ({}) [{}] failed to log into the \x02{}\x02 oper account because they are not connected using TLS.", - user->nick, user->MakeHost(), user->GetIPString(), oper->GetName()); + user->nick, user->GetRealUserHost(), user->GetAddress(), oper->GetName()); } return MOD_RES_DENY; } @@ -353,7 +353,7 @@ public: if (!automatic) { ServerInstance->SNO.WriteGlobalSno('o', "{} ({}) [{}] failed to log into the \x02{}\x02 oper account because they are not using the correct TLS client certificate.", - user->nick, user->MakeHost(), user->GetIPString(), oper->GetName()); + user->nick, user->GetRealUserHost(), user->GetAddress(), oper->GetName()); } return MOD_RES_DENY; } diff --git a/src/modules/m_tline.cpp b/src/modules/m_tline.cpp index 52bb3cec4..3dd38bf89 100644 --- a/src/modules/m_tline.cpp +++ b/src/modules/m_tline.cpp @@ -44,14 +44,14 @@ public: for (const auto& [_, u] : ServerInstance->Users.GetUsers()) { - if (InspIRCd::Match(u->GetFullRealHost(), parameters[0])) + if (InspIRCd::Match(u->GetRealMask(), parameters[0])) { n_matched++; n_match_host++; } else { - if (InspIRCd::MatchCIDR(u->MakeHostIP(), parameters[0])) + if (InspIRCd::MatchCIDR(u->GetUserAddress(), parameters[0])) { n_matched++; n_match_ip++; diff --git a/src/modules/m_uhnames.cpp b/src/modules/m_uhnames.cpp index 73255ffab..0777d5c4f 100644 --- a/src/modules/m_uhnames.cpp +++ b/src/modules/m_uhnames.cpp @@ -45,7 +45,7 @@ public: ModResult OnNamesListItem(LocalUser* issuer, Membership* memb, std::string& prefixes, std::string& nick) override { if (cap.IsEnabled(issuer)) - nick = memb->user->GetFullHost(); + nick = memb->user->GetMask(); return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_websocket.cpp b/src/modules/m_websocket.cpp index e0af106cc..0ad907c69 100644 --- a/src/modules/m_websocket.cpp +++ b/src/modules/m_websocket.cpp @@ -435,7 +435,7 @@ class WebSocketHook final } for (const auto& proxyrange : config.proxyranges) { - if (InspIRCd::MatchCIDR(luser->GetIPString(), proxyrange, ascii_case_insensitive_map)) + if (InspIRCd::MatchCIDR(luser->GetAddress(), proxyrange, ascii_case_insensitive_map)) { // Give the user their real IP address. if (realsa != luser->client_sa) diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 4262f6c92..1b64f61f9 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -196,13 +196,13 @@ void UserManager::AddUser(int socket, ListenSocket* via, const irc::sockets::soc */ New->exempt = (ServerInstance->XLines->MatchesLine("E", New) != nullptr); - BanCacheHit* const b = ServerInstance->BanCache.GetHit(New->GetIPString()); + BanCacheHit* const b = ServerInstance->BanCache.GetHit(New->GetAddress()); if (b) { if (!b->Type.empty() && !New->exempt) { /* user banned */ - ServerInstance->Logs.Debug("BANCACHE", "BanCache: Positive hit for " + New->GetIPString()); + ServerInstance->Logs.Debug("BANCACHE", "BanCache: Positive hit for " + New->GetAddress()); if (!ServerInstance->Config->XLineMessage.empty()) New->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage); @@ -214,7 +214,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, const irc::sockets::soc } else { - ServerInstance->Logs.Debug("BANCACHE", "BanCache: Negative hit for " + New->GetIPString()); + ServerInstance->Logs.Debug("BANCACHE", "BanCache: Negative hit for " + New->GetAddress()); } } else @@ -279,7 +279,7 @@ void UserManager::QuitUser(User* user, const std::string& quitmessage, const std ServerInstance->Logs.Debug("USERS", "QuitUser: {}={} '{}'", user->uuid, user->nick, quitmessage); if (localuser) { - ClientProtocol::Messages::Error errormsg(INSP_FORMAT("Closing link: ({}) [{}]", user->MakeHost(), operquitmsg)); + ClientProtocol::Messages::Error errormsg(INSP_FORMAT("Closing link: ({}) [{}]", user->GetRealUserHost(), operquitmsg)); localuser->Send(ServerInstance->GetRFCEvents().error, errormsg); } @@ -301,8 +301,8 @@ void UserManager::QuitUser(User* user, const std::string& quitmessage, const std if (lu->IsFullyConnected()) { - ServerInstance->SNO.WriteToSnoMask('q', "Client exiting: {} ({}) [{}]", user->GetFullRealHost(), - user->GetIPString(), operquitmsg); + ServerInstance->SNO.WriteToSnoMask('q', "Client exiting: {} ({}) [{}]", user->GetRealMask(), + user->GetAddress(), operquitmsg); } local_users.erase(lu); if (lu->GetClass()) diff --git a/src/users.cpp b/src/users.cpp index 0ed4c6e33..cf2652403 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -107,6 +107,78 @@ User::User(const std::string& uid, Server* srv, Type type) } } +const std::string& User::GetAddress() +{ + if (cached_address.empty()) + { + cached_address = client_sa.addr(); + + // If the user is connecting from an IPv4 address like ::1 we + // need to partially expand the address to avoid issues with + // the IRC wire format. + if (cached_address[0] == ':') + cached_address.insert(cached_address.begin(), 1, 0); + + cached_address.shrink_to_fit(); + } + + return cached_address; +} + +const std::string& User::GetUserAddress() +{ + if (cached_useraddress.empty()) + { + cached_useraddress = INSP_FORMAT("{}@{}", ident, GetAddress()); + cached_address.shrink_to_fit(); + } + + return cached_useraddress; +} +const std::string& User::GetUserHost() +{ + if (cached_userhost.empty()) + { + cached_userhost = INSP_FORMAT("{}@{}", ident, GetDisplayedHost()); + cached_userhost.shrink_to_fit(); + } + + return cached_userhost; +} + +const std::string& User::GetRealUserHost() +{ + if (cached_realuserhost.empty()) + { + cached_realuserhost = INSP_FORMAT("{}@{}", ident, GetRealHost()); + cached_realuserhost.shrink_to_fit(); + } + + return cached_realuserhost; +} + +const std::string& User::GetMask() +{ + if (cached_mask.empty()) + { + cached_mask = INSP_FORMAT("{}!{}@{}", nick, ident, GetDisplayedHost()); + cached_mask.shrink_to_fit(); + } + + return cached_mask; +} + +const std::string& User::GetRealMask() +{ + if (cached_realmask.empty()) + { + cached_realmask = INSP_FORMAT("{}!{}@{}", nick, ident, GetRealHost()); + cached_realmask.shrink_to_fit(); + } + + return cached_realmask; +} + LocalUser::LocalUser(int myfd, const irc::sockets::sockaddrs& clientsa, const irc::sockets::sockaddrs& serversa) : User(ServerInstance->UIDGen.GetUID(), ServerInstance->FakeClient->server, User::TYPE_LOCAL) , eh(this) @@ -121,43 +193,29 @@ LocalUser::LocalUser(int myfd, const irc::sockets::sockaddrs& clientsa, const ir ident = uuid; eh.SetFd(myfd); memcpy(&client_sa, &clientsa, sizeof(irc::sockets::sockaddrs)); - ChangeRealHost(GetIPString(), true); + ChangeRealHost(GetAddress(), true); } -const std::string& User::MakeHost() +FakeUser::FakeUser(const std::string& uid, Server* srv) + : User(uid, srv, TYPE_SERVER) { - if (!this->cached_makehost.empty()) - return this->cached_makehost; - - this->cached_makehost = ident + "@" + GetRealHost(); - return this->cached_makehost; + nick = srv->GetName(); } -const std::string& User::MakeHostIP() +FakeUser::FakeUser(const std::string& uid, const std::string& sname, const std::string& sdesc) + : User(uid, new Server(uid, sname, sdesc), TYPE_SERVER) { - if (!this->cached_hostip.empty()) - return this->cached_hostip; - - this->cached_hostip = ident + "@" + this->GetIPString(); - return this->cached_hostip; + nick = sname; } -const std::string& User::GetFullHost() +const std::string& FakeUser::GetMask() { - if (!this->cached_fullhost.empty()) - return this->cached_fullhost; - - this->cached_fullhost = nick + "!" + ident + "@" + GetDisplayedHost(); - return this->cached_fullhost; + return server->GetPublicName(); } -const std::string& User::GetFullRealHost() +const std::string& FakeUser::GetRealMask() { - if (!this->cached_fullrealhost.empty()) - return this->cached_fullrealhost; - - this->cached_fullrealhost = nick + "!" + ident + "@" + GetRealHost(); - return this->cached_fullrealhost; + return server->GetPublicName(); } void UserIOHandler::OnDataReady() @@ -431,10 +489,10 @@ void LocalUser::FullConnect() FOREACH_MOD(OnPostConnect, (this)); ServerInstance->SNO.WriteToSnoMask('c', "Client connecting on port {} (class {}): {} ({}) [{}\x0F]", - server_sa.port(), GetClass()->GetName(), GetFullRealHost(), GetIPString(), GetRealName()); + server_sa.port(), GetClass()->GetName(), GetRealMask(), GetAddress(), GetRealName()); - ServerInstance->Logs.Debug("BANCACHE", "BanCache: Adding NEGATIVE hit for " + this->GetIPString()); - ServerInstance->BanCache.AddHit(this->GetIPString(), "", ""); + ServerInstance->Logs.Debug("BANCACHE", "BanCache: Adding NEGATIVE hit for " + this->GetAddress()); + ServerInstance->BanCache.AddHit(this->GetAddress(), "", ""); // reset the flood penalty (which could have been raised due to things like auto +x) CommandFloodPenalty = 0; } @@ -442,11 +500,12 @@ void LocalUser::FullConnect() void User::InvalidateCache() { /* Invalidate cache */ - cachedip.clear(); - cached_fullhost.clear(); - cached_hostip.clear(); - cached_makehost.clear(); - cached_fullrealhost.clear(); + cached_address.clear(); + cached_useraddress.clear(); + cached_userhost.clear(); + cached_realuserhost.clear(); + cached_mask.clear(); + cached_realmask.clear(); } bool User::ChangeNick(const std::string& newnick, time_t newts) @@ -528,19 +587,6 @@ void LocalUser::OverruleNick() this->ChangeNick(this->uuid); } -const std::string& User::GetIPString() -{ - if (cachedip.empty()) - { - cachedip = client_sa.addr(); - /* IP addresses starting with a : on irc are a Bad Thing (tm) */ - if (cachedip[0] == ':') - cachedip.insert(cachedip.begin(), 1, '0'); - } - - return cachedip; -} - const std::string& User::GetBanIdent() const { static const std::string wildcard = "*"; @@ -584,15 +630,15 @@ irc::sockets::cidr_mask User::GetCIDRMask() const void User::ChangeRemoteAddress(const irc::sockets::sockaddrs& sa) { - const std::string oldip(client_sa.family() == AF_UNSPEC ? "" : GetIPString()); + const std::string oldip(client_sa.family() == AF_UNSPEC ? "" : GetAddress()); memcpy(&client_sa, &sa, sizeof(irc::sockets::sockaddrs)); this->InvalidateCache(); // If the users hostname was their IP then update it. if (GetRealHost() == oldip) - ChangeRealHost(GetIPString(), false); + ChangeRealHost(GetAddress(), false); if (GetDisplayedHost() == oldip) - ChangeDisplayedHost(GetIPString()); + ChangeDisplayedHost(GetAddress()); } void LocalUser::ChangeRemoteAddress(const irc::sockets::sockaddrs& sa) @@ -612,7 +658,7 @@ void LocalUser::ChangeRemoteAddress(const irc::sockets::sockaddrs& sa) bool LocalUser::FindConnectClass() { ServerInstance->Logs.Debug("CONNECTCLASS", "Finding a connect class for {} ({}) ...", - uuid, GetFullRealHost()); + uuid, GetRealMask()); for (const auto& klass : ServerInstance->Config->Classes) { @@ -632,7 +678,7 @@ bool LocalUser::FindConnectClass() if (modres != MOD_RES_DENY) { ServerInstance->Logs.Debug("CONNECTCLASS", "The {} connect class is suitable for {} ({}).", - klass->GetName(), uuid, GetFullRealHost()); + klass->GetName(), uuid, GetRealMask()); ChangeConnectClass(klass, false); return !quitting; @@ -700,7 +746,7 @@ void LocalUser::Send(ClientProtocol::Event& protoev) if (!serializer) { ServerInstance->Logs.Debug("USERS", "BUG: LocalUser::Send() called on {} who does not have a serializer!", - GetFullRealHost()); + GetRealMask()); return; } @@ -985,16 +1031,6 @@ void User::WriteNotice(const std::string& text) localuser->Send(ServerInstance->GetRFCEvents().privmsg, msg); } -const std::string& FakeUser::GetFullHost() -{ - return server->GetPublicName(); -} - -const std::string& FakeUser::GetFullRealHost() -{ - return server->GetPublicName(); -} - ConnectClass::ConnectClass(const std::shared_ptr<ConfigTag>& tag, Type t, const std::vector<std::string>& masks) : config(tag) , hosts(masks) diff --git a/src/xline.cpp b/src/xline.cpp index 10ca2b95f..6cc44447f 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -576,8 +576,8 @@ void XLine::DefaultApply(User* u, const std::string& line, bool bancache) if (bancache) { - ServerInstance->Logs.Debug("BANCACHE", "BanCache: Adding positive hit (" + line + ") for " + u->GetIPString()); - ServerInstance->BanCache.AddHit(u->GetIPString(), this->type, banReason, (this->duration > 0 ? (this->expiry - ServerInstance->Time()) : 0)); + ServerInstance->Logs.Debug("BANCACHE", "BanCache: Adding positive hit (" + line + ") for " + u->GetAddress()); + ServerInstance->BanCache.AddHit(u->GetAddress(), this->type, banReason, (this->duration > 0 ? (this->expiry - ServerInstance->Time()) : 0)); } } @@ -590,7 +590,7 @@ bool KLine::Matches(User* u) if (InspIRCd::Match(u->ident, this->identmask, 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)) + InspIRCd::MatchCIDR(u->GetAddress(), this->hostmask, ascii_case_insensitive_map)) { return true; } @@ -613,7 +613,7 @@ bool GLine::Matches(User* u) if (InspIRCd::Match(u->ident, this->identmask, 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)) + InspIRCd::MatchCIDR(u->GetAddress(), this->hostmask, ascii_case_insensitive_map)) { return true; } @@ -632,7 +632,7 @@ bool ELine::Matches(User* u) if (InspIRCd::Match(u->ident, this->identmask, 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)) + InspIRCd::MatchCIDR(u->GetAddress(), this->hostmask, ascii_case_insensitive_map)) { return true; } @@ -647,7 +647,7 @@ bool ZLine::Matches(User* u) if (lu && lu->exempt) return false; - return InspIRCd::MatchCIDR(u->GetIPString(), this->ipaddr); + return InspIRCd::MatchCIDR(u->GetAddress(), this->ipaddr); } void ZLine::Apply(User* u) |
