]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Change User::GetIPString() to return const std::string&
authorattilamolnar <attilamolnar@hush.com>
Sun, 31 Mar 2013 23:27:02 +0000 (01:27 +0200)
committerattilamolnar <attilamolnar@hush.com>
Sun, 31 Mar 2013 23:27:02 +0000 (01:27 +0200)
12 files changed:
include/users.h
src/commands/cmd_oper.cpp
src/modules/extra/m_ldapoper.cpp
src/modules/m_customtitle.cpp
src/modules/m_dnsbl.cpp
src/modules/m_spanningtree/netburst.cpp
src/modules/m_spanningtree/uid.cpp
src/modules/m_sqloper.cpp
src/user_resolver.cpp
src/usermanager.cpp
src/users.cpp
src/whois.cpp

index 88abfbcd1c6dc8c682fa3a2597f7c2e15891f148..c79bf7cb8e74405ce083f3863da7610b2fef830c 100644 (file)
@@ -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
         */
index 1a5e7e1783a4331911d89196b3353722b151ca53..4492a385aa8919fe7a1584f4c3ad52409d442e01 100644 (file)
@@ -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())
index 53896878c5e1b255b7bf085b493091d92ba515d5..856e42dc36648295b9f8bbae42d989cbf5f1ee27 100644 (file)
@@ -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))
index c65645bc9209426d0382f3e81cfdc2725daca441..4cd84c4cce7de06a0309fdf1e7d94705363642ec 100644 (file)
@@ -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)
index 5e02dd0a5dadc5cea64d99375285f24a5a8bb5e6..f95bfd92139e956bed3da32e954f823380b71bab 100644 (file)
@@ -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))
index 5248ea897e3a33dcc4ba5f4be58ba062cd2d2d68..2f43c92a1021e991dbc539ecf93a3a294c88c814 100644 (file)
@@ -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 */
index f33cb038d772f8554f1289f943b7e1d53e53743c..3f73d8ee8928bcc760341620ff8d3477379e0fba 100644 (file)
@@ -151,7 +151,7 @@ CmdResult CommandUID::Handle(const parameterlist &params, 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));
 
index 03b6269630c04833431bd514c07cd328904c50b4..38bcb744a2a4718a92f8a557badffa08265a197b 100644 (file)
@@ -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. */
 
index f18fc9a0385a29604ec5586bd3d276e7a8de2d8f..85181716a33793884fc243fa5b82cb3d1b3a0514 100644 (file)
@@ -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++;
index 124c4d140ece1f5d5e3a3640c62cb9200028118b..0088d1c7f3b8cea1d3e3df7432ef5f8c4be7dd82 100644 (file)
@@ -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();
index cc331f5a14891e522ee79d8553a55b8992f43d80..cb07707cd04eb0cfc29797103c72ea0abbfe5c04 100644 (file)
@@ -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()
index bec9c7ea9e0e44824e09eacbf0d303fda43280cd..efed45ce3b8cddecf33ab6ab3f6e254d36f46648 100644 (file)
@@ -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);