X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_passforward.cpp;h=c04b306b1b8482ed0155cd801d8b85a11e932f59;hb=aa19c8fc021ce1cc704434a2c5a19e1517132c79;hp=a1993c25a137eb814d1c48f5ba6f5cbcd8eb4ffe;hpb=ae61237cdc5e4d94681fc801d3076d202825ff45;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_passforward.cpp b/src/modules/m_passforward.cpp index a1993c25a..c04b306b1 100644 --- a/src/modules/m_passforward.cpp +++ b/src/modules/m_passforward.cpp @@ -1,16 +1,24 @@ -/* +------------------------------------+ - * | 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) 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 . */ + +/* $ModDesc: Forwards a password users can send on connect (for example for NickServ identification). */ + #include "inspircd.h" class ModulePassForward : public Module @@ -19,11 +27,11 @@ class ModulePassForward : public Module std::string nickrequired, forwardmsg, forwardcmd; public: - ModulePassForward() + void init() { OnRehash(NULL); Implementation eventlist[] = { I_OnPostConnect, I_OnRehash }; - ServerInstance->Modules->Attach(eventlist, this, 2); + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } Version GetVersion() @@ -33,13 +41,13 @@ class ModulePassForward : public Module void OnRehash(User* user) { - ConfigReader Conf; - nickrequired = Conf.ReadValue("passforward", "nick", "NickServ", 0); - forwardmsg = Conf.ReadValue("passforward", "forwardmsg", "NOTICE $nick :*** Forwarding PASS to $nickrequired", 0); - forwardcmd = Conf.ReadValue("passforward", "cmd", "PRIVMSG $nickrequired :IDENTIFY $pass", 0); + ConfigTag* tag = ServerInstance->Config->ConfValue("passforward"); + nickrequired = tag->getString("nick", "NickServ"); + forwardmsg = tag->getString("forwardmsg", "NOTICE $nick :*** Forwarding PASS to $nickrequired"); + forwardcmd = tag->getString("cmd", "PRIVMSG $nickrequired :IDENTIFY $pass"); } - void FormatStr(std::string& result, const std::string& format, const std::string &nick, const std::string &pass) + void FormatStr(std::string& result, const std::string& format, const LocalUser* user) { for (unsigned int i = 0; i < format.length(); i++) { @@ -53,12 +61,17 @@ class ModulePassForward : public Module } else if (format.substr(i, 5) == "$nick") { - result.append(nick); + result.append(user->nick); + i += 4; + } + else if (format.substr(i, 5) == "$user") + { + result.append(user->ident); i += 4; } else if (format.substr(i,5) == "$pass") { - result.append(pass); + result.append(user->password); i += 4; } else @@ -78,20 +91,19 @@ class ModulePassForward : public Module if (!nickrequired.empty()) { /* Check if nick exists and its server is ulined */ - User* u = ServerInstance->FindNick(nickrequired.c_str()); + User* u = ServerInstance->FindNick(nickrequired); if (!u || !ServerInstance->ULine(u->server)) return; } std::string tmp; - FormatStr(tmp,forwardmsg, user->nick, user->password); + FormatStr(tmp,forwardmsg, user); user->WriteServ(tmp); tmp.clear(); - FormatStr(tmp,forwardcmd, user->nick, user->password); + FormatStr(tmp,forwardcmd, user); ServerInstance->Parser->ProcessBuffer(tmp,user); } }; MODULE_INIT(ModulePassForward) -