1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
18 #include "configreader.h"
23 #include "command_parse.h"
25 bool InspIRCd::ULine(const char* server)
32 return (find(Config->ulines.begin(),Config->ulines.end(),server) != Config->ulines.end());
35 int InspIRCd::OperPassCompare(const char* data,const char* input)
38 FOREACH_RESULT_I(this,I_OnOperCompare,OnOperCompare(data,input))
39 Log(DEBUG,"OperPassCompare: %d",MOD_RESULT);
44 Log(DEBUG,"strcmp fallback: '%s' '%s' %d",data,input,strcmp(data,input));
45 return strcmp(data,input);
48 long InspIRCd::Duration(const char* str)
54 if ((!strchr(str,'s')) && (!strchr(str,'m')) && (!strchr(str,'h')) && (!strchr(str,'d')) && (!strchr(str,'w')) && (!strchr(str,'y')))
58 return Duration(n.c_str());
61 for (char* i = (char*)str; *i; i++)
63 // if we have digits, build up a string for the value in n_field,
64 // up to 10 digits in size.
65 if ((*i >= '0') && (*i <= '9'))
67 strlcat(n_field,i,10);
71 // we dont have a digit, check for numeric tokens
75 total += atoi(n_field);
79 total += (atoi(n_field)*duration_m);
83 total += (atoi(n_field)*duration_h);
87 total += (atoi(n_field)*duration_d);
91 total += (atoi(n_field)*duration_w);
95 total += (atoi(n_field)*duration_y);
101 // add trailing seconds
102 total += atoi(n_field);
107 /* All other ircds when doing this check usually just look for a string of *@* or *. We're smarter than that, though. */
109 bool InspIRCd::HostMatchesEveryone(const std::string &mask, userrec* user)
112 char itrigger[MAXBUF];
115 if (!Config->ConfValue(Config->config_data, "insane","trigger", 0, itrigger, MAXBUF))
116 strlcpy(itrigger,"95.5",MAXBUF);
118 if (Config->ConfValueBool(Config->config_data, "insane","hostmasks", 0))
121 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
123 strlcpy(buffer,u->second->ident,MAXBUF);
124 charlcat(buffer,'@',MAXBUF);
125 strlcat(buffer,u->second->host,MAXBUF);
126 if (match(buffer,mask.c_str()))
129 float percent = ((float)matches / (float)clientlist.size()) * 100;
130 if (percent > (float)atof(itrigger))
132 WriteOpers("*** \2WARNING\2: %s tried to set a G/K/E line mask of %s, which covers %.2f%% of the network!",user->nick,mask.c_str(),percent);
138 bool InspIRCd::IPMatchesEveryone(const std::string &ip, userrec* user)
140 char itrigger[MAXBUF];
143 if (!Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF))
144 strlcpy(itrigger,"95.5",MAXBUF);
146 if (Config->ConfValueBool(Config->config_data, "insane","ipmasks",0))
149 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
151 if (match(u->second->GetIPString(),ip.c_str(),true))
155 float percent = ((float)matches / (float)clientlist.size()) * 100;
156 if (percent > (float)atof(itrigger))
158 WriteOpers("*** \2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick,ip.c_str(),percent);
164 bool InspIRCd::NickMatchesEveryone(const std::string &nick, userrec* user)
166 char itrigger[MAXBUF];
169 if (!Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF))
170 strlcpy(itrigger,"95.5",MAXBUF);
172 if (Config->ConfValueBool(Config->config_data, "insane","nickmasks",0))
175 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
177 if (match(u->second->nick,nick.c_str()))
181 float percent = ((float)matches / (float)clientlist.size()) * 100;
182 if (percent > (float)atof(itrigger))
184 WriteOpers("*** \2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick,nick.c_str(),percent);