diff options
-rw-r--r-- | include/users.h | 2 | ||||
-rw-r--r-- | src/commands/cmd_oper.cpp | 2 | ||||
-rw-r--r-- | src/modules/extra/m_ldapoper.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_customtitle.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_dnsbl.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/uid.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_sqloper.cpp | 2 | ||||
-rw-r--r-- | src/user_resolver.cpp | 6 | ||||
-rw-r--r-- | src/usermanager.cpp | 8 | ||||
-rw-r--r-- | src/users.cpp | 19 | ||||
-rw-r--r-- | src/whois.cpp | 2 |
12 files changed, 28 insertions, 29 deletions
diff --git a/include/users.h b/include/users.h index 88abfbcd1..c79bf7cb8 100644 --- a/include/users.h +++ b/include/users.h @@ -384,7 +384,7 @@ class CoreExport User : public Extensible /** Get client IP string from sockaddr, using static internal buffer * @return The IP string */ - const char* GetIPString(); + const std::string& GetIPString(); /** Get CIDR mask, using default range, for this user */ diff --git a/src/commands/cmd_oper.cpp b/src/commands/cmd_oper.cpp index 1a5e7e178..4492a385a 100644 --- a/src/commands/cmd_oper.cpp +++ b/src/commands/cmd_oper.cpp @@ -66,7 +66,7 @@ CmdResult CommandOper::HandleLocal(const std::vector<std::string>& parameters, L bool match_hosts = false; snprintf(TheHost,MAXBUF,"%s@%s",user->ident.c_str(),user->host.c_str()); - snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(),user->GetIPString()); + snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(),user->GetIPString().c_str()); OperIndex::iterator i = ServerInstance->Config->oper_blocks.find(parameters[0]); if (i != ServerInstance->Config->oper_blocks.end()) diff --git a/src/modules/extra/m_ldapoper.cpp b/src/modules/extra/m_ldapoper.cpp index 53896878c..856e42dc3 100644 --- a/src/modules/extra/m_ldapoper.cpp +++ b/src/modules/extra/m_ldapoper.cpp @@ -97,7 +97,7 @@ class ModuleLDAPAuth : public Module std::string acceptedhosts = tag->getString("host"); std::string hostname = user->ident + "@" + user->host; - if (!OneOfMatches(hostname.c_str(), user->GetIPString(), acceptedhosts)) + if (!OneOfMatches(hostname.c_str(), user->GetIPString().c_str(), acceptedhosts)) return false; if (!LookupOper(opername, inputpass)) diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp index c65645bc9..4cd84c4cc 100644 --- a/src/modules/m_customtitle.cpp +++ b/src/modules/m_customtitle.cpp @@ -55,7 +55,7 @@ class CommandTitle : public Command char TheIP[MAXBUF]; snprintf(TheHost,MAXBUF,"%s@%s",user->ident.c_str(), user->host.c_str()); - snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(), user->GetIPString()); + snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(), user->GetIPString().c_str()); ConfigTagList tags = ServerInstance->Config->ConfTags("title"); for (ConfigIter i = tags.first; i != tags.second; ++i) diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 5e02dd0a5..f95bfd921 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -137,7 +137,7 @@ class DNSBLResolver : public Resolver { std::string timestr = ServerInstance->TimeString(kl->expiry); ServerInstance->SNO->WriteGlobalSno('x',"K:line added due to DNSBL match on *@%s to expire on %s: %s", - them->GetIPString(), timestr.c_str(), reason.c_str()); + them->GetIPString().c_str(), timestr.c_str(), reason.c_str()); ServerInstance->XLines->ApplyLines(); } else @@ -152,7 +152,7 @@ class DNSBLResolver : public Resolver { std::string timestr = ServerInstance->TimeString(gl->expiry); ServerInstance->SNO->WriteGlobalSno('x',"G:line added due to DNSBL match on *@%s to expire on %s: %s", - them->GetIPString(), timestr.c_str(), reason.c_str()); + them->GetIPString().c_str(), timestr.c_str(), reason.c_str()); ServerInstance->XLines->ApplyLines(); } else @@ -167,7 +167,7 @@ class DNSBLResolver : public Resolver { std::string timestr = ServerInstance->TimeString(zl->expiry); ServerInstance->SNO->WriteGlobalSno('x',"Z:line added due to DNSBL match on *@%s to expire on %s: %s", - them->GetIPString(), timestr.c_str(), reason.c_str()); + them->GetIPString().c_str(), timestr.c_str(), reason.c_str()); ServerInstance->XLines->ApplyLines(); } else @@ -405,7 +405,7 @@ class ModuleDNSBL : public Module return MOD_RES_PASSTHRU; return MOD_RES_DENY; } - + ModResult OnCheckReady(LocalUser *user) { if (countExt.get(user)) diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 5248ea897..2f43c92a1 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -256,7 +256,7 @@ void TreeSocket::SendUsers() u->second->host.c_str(), /* 3: Displayed Host */ u->second->dhost.c_str(), /* 4: Real host */ u->second->ident.c_str(), /* 5: Ident */ - u->second->GetIPString(), /* 6: IP string */ + u->second->GetIPString().c_str(), /* 6: IP string */ (unsigned long)u->second->signon, /* 7: Signon time for WHOWAS */ u->second->FormatModes(true), /* 8...n: Modes and params */ u->second->fullname.c_str()); /* size-1: GECOS */ diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index f33cb038d..3f73d8ee8 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -151,7 +151,7 @@ CmdResult CommandUID::Handle(const parameterlist ¶ms, User* serversrc) dosend = false; if (dosend) - ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s (%s) [%s]", _new->server.c_str(), _new->GetFullRealHost().c_str(), _new->GetIPString(), _new->fullname.c_str()); + ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s (%s) [%s]", _new->server.c_str(), _new->GetFullRealHost().c_str(), _new->GetIPString().c_str(), _new->fullname.c_str()); FOREACH_MOD(I_OnPostConnect,OnPostConnect(_new)); diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp index 03b626963..38bcb744a 100644 --- a/src/modules/m_sqloper.cpp +++ b/src/modules/m_sqloper.cpp @@ -119,7 +119,7 @@ class OpMeQuery : public SQLQuery hostname.append("@").append(user->host); - if (OneOfMatches(hostname.c_str(), user->GetIPString(), pattern.c_str())) + if (OneOfMatches(hostname.c_str(), user->GetIPString().c_str(), pattern.c_str())) { /* Opertype and host match, looks like this is it. */ diff --git a/src/user_resolver.cpp b/src/user_resolver.cpp index f18fc9a03..85181716a 100644 --- a/src/user_resolver.cpp +++ b/src/user_resolver.cpp @@ -112,7 +112,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, { if (!bound_user->dns_done) { - bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", bound_user->GetIPString()); + bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", bound_user->GetIPString().c_str()); bound_user->dns_done = true; } } @@ -121,7 +121,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, { if (!bound_user->dns_done) { - bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", bound_user->GetIPString()); + bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", bound_user->GetIPString().c_str()); bound_user->dns_done = true; } } @@ -136,7 +136,7 @@ void UserResolver::OnError(ResolverError e, const std::string &errormessage) LocalUser* bound_user = (LocalUser*)ServerInstance->FindUUID(uuid); if (bound_user) { - bound_user->WriteServ("NOTICE Auth :*** Could not resolve your hostname: %s; using your IP address (%s) instead.", errormessage.c_str(), bound_user->GetIPString()); + bound_user->WriteServ("NOTICE Auth :*** Could not resolve your hostname: %s; using your IP address (%s) instead.", errormessage.c_str(), bound_user->GetIPString().c_str()); bound_user->dns_done = true; bound_user->stored_host.resize(0); ServerInstance->stats->statsDnsBad++; diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 124c4d140..0088d1c7f 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -108,7 +108,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs if (!b->Type.empty() && !New->exempt) { /* user banned */ - ServerInstance->Logs->Log("BANCACHE", DEBUG, std::string("BanCache: Positive hit for ") + New->GetIPString()); + ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Positive hit for " + New->GetIPString()); if (!ServerInstance->Config->MoronBanner.empty()) New->WriteServ("NOTICE %s :*** %s", New->nick.c_str(), ServerInstance->Config->MoronBanner.c_str()); this->QuitUser(New, b->Reason); @@ -116,7 +116,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs } else { - ServerInstance->Logs->Log("BANCACHE", DEBUG, std::string("BanCache: Negative hit for ") + New->GetIPString()); + ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Negative hit for " + New->GetIPString()); } } else @@ -220,7 +220,7 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char if (!user->quietquit) { ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s (%s) [%s]", - user->GetFullRealHost().c_str(), user->GetIPString(), oper_reason.c_str()); + user->GetFullRealHost().c_str(), user->GetIPString().c_str(), oper_reason.c_str()); } } else @@ -228,7 +228,7 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char if ((!ServerInstance->SilentULine(user->server)) && (!user->quietquit)) { ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s (%s) [%s]", - user->server.c_str(), user->GetFullRealHost().c_str(), user->GetIPString(), oper_reason.c_str()); + user->server.c_str(), user->GetFullRealHost().c_str(), user->GetIPString().c_str(), oper_reason.c_str()); } } user->AddToWhoWas(); diff --git a/src/users.cpp b/src/users.cpp index cc331f5a1..cb07707cd 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -114,11 +114,10 @@ void LocalUser::StartDNSLookup() try { bool cached = false; - const char* sip = this->GetIPString(); UserResolver *res_reverse; QueryType resolvtype = this->client_sa.sa.sa_family == AF_INET6 ? DNS_QUERY_PTR6 : DNS_QUERY_PTR4; - res_reverse = new UserResolver(this, sip, resolvtype, cached); + res_reverse = new UserResolver(this, this->GetIPString(), resolvtype, cached); ServerInstance->AddResolver(res_reverse, cached); } @@ -268,7 +267,7 @@ const std::string& User::MakeHostIP() for(const char* n = ident.c_str(); *n; n++) *t++ = *n; *t++ = '@'; - for(const char* n = this->GetIPString(); *n; n++) + for(const char* n = this->GetIPString().c_str(); *n; n++) *t++ = *n; *t = 0; @@ -721,14 +720,14 @@ void LocalUser::CheckClass() { ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (local)"); if (a->maxconnwarn) - ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString()); + ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString().c_str()); return; } else if ((a->GetMaxGlobal()) && (ServerInstance->Users->GlobalCloneCount(this) > a->GetMaxGlobal())) { ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (global)"); if (a->maxconnwarn) - ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString()); + ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString().c_str()); return; } @@ -819,8 +818,8 @@ void LocalUser::FullConnect() FOREACH_MOD(I_OnPostConnect,OnPostConnect(this)); ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d (class %s): %s (%s) [%s]", - this->GetServerPort(), this->MyClass->name.c_str(), GetFullRealHost().c_str(), this->GetIPString(), this->fullname.c_str()); - ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Adding NEGATIVE hit for %s", this->GetIPString()); + this->GetServerPort(), this->MyClass->name.c_str(), GetFullRealHost().c_str(), this->GetIPString().c_str(), this->fullname.c_str()); + ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Adding NEGATIVE hit for " + this->GetIPString()); ServerInstance->BanCache->AddHit(this->GetIPString(), "", ""); // reset the flood penalty (which could have been raised due to things like auto +x) CommandFloodPenalty = 0; @@ -956,18 +955,18 @@ int LocalUser::GetServerPort() return 0; } -const char* User::GetIPString() +const std::string& User::GetIPString() { int port; if (cachedip.empty()) { irc::sockets::satoap(client_sa, cachedip, port); /* IP addresses starting with a : on irc are a Bad Thing (tm) */ - if (cachedip.c_str()[0] == ':') + if (cachedip[0] == ':') cachedip.insert(0,1,'0'); } - return cachedip.c_str(); + return cachedip; } irc::sockets::cidr_mask User::GetCIDRMask() diff --git a/src/whois.cpp b/src/whois.cpp index bec9c7ea9..efed45ce3 100644 --- a/src/whois.cpp +++ b/src/whois.cpp @@ -24,7 +24,7 @@ void InspIRCd::DoWhois(User* user, User* dest,unsigned long signon, unsigned lon this->SendWhoisLine(user, dest, 311, "%s %s %s %s * :%s",user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str(), dest->dhost.c_str(), dest->fullname.c_str()); if (user == dest || user->HasPrivPermission("users/auspex")) { - this->SendWhoisLine(user, dest, 378, "%s %s :is connecting from %s@%s %s", user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str(), dest->host.c_str(), dest->GetIPString()); + this->SendWhoisLine(user, dest, 378, "%s %s :is connecting from %s@%s %s", user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str(), dest->host.c_str(), dest->GetIPString().c_str()); } std::string cl = dest->ChannelList(user, false); |