1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/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;
26 Implementation eventlist[] = { I_OnRehash, I_OnPreCommand, I_On005Numeric };
27 ServerInstance->Modules->Attach(eventlist, this, 3);
30 virtual ~ModuleSecureList()
34 virtual Version GetVersion()
36 return Version("A module overriding /list, and making it safe - stop those sendq problems.",VF_VENDOR,API_VERSION);
39 void OnRehash(User* user)
41 ConfigReader* MyConf = new ConfigReader;
44 for (int i = 0; i < MyConf->Enumerate("securehost"); i++)
45 allowlist.push_back(MyConf->ReadValue("securehost", "exception", i));
47 WaitTime = MyConf->ReadInteger("securelist", "waittime", "60", 0, true);
54 * Intercept the LIST command.
56 virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line)
58 /* If the command doesnt appear to be valid, we dont want to mess with it. */
60 return MOD_RES_PASSTHRU;
62 if ((command == "LIST") && (ServerInstance->Time() < (user->signon+WaitTime)) && (!IS_OPER(user)))
64 /* Normally wouldnt be allowed here, are they exempt? */
65 for (std::vector<std::string>::iterator x = allowlist.begin(); x != allowlist.end(); x++)
66 if (InspIRCd::Match(user->MakeHost(), *x, ascii_case_insensitive_map))
67 return MOD_RES_PASSTHRU;
69 /* Not exempt, BOOK EM DANNO! */
70 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);
71 /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
72 * receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
74 user->WriteNumeric(321, "%s Channel :Users Name",user->nick.c_str());
75 user->WriteNumeric(323, "%s :End of channel list.",user->nick.c_str());
78 return MOD_RES_PASSTHRU;
81 virtual void On005Numeric(std::string &output)
83 output.append(" SECURELIST");
87 MODULE_INIT(ModuleSecureList)