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