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)
27 Implementation eventlist[] = { I_OnRehash, I_OnPreCommand, I_On005Numeric };
28 ServerInstance->Modules->Attach(eventlist, this, 3);
31 virtual ~ModuleSecureList()
35 virtual Version GetVersion()
37 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
40 void OnRehash(User* user, const std::string ¶meter)
42 ConfigReader* MyConf = new ConfigReader(ServerInstance);
45 for (int i = 0; i < MyConf->Enumerate("securehost"); i++)
46 allowlist.push_back(MyConf->ReadValue("securehost", "exception", i));
48 WaitTime = MyConf->ReadInteger("securelist", "waittime", "60", 0, true);
52 void Implements(char* List)
54 List[I_OnRehash] = List[I_OnPreCommand] = List[I_On005Numeric] = 1;
59 * Intercept the LIST command.
61 virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, User *user, bool validated, const std::string &original_line)
63 /* If the command doesnt appear to be valid, we dont want to mess with it. */
67 if ((command == "LIST") && (ServerInstance->Time() < (user->signon+WaitTime)) && (!IS_OPER(user)))
69 /* Normally wouldnt be allowed here, are they exempt? */
70 for (std::vector<std::string>::iterator x = allowlist.begin(); x != allowlist.end(); x++)
71 if (ServerInstance->MatchText(user->MakeHost(), *x))
74 /* Not exempt, BOOK EM DANNO! */
75 user->WriteServ("NOTICE %s :*** You cannot list within the first %d seconds of connecting. Please try again later.",user->nick, WaitTime);
76 /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
77 * receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
79 user->WriteServ("321 %s Channel :Users Name",user->nick);
80 user->WriteServ("323 %s :End of channel list.",user->nick);
86 virtual void On005Numeric(std::string &output)
88 output.append(" SECURELIST");
93 Module* safelist = ServerInstance->Modules->Find("m_safelist.so");
94 ServerInstance->Modules->SetPriority(this, I_OnPreCommand, PRIO_BEFORE, &safelist);
99 MODULE_INIT(ModuleSecureList)