From 5e2eaff8b76f4ecf395b78484fac6b93f1afefe7 Mon Sep 17 00:00:00 2001 From: w00t Date: Sun, 31 Aug 2008 00:30:04 +0000 Subject: [PATCH] Add as part of m_ident, original suggestion from various people, including satmd. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10357 e03df62e-2008-0410-955e-edbf42e46eb7 --- conf/modules.conf.example | 3 +++ src/modules/m_ident.cpp | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/conf/modules.conf.example b/conf/modules.conf.example index 7d89163ba..f1173decd 100644 --- a/conf/modules.conf.example +++ b/conf/modules.conf.example @@ -748,6 +748,9 @@ #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Ident: Provides RFC 1413 ident lookup support +# When this module is loaded tags may have an optional +# useident="yes|no" boolean value, determining whether or not to lookup +# ident on users matching that connect tag. # # #-#-#-#-#-#-#-#-#-#-#-#- IDENT CONFIGURATION -#-#-#-#-#-#-#-#-#-#-# diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 835250607..ba766319e 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -77,12 +77,10 @@ class IdentRequestSocket : public EventHandler { private: - - User *user; /* User we are attached to */ - InspIRCd* ServerInstance; /* Server instance */ - bool done; /* True if lookup is finished */ - std::string result; /* Holds the ident string if done */ - + User *user; /* User we are attached to */ + InspIRCd* ServerInstance; /* Server instance */ + bool done; /* True if lookup is finished */ + std::string result; /* Holds the ident string if done */ public: IdentRequestSocket(InspIRCd *Server, User* u, const std::string &bindip) : user(u), ServerInstance(Server), result(u->ident) @@ -339,32 +337,51 @@ class ModuleIdent : public Module { private: int RequestTimeout; + ConfigReader *Conf; public: - ModuleIdent(InspIRCd *Me) - : Module(Me) + ModuleIdent(InspIRCd *Me) : Module(Me) { + Conf = new ConfigReader(ServerInstance); OnRehash(NULL, ""); Implementation eventlist[] = { I_OnRehash, I_OnUserRegister, I_OnCheckReady, I_OnCleanup, I_OnUserDisconnect }; ServerInstance->Modules->Attach(eventlist, this, 5); } + ~ModuleIdent() + { + delete Conf; + } + virtual Version GetVersion() { return Version("$Id$", VF_VENDOR, API_VERSION); } - virtual void OnRehash(User *user, const std::string ¶m) { - ConfigReader MyConf(ServerInstance); + delete Conf; + Conf = new ConfigReader(ServerInstance); - RequestTimeout = MyConf.ReadInteger("ident", "timeout", 0, true); + RequestTimeout = Conf->ReadInteger("ident", "timeout", 0, true); if (!RequestTimeout) RequestTimeout = 5; } virtual int OnUserRegister(User *user) { + for (int j = 0; j < Conf->Enumerate("connect"); j++) + { + std::string hostn = Conf->ReadValue("connect","allow",j); + /* XXX: Fixme: does not respect port, limit, etc */ + if ((InspIRCd::MatchCIDR(user->GetIPString(),hostn)) || (InspIRCd::Match(user->host,hostn))) + { + bool useident = Conf->ReadFlag("connect", "useident", j); + + if (!useident) + return 0; + } + } + /* User::ident is currently the username field from USER; with m_ident loaded, that * should be preceded by a ~. The field is actually IdentMax+2 characters wide. */ if (user->ident.length() > ServerInstance->Config->Limits.IdentMax + 1) -- 2.39.5