]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Make better use of User::GetFullRealHost()
authorattilamolnar <attilamolnar@hush.com>
Sun, 21 Oct 2012 13:10:44 +0000 (15:10 +0200)
committerattilamolnar <attilamolnar@hush.com>
Sun, 21 Oct 2012 13:10:44 +0000 (15:10 +0200)
src/commands/cmd_die.cpp
src/commands/cmd_kill.cpp
src/commands/cmd_oper.cpp
src/commands/cmd_restart.cpp
src/modules/extra/m_ldapauth.cpp
src/modules/m_operlog.cpp
src/modules/m_spanningtree/uid.cpp
src/modules/m_sqlauth.cpp
src/usermanager.cpp
src/users.cpp

index 9b0126e3e975a7afbb542a634189592b62405106..1d6640213c445feab12b9429c56be25b4cb7e4fc 100644 (file)
@@ -49,7 +49,7 @@ CmdResult CommandDie::Handle (const std::vector<std::string>& parameters, User *
        if (!ServerInstance->PassCompare(user, ServerInstance->Config->diepass, parameters[0].c_str(), ServerInstance->Config->powerhash))
        {
                {
-                       std::string diebuf = "*** DIE command from " + user->nick + "!" + user->ident + "@" + user->dhost + ". Terminating.";
+                       std::string diebuf = "*** DIE command from " + user->GetFullHost() + ". Terminating.";
                        ServerInstance->Logs->Log("COMMAND",SPARSE, diebuf);
                        ServerInstance->SendError(diebuf);
                }
@@ -58,8 +58,8 @@ CmdResult CommandDie::Handle (const std::vector<std::string>& parameters, User *
        }
        else
        {
-               ServerInstance->Logs->Log("COMMAND",SPARSE, "Failed /DIE command from %s!%s@%s", user->nick.c_str(), user->ident.c_str(), user->host.c_str());
-               ServerInstance->SNO->WriteGlobalSno('a', "Failed DIE Command from %s!%s@%s.",user->nick.c_str(),user->ident.c_str(),user->host.c_str());
+               ServerInstance->Logs->Log("COMMAND",SPARSE, "Failed /DIE command from %s", user->GetFullRealHost().c_str());
+               ServerInstance->SNO->WriteGlobalSno('a', "Failed DIE Command from %s.", user->GetFullRealHost().c_str());
                return CMD_FAILURE;
        }
        return CMD_SUCCESS;
index 99ead1b7d7bfd61f21937302f6d3e006bb197f15..463c7af3837e353754f4243d9f01bf505e858d3a 100644 (file)
@@ -111,7 +111,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User
                if (!IS_LOCAL(u))
                {
                        // remote kill
-                       ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s!%s@%s (%s)", user->nick.c_str(), u->nick.c_str(), u->ident.c_str(), u->host.c_str(), parameters[1].c_str());
+                       ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s (%s)", user->nick.c_str(), u->GetFullRealHost().c_str(), parameters[1].c_str());
                        FOREACH_MOD(I_OnRemoteKill, OnRemoteKill(user, u, killreason, killreason));
                }
                else
@@ -121,7 +121,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User
                         * XXX - this isn't entirely correct, servers A - B - C, oper on A, client on C. Oper kills client, A and B will get remote kill
                         * snotices, C will get a local kill snotice. this isn't accurate, and needs fixing at some stage. -- w00t
                         */
-                       ServerInstance->SNO->WriteToSnoMask('k',"Local Kill by %s: %s!%s@%s (%s)", user->nick.c_str(), u->nick.c_str(), u->ident.c_str(), u->host.c_str(), parameters[1].c_str());
+                       ServerInstance->SNO->WriteToSnoMask('k',"Local Kill by %s: %s (%s)", user->nick.c_str(), u->GetFullRealHost().c_str(), parameters[1].c_str());
                        ServerInstance->Logs->Log("KILL",DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick.c_str(), ServerInstance->Config->ServerName.c_str(), user->dhost.c_str(), user->nick.c_str(), parameters[1].c_str());
                        /* Bug #419, make sure this message can only occur once even in the case of multiple KILL messages crossing the network, and change to show
                         * hidekillsserver as source if possible
index e3f79d3474db3524f55056710bc769d4d1e83356..1a5e7e1783a4331911d89196b3353722b151ca53 100644 (file)
@@ -84,7 +84,6 @@ CmdResult CommandOper::HandleLocal(const std::vector<std::string>& parameters, L
                        return CMD_SUCCESS;
                }
        }
-       char broadcast[MAXBUF];
 
        std::string fields;
        if (!match_login)
@@ -98,10 +97,8 @@ CmdResult CommandOper::HandleLocal(const std::vector<std::string>& parameters, L
        user->WriteNumeric(491, "%s :Invalid oper credentials",user->nick.c_str());
        user->CommandFloodPenalty += 10000;
 
-       snprintf(broadcast, MAXBUF, "WARNING! Failed oper attempt by %s!%s@%s using login '%s': The following fields do not match: %s", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), parameters[0].c_str(), fields.c_str());
-       ServerInstance->SNO->WriteGlobalSno('o',std::string(broadcast));
-
-       ServerInstance->Logs->Log("OPER",DEFAULT,"OPER: Failed oper attempt by %s!%s@%s using login '%s': The following fields did not match: %s", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), parameters[0].c_str(), fields.c_str());
+       ServerInstance->SNO->WriteGlobalSno('o', "WARNING! Failed oper attempt by %s using login '%s': The following fields do not match: %s", user->GetFullRealHost().c_str(), parameters[0].c_str(), fields.c_str());
+       ServerInstance->Logs->Log("OPER",DEFAULT,"OPER: Failed oper attempt by %s using login '%s': The following fields did not match: %s", user->GetFullRealHost().c_str(), parameters[0].c_str(), fields.c_str());
        return CMD_FAILURE;
 }
 
index b94dbaac927fd2a1d149d0719718b3dc6a8aff4f..dc5507548ac4c2564049e4933233b89161eb158c 100644 (file)
@@ -42,7 +42,7 @@ CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, Us
        ServerInstance->Logs->Log("COMMAND",DEFAULT,"Restart: %s",user->nick.c_str());
        if (!ServerInstance->PassCompare(user, ServerInstance->Config->restartpass, parameters[0].c_str(), ServerInstance->Config->powerhash))
        {
-               ServerInstance->SNO->WriteGlobalSno('a', "RESTART command from %s!%s@%s, restarting server.", user->nick.c_str(), user->ident.c_str(), user->host.c_str());
+               ServerInstance->SNO->WriteGlobalSno('a', "RESTART command from %s, restarting server.", user->GetFullRealHost().c_str());
 
                ServerInstance->SendError("Server restarting.");
                execv(ServerInstance->Config->cmdline.argv[0], ServerInstance->Config->cmdline.argv);
@@ -51,7 +51,7 @@ CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, Us
        }
        else
        {
-               ServerInstance->SNO->WriteGlobalSno('a', "Failed RESTART Command from %s!%s@%s.", user->nick.c_str(), user->ident.c_str(), user->host.c_str());
+               ServerInstance->SNO->WriteGlobalSno('a', "Failed RESTART Command from %s.", user->GetFullRealHost().c_str());
        }
        return CMD_FAILURE;
 }
index f404471ea07b4816d904b36616deda6d9841b4a5..f51b41e0b287fd4e41f4236da852d98d263e5099 100644 (file)
@@ -181,7 +181,7 @@ public:
                if (user->password.empty())
                {
                        if (verbose)
-                               ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s!%s@%s (No password provided)", user->nick.c_str(), user->ident.c_str(), user->host.c_str());
+                               ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s (No password provided)", user->GetFullRealHost().c_str());
                        return false;
                }
 
@@ -205,7 +205,7 @@ public:
                        if (res != LDAP_SUCCESS)
                        {
                                if (verbose)
-                                       ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s!%s@%s (LDAP bind failed: %s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), ldap_err2string(res));
+                                       ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s (LDAP bind failed: %s)", user->GetFullRealHost().c_str(), ldap_err2string(res));
                                ldap_unbind_ext(conn, NULL, NULL);
                                conn = NULL;
                                return false;
@@ -235,21 +235,21 @@ public:
                        if (res != LDAP_SUCCESS)
                        {
                                if (verbose)
-                                       ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s!%s@%s (LDAP search failed: %s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), ldap_err2string(res));
+                                       ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s (LDAP search failed: %s)", user->GetFullRealHost().c_str(), ldap_err2string(res));
                                return false;
                        }
                }
                if (ldap_count_entries(conn, msg) > 1)
                {
                        if (verbose)
-                               ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s!%s@%s (LDAP search returned more than one result: %s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), ldap_err2string(res));
+                               ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s (LDAP search returned more than one result: %s)", user->GetFullRealHost().c_str(), ldap_err2string(res));
                        ldap_msgfree(msg);
                        return false;
                }
                if ((entry = ldap_first_entry(conn, msg)) == NULL)
                {
                        if (verbose)
-                               ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s!%s@%s (LDAP search returned no results: %s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), ldap_err2string(res));
+                               ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s (LDAP search returned no results: %s)", user->GetFullRealHost().c_str(), ldap_err2string(res));
                        ldap_msgfree(msg);
                        return false;
                }
@@ -258,7 +258,7 @@ public:
                if ((res = ldap_sasl_bind_s(conn, ldap_get_dn(conn, entry), LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL)) != LDAP_SUCCESS)
                {
                        if (verbose)
-                               ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s!%s@%s (%s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), ldap_err2string(res));
+                               ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s (%s)", user->GetFullRealHost().c_str(), ldap_err2string(res));
                        ldap_msgfree(msg);
                        return false;
                }
index d8006d9d5267d1fa8a68a03b52e9b9ad4e98028a..1913ceeee35d620baa205560efd52518a9fcee34 100644 (file)
@@ -58,7 +58,7 @@ class ModuleOperLog : public Module
                                std::string line;
                                if (!parameters.empty())
                                        line = irc::stringjoiner(" ", parameters, 0, parameters.size() - 1).GetJoined();
-                               ServerInstance->Logs->Log("m_operlog",DEFAULT,"OPERLOG: [%s!%s@%s] %s %s",user->nick.c_str(), user->ident.c_str(), user->host.c_str(), command.c_str(), line.c_str());
+                               ServerInstance->Logs->Log("m_operlog",DEFAULT,"OPERLOG: [%s] %s %s", user->GetFullRealHost().c_str(), command.c_str(), line.c_str());
                        }
                }
 
index 7dd2cad1df9a081d1d233ca46a49f631bfd01403..4a73eb80c2d69c1d4a070c4d1014401d3808180f 100644 (file)
@@ -154,7 +154,7 @@ CmdResult CommandUID::Handle(const parameterlist &params, User* serversrc)
                dosend = false;
 
        if (dosend)
-               ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s!%s@%s (%s) [%s]", _new->server.c_str(), _new->nick.c_str(), _new->ident.c_str(), _new->host.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(), _new->fullname.c_str());
 
        FOREACH_MOD(I_OnPostConnect,OnPostConnect(_new));
 
index 417d5a4b56499ac277bcd80b97dfa16f7f74a82f..c1da776d658f29283af3a9c0ae2b1a151b86de3c 100644 (file)
@@ -52,7 +52,7 @@ class AuthQuery : public SQLQuery
                else
                {
                        if (verbose)
-                               ServerInstance->SNO->WriteGlobalSno('a', "Forbidden connection from %s!%s@%s (SQL query returned no matches)", user->nick.c_str(), user->ident.c_str(), user->host.c_str());
+                               ServerInstance->SNO->WriteGlobalSno('a', "Forbidden connection from %s (SQL query returned no matches)", user->GetFullRealHost().c_str());
                        pendingExt.set(user, AUTH_STATE_FAIL);
                }
        }
@@ -64,7 +64,7 @@ class AuthQuery : public SQLQuery
                        return;
                pendingExt.set(user, AUTH_STATE_FAIL);
                if (verbose)
-                       ServerInstance->SNO->WriteGlobalSno('a', "Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), error.Str());
+                       ServerInstance->SNO->WriteGlobalSno('a', "Forbidden connection from %s (SQL query failed: %s)", user->GetFullRealHost().c_str(), error.Str());
        }
 };
 
@@ -120,8 +120,7 @@ class ModuleSQLAuth : public Module
 
                if (!SQL)
                {
-                       ServerInstance->SNO->WriteGlobalSno('a', "Forbiding connection from %s!%s@%s (SQL database not present)",
-                               user->nick.c_str(), user->ident.c_str(), user->host.c_str());
+                       ServerInstance->SNO->WriteGlobalSno('a', "Forbiding connection from %s (SQL database not present)", user->GetFullRealHost().c_str());
                        ServerInstance->Users->QuitUser(user, killreason);
                        return MOD_RES_PASSTHRU;
                }
index d65f47128aa2412141a0797873340b212746657a..3742c855db5b1312d14983c112b448b5765b34c1 100644 (file)
@@ -215,16 +215,16 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char
                {
                        if (!user->quietquit)
                        {
-                               ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s (%s) [%s]",
-                                       user->nick.c_str(), user->ident.c_str(), user->host.c_str(), user->GetIPString(), oper_reason.c_str());
+                               ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s (%s) [%s]",
+                                       user->GetFullRealHost().c_str(), user->GetIPString(), oper_reason.c_str());
                        }
                }
                else
                {
                        if ((!ServerInstance->SilentULine(user->server)) && (!user->quietquit))
                        {
-                               ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s (%s) [%s]",
-                                       user->server.c_str(), user->nick.c_str(), user->ident.c_str(), user->host.c_str(), user->GetIPString(), oper_reason.c_str());
+                               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->AddToWhoWas();
index cce5c4514dbd9b107020c78d1cf8100ddb01e6cf..aebc66bfc48472110fb375c1dbe5a0fa1950ec28 100644 (file)
@@ -604,7 +604,7 @@ void User::Oper(OperInfo* info)
                nick.c_str(), ident.c_str(), host.c_str(), oper->NameStr(), opername.c_str());
        this->WriteNumeric(381, "%s :You are now %s %s", nick.c_str(), strchr("aeiouAEIOU", oper->name[0]) ? "an" : "a", oper->NameStr());
 
-       ServerInstance->Logs->Log("OPER", DEFAULT, "%s!%s@%s opered as type: %s", this->nick.c_str(), this->ident.c_str(), this->host.c_str(), oper->NameStr());
+       ServerInstance->Logs->Log("OPER", DEFAULT, "%s opered as type: %s", GetFullRealHost().c_str(), oper->NameStr());
        ServerInstance->Users->all_opers.push_back(this);
 
        // Expand permissions from config for faster lookup
@@ -792,7 +792,7 @@ void LocalUser::FullConnect()
 
        if (ServerInstance->Config->WelcomeNotice)
                this->WriteServ("NOTICE Auth :Welcome to \002%s\002!",ServerInstance->Config->Network.c_str());
-       this->WriteNumeric(RPL_WELCOME, "%s :Welcome to the %s IRC Network %s!%s@%s",this->nick.c_str(), ServerInstance->Config->Network.c_str(), this->nick.c_str(), this->ident.c_str(), this->host.c_str());
+       this->WriteNumeric(RPL_WELCOME, "%s :Welcome to the %s IRC Network %s",this->nick.c_str(), ServerInstance->Config->Network.c_str(), GetFullRealHost().c_str());
        this->WriteNumeric(RPL_YOURHOSTIS, "%s :Your host is %s, running version %s",this->nick.c_str(),ServerInstance->Config->ServerName.c_str(),BRANCH);
        this->WriteNumeric(RPL_SERVERCREATED, "%s :This server was created %s %s", this->nick.c_str(), __TIME__, __DATE__);
 
@@ -835,8 +835,8 @@ void LocalUser::FullConnect()
 
        FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
 
-       ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d (class %s): %s!%s@%s (%s) [%s]",
-               this->GetServerPort(), this->MyClass->name.c_str(), this->nick.c_str(), this->ident.c_str(), this->host.c_str(), this->GetIPString(), this->fullname.c_str());
+       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());
        ServerInstance->BanCache->AddHit(this->GetIPString(), "", "");
        // reset the flood penalty (which could have been raised due to things like auto +x)
@@ -891,8 +891,8 @@ bool User::ChangeNick(const std::string& newnick, bool force)
                        {
                                if (this->registered == REG_ALL)
                                {
-                                       ServerInstance->SNO->WriteGlobalSno('a', "Q-Lined nickname %s from %s!%s@%s: %s",
-                                               newnick.c_str(), this->nick.c_str(), this->ident.c_str(), this->host.c_str(), mq->reason.c_str());
+                                       ServerInstance->SNO->WriteGlobalSno('a', "Q-Lined nickname %s from %s: %s",
+                                               newnick.c_str(), GetFullRealHost().c_str(), mq->reason.c_str());
                                }
                                this->WriteNumeric(432, "%s %s :Invalid nickname: %s",this->nick.c_str(), newnick.c_str(), mq->reason.c_str());
                                return false;