1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 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)
29 virtual ~ModuleSecureList()
33 virtual Version GetVersion()
35 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
38 void OnRehash(userrec* user, const std::string ¶meter)
40 ConfigReader* MyConf = new ConfigReader(ServerInstance);
43 for (int i = 0; i < MyConf->Enumerate("securehost"); i++)
44 allowlist.push_back(MyConf->ReadValue("securehost", "exception", i));
46 WaitTime = MyConf->ReadInteger("securelist", "waittime", "60", 0, true);
50 void Implements(char* List)
52 List[I_OnRehash] = List[I_OnPreCommand] = List[I_On005Numeric] = 1;
57 * Intercept the LIST command.
59 virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
61 /* If the command doesnt appear to be valid, we dont want to mess with it. */
65 if ((command == "LIST") && (ServerInstance->Time() < (user->signon+WaitTime)) && (!IS_OPER(user)))
67 /* Normally wouldnt be allowed here, are they exempt? */
68 for (std::vector<std::string>::iterator x = allowlist.begin(); x != allowlist.end(); x++)
69 if (ServerInstance->MatchText(user->MakeHost(), *x))
72 /* Not exempt, BOOK EM DANNO! */
73 user->WriteServ("NOTICE %s :*** You cannot list within the first %d seconds of connecting. Please try again later.",user->nick, WaitTime);
74 /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
75 * receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
77 user->WriteServ("321 %s Channel :Users Name",user->nick);
78 user->WriteServ("323 %s :End of channel list.",user->nick);
84 virtual void On005Numeric(std::string &output)
86 output.append(" SECURELIST");
89 virtual Priority Prioritize()
91 return (Priority)ServerInstance->Modules->PriorityBefore("m_safelist.so");
96 MODULE_INIT(ModuleSecureList)