1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: A module overriding /list, and making it safe - stop those sendq problems. */
18 class ModuleSecureList : public Module
21 std::vector<std::string> allowlist;
24 ModuleSecureList(InspIRCd* Me) : Module(Me)
27 Implementation eventlist[] = { I_OnRehash, I_OnPreCommand, I_On005Numeric };
28 ServerInstance->Modules->Attach(eventlist, this, 3);
31 virtual ~ModuleSecureList()
35 virtual Version GetVersion()
37 return Version("$Id$",VF_VENDOR,API_VERSION);
40 void OnRehash(User* user, const std::string ¶meter)
42 ConfigReader* MyConf = new ConfigReader(ServerInstance);
45 for (int i = 0; i < MyConf->Enumerate("securehost"); i++)
46 allowlist.push_back(MyConf->ReadValue("securehost", "exception", i));
48 WaitTime = MyConf->ReadInteger("securelist", "waittime", "60", 0, true);
55 * Intercept the LIST command.
57 virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line)
59 /* If the command doesnt appear to be valid, we dont want to mess with it. */
63 if ((command == "LIST") && (ServerInstance->Time() < (user->signon+WaitTime)) && (!IS_OPER(user)))
65 /* Normally wouldnt be allowed here, are they exempt? */
66 for (std::vector<std::string>::iterator x = allowlist.begin(); x != allowlist.end(); x++)
67 if (InspIRCd::Match(user->MakeHost(), *x, ascii_case_insensitive_map))
70 /* Not exempt, BOOK EM DANNO! */
71 user->WriteServ("NOTICE %s :*** You cannot list within the first %lu seconds of connecting. Please try again later.",user->nick.c_str(), (unsigned long) WaitTime);
72 /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
73 * receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
75 user->WriteNumeric(321, "%s Channel :Users Name",user->nick.c_str());
76 user->WriteNumeric(323, "%s :End of channel list.",user->nick.c_str());
82 virtual void On005Numeric(std::string &output)
84 output.append(" SECURELIST");
89 Module* safelist = ServerInstance->Modules->Find("m_safelist.so");
90 ServerInstance->Modules->SetPriority(this, I_OnPreCommand, PRIO_BEFORE, &safelist);
95 MODULE_INIT(ModuleSecureList)