1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 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);
39 void OnRehash(User* user)
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);
53 * Intercept the LIST command.
55 virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line)
57 /* If the command doesnt appear to be valid, we dont want to mess with it. */
59 return MOD_RES_PASSTHRU;
61 if ((command == "LIST") && (ServerInstance->Time() < (user->signon+WaitTime)) && (!IS_OPER(user)))
63 /* Normally wouldnt be allowed here, are they exempt? */
64 for (std::vector<std::string>::iterator x = allowlist.begin(); x != allowlist.end(); x++)
65 if (InspIRCd::Match(user->MakeHost(), *x, ascii_case_insensitive_map))
66 return MOD_RES_PASSTHRU;
68 /* Not exempt, BOOK EM DANNO! */
69 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);
70 /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
71 * receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
73 user->WriteNumeric(321, "%s Channel :Users Name",user->nick.c_str());
74 user->WriteNumeric(323, "%s :End of channel list.",user->nick.c_str());
77 return MOD_RES_PASSTHRU;
80 virtual void On005Numeric(std::string &output)
82 output.append(" SECURELIST");
86 MODULE_INIT(ModuleSecureList)