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 * ---------------------------------------------------
21 /* $ModDesc: A module overriding /list, and making it safe - stop those sendq problems. */
23 class ModuleSecureList : public Module
26 std::vector<std::string> allowlist;
29 ModuleSecureList(InspIRCd* Me) : Module::Module(Me)
34 virtual ~ModuleSecureList()
38 virtual Version GetVersion()
40 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
43 void OnRehash(userrec* user, const std::string ¶meter)
45 ConfigReader* MyConf = new ConfigReader(ServerInstance);
47 for (int i = 0; i < MyConf->Enumerate("securelist"); i++)
48 allowlist.push_back(MyConf->ReadValue("securelist", "exception", i));
49 WaitTime = MyConf->ReadInteger("securelist", "waittime", "60", 0, true);
53 void Implements(char* List)
55 List[I_OnRehash] = List[I_OnPreCommand] = List[I_On005Numeric] = 1;
60 * Intercept the LIST command.
62 virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
64 /* If the command doesnt appear to be valid, we dont want to mess with it. */
68 if ((command == "LIST") && (ServerInstance->Time() < (user->signon+WaitTime)) && (!*user->oper))
70 /* Normally wouldnt be allowed here, are they exempt? */
71 for (std::vector<std::string>::iterator x = allowlist.begin(); x != allowlist.end(); x++)
72 if (ServerInstance->MatchText(user->MakeHost(), *x))
75 /* Not exempt, BOOK EM DANNO! */
76 user->WriteServ("NOTICE %s :*** You cannot list within the first %d seconds of connecting. Please try again later.",user->nick, WaitTime);
77 /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
78 * receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
80 user->WriteServ("321 %s Channel :Users Name",user->nick);
81 user->WriteServ("323 %s :End of channel list.",user->nick);
87 virtual void On005Numeric(std::string &output)
89 output.append(" SECURELIST");
92 virtual Priority Prioritize()
94 return (Priority)ServerInstance->PriorityBefore("m_safelist.so");
101 /******************************************************************************************************/
103 class ModuleSecureListFactory : public ModuleFactory
106 ModuleSecureListFactory()
110 ~ModuleSecureListFactory()
114 virtual Module * CreateModule(InspIRCd* Me)
116 return new ModuleSecureList(Me);
121 extern "C" void * init_module( void )
123 return new ModuleSecureListFactory;