X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sqlauth.cpp;h=94f2823c9b197ee14bb35f467b7ecb44fe0ba5e4;hb=909cba9b756179bfa16d985916db1084cb7b4a9d;hp=d87c66de980210773340e6395ba30a0ed8a1c98c;hpb=63732f37cba3d493954154c0f2440ddc88d7f207;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sqlauth.cpp b/src/modules/m_sqlauth.cpp index d87c66de9..94f2823c9 100644 --- a/src/modules/m_sqlauth.cpp +++ b/src/modules/m_sqlauth.cpp @@ -1,21 +1,25 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009-2010 Daniel De Graaf * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#include "inspircd.h" -#include "sql.h" -#include "hash.h" -/* $ModDesc: Allow/Deny connections based upon an arbitary SQL table */ +#include "inspircd.h" +#include "modules/sql.h" +#include "modules/hash.h" enum AuthState { AUTH_STATE_NONE = 0, @@ -33,8 +37,8 @@ class AuthQuery : public SQLQuery : SQLQuery(me), uid(u), pendingExt(e), verbose(v) { } - - void OnResult(SQLResult& res) + + void OnResult(SQLResult& res) CXX11_OVERRIDE { User* user = ServerInstance->FindNick(uid); if (!user) @@ -46,19 +50,19 @@ 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); } } - void OnError(SQLerror& error) + void OnError(SQLerror& error) CXX11_OVERRIDE { User* user = ServerInstance->FindNick(uid); if (!user) 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()); } }; @@ -77,15 +81,15 @@ class ModuleSQLAuth : public Module { } - void init() + void init() CXX11_OVERRIDE { ServerInstance->Modules->AddService(pendingExt); OnRehash(NULL); - Implementation eventlist[] = { I_OnUserDisconnect, I_OnCheckReady, I_OnRehash, I_OnUserRegister }; - ServerInstance->Modules->Attach(eventlist, this, 4); + Implementation eventlist[] = { I_OnCheckReady, I_OnRehash, I_OnUserRegister }; + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } - void OnRehash(User* user) + void OnRehash(User* user) CXX11_OVERRIDE { ConfigTag* conf = ServerInstance->Config->ConfValue("sqlauth"); std::string dbid = conf->getString("dbid"); @@ -99,7 +103,7 @@ class ModuleSQLAuth : public Module verbose = conf->getBool("verbose"); } - ModResult OnUserRegister(LocalUser* user) + ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE { // Note this is their initial (unresolved) connect block ConfigTag* tag = user->MyClass->config; @@ -114,8 +118,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; } @@ -139,7 +142,7 @@ class ModuleSQLAuth : public Module return MOD_RES_PASSTHRU; } - ModResult OnCheckReady(LocalUser* user) + ModResult OnCheckReady(LocalUser* user) CXX11_OVERRIDE { switch (pendingExt.get(user)) { @@ -154,9 +157,9 @@ class ModuleSQLAuth : public Module return MOD_RES_PASSTHRU; } - Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { - return Version("Allow/Deny connections based upon an arbitary SQL table", VF_VENDOR); + return Version("Allow/Deny connections based upon an arbitrary SQL table", VF_VENDOR); } };