summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/aes.cpp4
-rw-r--r--src/cmd_kill.cpp10
-rw-r--r--src/cmd_names.cpp8
-rw-r--r--src/cmd_notice.cpp10
-rw-r--r--src/cmd_oper.cpp8
-rw-r--r--src/cmd_privmsg.cpp20
-rw-r--r--src/cmd_quit.cpp14
-rw-r--r--src/cmd_time.cpp6
-rw-r--r--src/cmd_topic.cpp16
-rw-r--r--src/cmd_unloadmodule.cpp18
-rw-r--r--src/cmd_who.cpp30
-rw-r--r--src/cmd_whois.cpp10
-rw-r--r--src/cull_list.cpp26
-rw-r--r--src/dns.cpp98
-rw-r--r--src/hashcomp.cpp16
-rw-r--r--src/helperfuncs.cpp2
-rw-r--r--src/inspircd.cpp446
-rw-r--r--src/message.cpp46
-rw-r--r--src/mode.cpp344
-rw-r--r--src/modules.cpp94
-rw-r--r--src/modules/extra/m_filter_pcre.cpp40
-rw-r--r--src/modules/extra/m_sql.cpp18
-rw-r--r--src/modules/extra/m_sqllog.cpp149
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp2
-rw-r--r--src/modules/m_antibottler.cpp8
-rw-r--r--src/modules/m_censor.cpp16
-rw-r--r--src/modules/m_chanfilter.cpp10
-rw-r--r--src/modules/m_chanprotect.cpp28
-rw-r--r--src/modules/m_chghost.cpp10
-rw-r--r--src/modules/m_cloaking.cpp32
-rw-r--r--src/modules/m_denychans.cpp6
-rw-r--r--src/modules/m_devoice.cpp12
-rw-r--r--src/modules/m_globalload.cpp37
-rw-r--r--src/modules/m_hostchange.cpp2
-rw-r--r--src/modules/m_ident.cpp62
-rw-r--r--src/modules/m_knock.cpp6
-rw-r--r--src/modules/m_messageflood.cpp10
-rw-r--r--src/modules/m_noctcp.cpp6
-rw-r--r--src/modules/m_nokicks.cpp6
-rw-r--r--src/modules/m_nonicks.cpp6
-rw-r--r--src/modules/m_nonotice.cpp6
-rw-r--r--src/modules/m_operchans.cpp6
-rw-r--r--src/modules/m_operjoin.cpp26
-rw-r--r--src/modules/m_operlevels.cpp24
-rw-r--r--src/modules/m_opermodes.cpp18
-rw-r--r--src/modules/m_operwho.cpp18
-rw-r--r--src/modules/m_park.cpp102
-rw-r--r--src/modules/m_randquote.cpp2
-rw-r--r--src/modules/m_remove.cpp8
-rw-r--r--src/modules/m_safelist.cpp110
-rw-r--r--src/modules/m_silence.cpp32
-rw-r--r--src/modules/m_spy.cpp100
-rw-r--r--src/modules/m_stripcolor.cpp8
-rw-r--r--src/modules/m_timedbans.cpp24
-rw-r--r--src/modules/m_uninvite.cpp80
-rw-r--r--src/modules/m_userip.cpp30
-rw-r--r--src/modules/m_vhost.cpp49
-rw-r--r--src/modules/m_watch.cpp128
-rw-r--r--src/socket.cpp12
-rw-r--r--src/users.cpp626
-rw-r--r--src/xline.cpp77
61 files changed, 1637 insertions, 1541 deletions
diff --git a/src/aes.cpp b/src/aes.cpp
index b490f7716..033d8beb2 100644
--- a/src/aes.cpp
+++ b/src/aes.cpp
@@ -1467,11 +1467,11 @@ int from64tobits(char *out, const char *in, int maxlen)
{
++len;
if (maxlen && len > maxlen)
- return(-1);
+ return(-1);
*out++ = ((DECODE64(digit2) << 4) & 0xf0) | (DECODE64(digit3) >> 2);
if (digit4 != '=')
{
- ++len;
+ ++len;
if (maxlen && len > maxlen)
return(-1);
*out++ = ((DECODE64(digit3) << 6) & 0xc0) | DECODE64(digit4);
diff --git a/src/cmd_kill.cpp b/src/cmd_kill.cpp
index ac3f3686d..f90347e95 100644
--- a/src/cmd_kill.cpp
+++ b/src/cmd_kill.cpp
@@ -52,18 +52,18 @@ void cmd_kill::Handle (char **parameters, int pcnt, userrec *user)
char killreason[MAXBUF];
int MOD_RESULT = 0;
- log(DEBUG,"kill: %s %s", parameters[0], parameters[1]);
+ log(DEBUG,"kill: %s %s", parameters[0], parameters[1]);
if (u)
{
log(DEBUG, "into kill mechanism");
- FOREACH_RESULT(I_OnKill, OnKill(user, u, parameters[1]));
+ FOREACH_RESULT(I_OnKill, OnKill(user, u, parameters[1]));
- if (MOD_RESULT)
+ if (MOD_RESULT)
{
log(DEBUG, "A module prevented the kill with result %d", MOD_RESULT);
- return;
- }
+ return;
+ }
if (!IS_LOCAL(u))
{
diff --git a/src/cmd_names.cpp b/src/cmd_names.cpp
index e5e83a70f..bf987e9f2 100644
--- a/src/cmd_names.cpp
+++ b/src/cmd_names.cpp
@@ -77,10 +77,10 @@ void cmd_names::Handle (char **parameters, int pcnt, userrec *user)
if (c)
{
if ((c->modes[CM_SECRET]) && (!c->HasUser(user)))
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, c->name);
- return;
- }
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, c->name);
+ return;
+ }
userlist(user,c);
WriteServ(user->fd,"366 %s %s :End of /NAMES list.", user->nick, c->name);
}
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
index 589bf38c7..784f1e185 100644
--- a/src/cmd_notice.cpp
+++ b/src/cmd_notice.cpp
@@ -115,11 +115,11 @@ void cmd_notice::Handle (char **parameters, int pcnt, userrec *user)
}
parameters[1] = (char*)temp.c_str();
- if (temp == "")
- {
- WriteServ(user->fd,"412 %s No text to send", user->nick);
- return;
- }
+ if (temp == "")
+ {
+ WriteServ(user->fd,"412 %s No text to send", user->nick);
+ return;
+ }
ChanExceptSender(chan, user, status, "NOTICE %s :%s", chan->name, parameters[1]);
diff --git a/src/cmd_oper.cpp b/src/cmd_oper.cpp
index f4b9a1c21..2681da13e 100644
--- a/src/cmd_oper.cpp
+++ b/src/cmd_oper.cpp
@@ -129,9 +129,9 @@ void cmd_oper::Handle (char **parameters, int pcnt, userrec *user)
}
if (found)
{
- /* correct oper credentials */
- WriteOpers("*** %s (%s@%s) is now an IRC operator of type %s",user->nick,user->ident,user->host,OperType);
- WriteServ(user->fd,"381 %s :You are now an IRC operator of type %s",user->nick,OperType);
+ /* correct oper credentials */
+ WriteOpers("*** %s (%s@%s) is now an IRC operator of type %s",user->nick,user->ident,user->host,OperType);
+ WriteServ(user->fd,"381 %s :You are now an IRC operator of type %s",user->nick,OperType);
if (!strchr(user->modes,'o'))
{
strcat(user->modes,"o");
@@ -154,7 +154,7 @@ void cmd_oper::Handle (char **parameters, int pcnt, userrec *user)
{
WriteServ(user->fd,"491 %s :Your oper block does not have a valid opertype associated with it",user->nick);
WriteOpers("*** CONFIGURATION ERROR! Oper block mismatch for OperType %s",OperType);
- log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: credentials valid, but oper type nonexistent.",user->nick,user->ident,user->host);
+ log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: credentials valid, but oper type nonexistent.",user->nick,user->ident,user->host);
}
}
return;
diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp
index 9ab0532c5..85bb4d6d2 100644
--- a/src/cmd_privmsg.cpp
+++ b/src/cmd_privmsg.cpp
@@ -76,18 +76,18 @@ void cmd_privmsg::Handle (char **parameters, int pcnt, userrec *user)
char* servermask = parameters[0];
servermask++;
if (match(Config->ServerName,servermask))
- {
+ {
ServerPrivmsgAll("%s",parameters[1]);
- }
+ }
return;
- }
- char status = 0;
- if ((*parameters[0] == '@') || (*parameters[0] == '%') || (*parameters[0] == '+'))
- {
- status = *parameters[0];
- parameters[0]++;
- }
- if (parameters[0][0] == '#')
+ }
+ char status = 0;
+ if ((*parameters[0] == '@') || (*parameters[0] == '%') || (*parameters[0] == '+'))
+ {
+ status = *parameters[0];
+ parameters[0]++;
+ }
+ if (parameters[0][0] == '#')
{
chan = FindChan(parameters[0]);
if (chan)
diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp
index dd36de9b3..4863d6333 100644
--- a/src/cmd_quit.cpp
+++ b/src/cmd_quit.cpp
@@ -113,11 +113,11 @@ void cmd_quit::Handle (char **parameters, int pcnt, userrec *user)
if (user->fd > -1)
{
ServerInstance->SE->DelFd(user->fd);
- if (find(local_users.begin(),local_users.end(),user) != local_users.end())
- {
- log(DEBUG,"Delete local user");
- local_users.erase(find(local_users.begin(),local_users.end(),user));
- }
+ if (find(local_users.begin(),local_users.end(),user) != local_users.end())
+ {
+ log(DEBUG,"Delete local user");
+ local_users.erase(find(local_users.begin(),local_users.end(),user));
+ }
user->CloseSocket();
}
@@ -129,8 +129,8 @@ void cmd_quit::Handle (char **parameters, int pcnt, userrec *user)
if (user->registered == 7) {
purge_empty_chans(user);
}
- if (user->fd > -1)
- fd_ref_table[user->fd] = NULL;
+ if (user->fd > -1)
+ fd_ref_table[user->fd] = NULL;
delete user;
}
diff --git a/src/cmd_time.cpp b/src/cmd_time.cpp
index 214592ea8..f914add49 100644
--- a/src/cmd_time.cpp
+++ b/src/cmd_time.cpp
@@ -69,9 +69,9 @@ void cmd_time::Handle (char **parameters, int pcnt, userrec *user)
time(&rawtime);
timeinfo = localtime(&rawtime);
- char tms[26];
- snprintf(tms,26,"%s",asctime(timeinfo));
- tms[24] = 0;
+ char tms[26];
+ snprintf(tms,26,"%s",asctime(timeinfo));
+ tms[24] = 0;
WriteServ(user->fd,"391 %s %s :%s",user->nick,Config->ServerName,tms);
diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp
index b8c60240d..0b94eb53b 100644
--- a/src/cmd_topic.cpp
+++ b/src/cmd_topic.cpp
@@ -3,7 +3,7 @@
* +------------------------------------+
*
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- * E-mail:
+ * E-mail:
* <brain@chatspike.net>
* <Craig@chatspike.net>
*
@@ -112,13 +112,13 @@ void cmd_topic::Handle (char **parameters, int pcnt, userrec *user)
char topic[MAXTOPIC];
strlcpy(topic,parameters[1],MAXTOPIC-1);
- if (IS_LOCAL(user))
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic));
- if (MOD_RESULT)
- return;
- }
+ if (IS_LOCAL(user))
+ {
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(user,Ptr,topic));
+ if (MOD_RESULT)
+ return;
+ }
strlcpy(Ptr->topic,topic,MAXTOPIC-1);
strlcpy(Ptr->setby,user->nick,NICKMAX-1);
diff --git a/src/cmd_unloadmodule.cpp b/src/cmd_unloadmodule.cpp
index 0d8e4d052..4b7648538 100644
--- a/src/cmd_unloadmodule.cpp
+++ b/src/cmd_unloadmodule.cpp
@@ -39,14 +39,14 @@ extern InspIRCd* ServerInstance;
void cmd_unloadmodule::Handle (char **parameters, int pcnt, userrec *user)
{
- if (ServerInstance->UnloadModule(parameters[0]))
- {
- WriteOpers("*** MODULE UNLOADED: %s",parameters[0]);
- WriteServ(user->fd,"973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
- }
- else
- {
- WriteServ(user->fd,"972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
- }
+ if (ServerInstance->UnloadModule(parameters[0]))
+ {
+ WriteOpers("*** MODULE UNLOADED: %s",parameters[0]);
+ WriteServ(user->fd,"973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
+ }
+ else
+ {
+ WriteServ(user->fd,"972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
+ }
}
diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp
index 4a94dc659..f5a376e39 100644
--- a/src/cmd_who.cpp
+++ b/src/cmd_who.cpp
@@ -127,12 +127,12 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
if (*i->second->oper) { charlcat(tmp, '*', 9); }
strlcat(tmp, cmode(i->second, Ptr),5);
WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, Ptr->name, i->second->ident, i->second->dhost, i->second->server, i->second->nick, tmp, i->second->fullname);
- n_list++;
- if (n_list > Config->MaxWhoResults)
- {
- WriteServ(user->fd,"523 %s WHO :Command aborted: More results than configured limit",user->nick);
- break;
- }
+ n_list++;
+ if (n_list > Config->MaxWhoResults)
+ {
+ WriteServ(user->fd,"523 %s WHO :Command aborted: More results than configured limit",user->nick);
+ break;
+ }
}
}
@@ -157,17 +157,17 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
}
if (*u->oper) { charlcat(tmp, '*' ,9); }
WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, u->chans.size() && ((ucrec*)*(u->chans.begin()))->channel ? ((ucrec*)*(u->chans.begin()))->channel->name
- : "*", u->ident, u->dhost, u->server, u->nick, tmp, u->fullname);
+ : "*", u->ident, u->dhost, u->server, u->nick, tmp, u->fullname);
}
WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
}
}
if (pcnt == 2)
{
- if ((IS_SINGLE(parameters[0],'0')) || (IS_SINGLE(parameters[0],'*')) && (IS_SINGLE(parameters[1],'o')))
- {
+ if ((IS_SINGLE(parameters[0],'0')) || (IS_SINGLE(parameters[0],'*')) && (IS_SINGLE(parameters[1],'o')))
+ {
for (std::vector<userrec*>::iterator i = all_opers.begin(); i != all_opers.end(); i++)
- {
+ {
// If i were a rich man.. I wouldn't need to me making these bugfixes..
// But i'm a poor bastard with nothing better to do.
userrec* oper = *i;
@@ -177,12 +177,12 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
} else {
charlcat(tmp, 'H' ,9);
}
- WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans.size() && ((ucrec*)*(oper->chans.begin()))->channel ? ((ucrec*)*(oper->chans.begin()))->channel->name
+ WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans.size() && ((ucrec*)*(oper->chans.begin()))->channel ? ((ucrec*)*(oper->chans.begin()))->channel->name
: "*", oper->ident, oper->dhost, oper->server, oper->nick, tmp, oper->fullname);
- }
- WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
- return;
- }
+ }
+ WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
+ return;
+ }
}
}
diff --git a/src/cmd_whois.cpp b/src/cmd_whois.cpp
index 20215b9cf..37283784b 100644
--- a/src/cmd_whois.cpp
+++ b/src/cmd_whois.cpp
@@ -132,10 +132,10 @@ void cmd_whois::Handle (char **parameters, int pcnt, userrec *user)
{
do_whois(user,dest,0,0,parameters[0]);
}
- else
- {
- /* no such nick/channel */
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- WriteServ(user->fd,"318 %s %s :End of /WHOIS list.",user->nick, parameters[0]);
+ else
+ {
+ /* no such nick/channel */
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ WriteServ(user->fd,"318 %s %s :End of /WHOIS list.",user->nick, parameters[0]);
}
}
diff --git a/src/cull_list.cpp b/src/cull_list.cpp
index 20454c155..61324c454 100644
--- a/src/cull_list.cpp
+++ b/src/cull_list.cpp
@@ -86,8 +86,8 @@ bool CullList::IsValid(userrec* user)
CullItem::CullItem(userrec* u, std::string &r)
{
- this->user = u;
- this->reason = r;
+ this->user = u;
+ this->reason = r;
}
CullItem::CullItem(userrec* u, const char* r)
@@ -102,27 +102,27 @@ CullItem::~CullItem()
userrec* CullItem::GetUser()
{
- return this->user;
+ return this->user;
}
std::string& CullItem::GetReason()
{
- return this->reason;
+ return this->reason;
}
CullList::CullList()
{
list.clear();
- exempt.clear();
+ exempt.clear();
}
void CullList::AddItem(userrec* user, std::string &reason)
{
if (exempt.find(user) == exempt.end())
{
- CullItem item(user,reason);
- list.push_back(item);
- exempt[user] = user->signon;
+ CullItem item(user,reason);
+ list.push_back(item);
+ exempt[user] = user->signon;
}
}
@@ -138,13 +138,13 @@ void CullList::AddItem(userrec* user, const char* reason)
int CullList::Apply()
{
- int n = 0;
- while (list.size())
- {
+ int n = 0;
+ while (list.size())
+ {
std::vector<CullItem>::iterator a = list.begin();
kill_link(a->GetUser(), a->GetReason().c_str());
list.erase(list.begin());
- }
- return n;
+ }
+ return n;
}
diff --git a/src/dns.cpp b/src/dns.cpp
index dc25fe8fe..bdb7889a5 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -210,12 +210,12 @@ void DNS::dns_init()
void DNS::dns_init_2(const char* dnsserver)
{
- in_addr addr4;
- i4 = 0;
- srand((unsigned int) TIME);
- memset(servers4,'\0',sizeof(in_addr) * 8);
- if (dns_aton4_s(dnsserver,&addr4) != NULL)
- memcpy(&servers4[i4++],&addr4,sizeof(in_addr));
+ in_addr addr4;
+ i4 = 0;
+ srand((unsigned int) TIME);
+ memset(servers4,'\0',sizeof(in_addr) * 8);
+ if (dns_aton4_s(dnsserver,&addr4) != NULL)
+ memcpy(&servers4[i4++],&addr4,sizeof(in_addr));
}
@@ -704,13 +704,13 @@ bool DNS::ReverseLookup(const std::string &ip)
{
if (ServerInstance && ServerInstance->stats)
ServerInstance->stats->statsDns++;
- binip = dns_aton4(ip.c_str());
- if (binip == NULL)
+ binip = dns_aton4(ip.c_str());
+ if (binip == NULL)
{
- return false;
- }
+ return false;
+ }
- this->myfd = dns_getname4(binip);
+ this->myfd = dns_getname4(binip);
if (this->myfd == -1)
{
return false;
@@ -784,14 +784,14 @@ int DNS::GetFD()
std::string DNS::GetResult()
{
log(DEBUG,"DNS: GetResult()");
- result = dns_getresult(this->myfd);
- if (result)
+ result = dns_getresult(this->myfd);
+ if (result)
{
if (ServerInstance && ServerInstance->stats)
ServerInstance->stats->statsDnsGood++;
dns_close(this->myfd);
return result;
- }
+ }
else
{
if (ServerInstance && ServerInstance->stats)
@@ -838,40 +838,40 @@ std::string DNS::GetResultIP()
#ifdef THREADED_DNS
void* dns_task(void* arg)
{
- userrec* u = (userrec*)arg;
- log(DEBUG,"DNS thread for user %s",u->nick);
- DNS dns1;
- DNS dns2;
- std::string host;
- std::string ip;
- if (dns1.ReverseLookup((char*)inet_ntoa(u->ip4)))
- {
- while (!dns1.HasResult())
- {
- usleep(100);
- }
- host = dns1.GetResult();
- if (host != "")
- {
- if (dns2.ForwardLookup(host))
- {
- while (!dns2.HasResult())
- {
- usleep(100);
- }
- ip = dns2.GetResultIP();
- if (ip == std::string((char*)inet_ntoa(u->ip4)))
- {
- if (host.length() < 160)
- {
- strcpy(u->host,host.c_str());
- strcpy(u->dhost,host.c_str());
- }
- }
- }
- }
- }
- u->dns_done = true;
- return NULL;
+ userrec* u = (userrec*)arg;
+ log(DEBUG,"DNS thread for user %s",u->nick);
+ DNS dns1;
+ DNS dns2;
+ std::string host;
+ std::string ip;
+ if (dns1.ReverseLookup((char*)inet_ntoa(u->ip4)))
+ {
+ while (!dns1.HasResult())
+ {
+ usleep(100);
+ }
+ host = dns1.GetResult();
+ if (host != "")
+ {
+ if (dns2.ForwardLookup(host))
+ {
+ while (!dns2.HasResult())
+ {
+ usleep(100);
+ }
+ ip = dns2.GetResultIP();
+ if (ip == std::string((char*)inet_ntoa(u->ip4)))
+ {
+ if (host.length() < 160)
+ {
+ strcpy(u->host,host.c_str());
+ strcpy(u->dhost,host.c_str());
+ }
+ }
+ }
+ }
+ }
+ u->dns_done = true;
+ return NULL;
}
#endif
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 3e1184a95..d107df309 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -69,9 +69,9 @@ using namespace std;
size_t nspace::hash<in_addr>::operator()(const struct in_addr &a) const
{
- size_t q;
- memcpy(&q,&a,sizeof(size_t));
- return q;
+ size_t q;
+ memcpy(&q,&a,sizeof(size_t));
+ return q;
}
size_t nspace::hash<string>::operator()(const string &s) const
@@ -95,7 +95,7 @@ bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2)
bool irc::InAddr_HashComp::operator()(const in_addr &s1, const in_addr &s2) const
{
- return (s1.s_addr == s1.s_addr);
+ return (s1.s_addr == s1.s_addr);
}
/******************************************************
@@ -131,13 +131,13 @@ int irc::irc_char_traits::compare(const char* str1, const char* str2, size_t n)
for(unsigned int i = 0; i < n; i++)
{
if(lowermap[(unsigned char)*str1] > lowermap[(unsigned char)*str2])
- return 1;
+ return 1;
if(lowermap[(unsigned char)*str1] < lowermap[(unsigned char)*str2])
- return -1;
+ return -1;
- if(*str1 == 0 || *str2 == 0)
- return 0;
+ if(*str1 == 0 || *str2 == 0)
+ return 0;
str1++;
str2++;
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 9f184e868..034976fb7 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -1862,7 +1862,7 @@ void LoadAllModules(InspIRCd* ServerInstance)
char configToken[MAXBUF];
Config->module_names.clear();
MODCOUNT = -1;
-
+
for (int count = 0; count < Config->ConfValueEnum(Config->config_data, "module"); count++)
{
Config->ConfValue(Config->config_data, "module","name",count,configToken,MAXBUF);
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 9b7d6fa17..5d77e6d75 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -199,39 +199,39 @@ InspIRCd::InspIRCd(int argc, char** argv)
this->MakeLowerMap();
- OpenLog(argv, argc);
+ OpenLog(argv, argc);
this->stats = new serverstats();
- Config->ClearStack();
- Config->Read(true,NULL);
- CheckRoot();
+ Config->ClearStack();
+ Config->Read(true,NULL);
+ CheckRoot();
this->ModeGrok = new ModeParser();
this->Parser = new CommandParser();
- AddServerName(Config->ServerName);
- CheckDie();
- stats->BoundPortCount = BindPorts(true);
+ AddServerName(Config->ServerName);
+ CheckDie();
+ stats->BoundPortCount = BindPorts(true);
for(int t = 0; t < 255; t++)
Config->global_implementation[t] = 0;
memset(&Config->implement_lists,0,sizeof(Config->implement_lists));
- printf("\n");
+ printf("\n");
SetSignals();
- if (!Config->nofork)
- {
+ if (!Config->nofork)
+ {
if (!DaemonSeed())
- {
- printf("ERROR: could not go into daemon mode. Shutting down.\n");
- Exit(ERROR);
- }
- }
+ {
+ printf("ERROR: could not go into daemon mode. Shutting down.\n");
+ Exit(ERROR);
+ }
+ }
- /* Because of limitations in kqueue on freebsd, we must fork BEFORE we
- * initialize the socket engine.
- */
- SE = new SocketEngine();
+ /* Because of limitations in kqueue on freebsd, we must fork BEFORE we
+ * initialize the socket engine.
+ */
+ SE = new SocketEngine();
- /* We must load the modules AFTER initializing the socket engine, now */
+ /* We must load the modules AFTER initializing the socket engine, now */
return;
}
@@ -267,38 +267,38 @@ void InspIRCd::erase_factory(int j)
{
if (v == j)
{
- factory.erase(t);
- factory.push_back(NULL);
- return;
- }
+ factory.erase(t);
+ factory.push_back(NULL);
+ return;
+ }
v++;
- }
+ }
}
void InspIRCd::erase_module(int j)
{
int v1 = 0;
for (std::vector<Module*>::iterator m = modules.begin(); m!= modules.end(); m++)
- {
- if (v1 == j)
- {
+ {
+ if (v1 == j)
+ {
delete *m;
- modules.erase(m);
- modules.push_back(NULL);
+ modules.erase(m);
+ modules.push_back(NULL);
break;
- }
+ }
v1++;
- }
+ }
int v2 = 0;
- for (std::vector<std::string>::iterator v = Config->module_names.begin(); v != Config->module_names.end(); v++)
- {
- if (v2 == j)
- {
- Config->module_names.erase(v);
- break;
- }
+ for (std::vector<std::string>::iterator v = Config->module_names.begin(); v != Config->module_names.end(); v++)
+ {
+ if (v2 == j)
+ {
+ Config->module_names.erase(v);
+ break;
+ }
v2++;
- }
+ }
}
@@ -385,7 +385,7 @@ void InspIRCd::MoveToLast(std::string modulename)
void InspIRCd::BuildISupport()
{
- // the neatest way to construct the initial 005 numeric, considering the number of configure constants to go in it...
+ // the neatest way to construct the initial 005 numeric, considering the number of configure constants to go in it...
std::stringstream v;
v << "WALLCHOPS WALLVOICES MODES=" << MAXMODES << " CHANTYPES=# PREFIX=(ohv)@%+ MAP MAXCHANNELS=" << MAXCHANS << " MAXBANS=60 VBANLIST NICKLEN=" << NICKMAX-1;
v << " CASEMAPPING=rfc1459 STATUSMSG=@%+ CHARSET=ascii TOPICLEN=" << MAXTOPIC << " KICKLEN=" << MAXKICK << " MAXTARGETS=" << Config->MaxTargets << " AWAYLEN=";
@@ -419,7 +419,7 @@ bool InspIRCd::UnloadModule(const char* filename)
FOREACH_MOD(I_OnUnloadModule,OnUnloadModule(modules[j],Config->module_names[j]));
- for(int t = 0; t < 255; t++)
+ for(int t = 0; t < 255; t++)
{
Config->global_implementation[t] -= Config->implement_lists[j][t];
}
@@ -439,8 +439,8 @@ bool InspIRCd::UnloadModule(const char* filename)
erase_module(j);
log(DEBUG,"Erasing module entry...");
erase_factory(j);
- log(DEBUG,"Removing dependent commands...");
- Parser->RemoveCommands(filename);
+ log(DEBUG,"Removing dependent commands...");
+ Parser->RemoveCommands(filename);
log(DEFAULT,"Module %s unloaded",filename);
MODCOUNT--;
BuildISupport();
@@ -473,8 +473,8 @@ bool InspIRCd::LoadModule(const char* filename)
#endif
log(DEBUG,"Loading module: %s",modfile);
#ifndef STATIC_LINK
- if (FileExists(modfile))
- {
+ if (FileExists(modfile))
+ {
#endif
for (unsigned int j = 0; j < Config->module_names.size(); j++)
{
@@ -486,22 +486,22 @@ bool InspIRCd::LoadModule(const char* filename)
}
}
ircd_module* a = new ircd_module(modfile);
- factory[MODCOUNT+1] = a;
- if (factory[MODCOUNT+1]->LastError())
- {
- log(DEFAULT,"Unable to load %s: %s",modfile,factory[MODCOUNT+1]->LastError());
+ factory[MODCOUNT+1] = a;
+ if (factory[MODCOUNT+1]->LastError())
+ {
+ log(DEFAULT,"Unable to load %s: %s",modfile,factory[MODCOUNT+1]->LastError());
snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
return false;
- }
+ }
try
{
- if (factory[MODCOUNT+1]->factory)
- {
+ if (factory[MODCOUNT+1]->factory)
+ {
Module* m = factory[MODCOUNT+1]->factory->CreateModule(MyServer);
- modules[MODCOUNT+1] = m;
- /* save the module and the module's classfactory, if
- * this isnt done, random crashes can occur :/ */
- Config->module_names.push_back(filename);
+ modules[MODCOUNT+1] = m;
+ /* save the module and the module's classfactory, if
+ * this isnt done, random crashes can occur :/ */
+ Config->module_names.push_back(filename);
char* x = &Config->implement_lists[MODCOUNT+1][0];
for(int t = 0; t < 255; t++)
@@ -511,13 +511,13 @@ bool InspIRCd::LoadModule(const char* filename)
for(int t = 0; t < 255; t++)
Config->global_implementation[t] += Config->implement_lists[MODCOUNT+1][t];
- }
+ }
else
{
- log(DEFAULT,"Unable to load %s",modfile);
+ log(DEFAULT,"Unable to load %s",modfile);
snprintf(MODERR,MAXBUF,"Factory function failed!");
return false;
- }
+ }
}
catch (ModuleException& modexcept)
{
@@ -526,13 +526,13 @@ bool InspIRCd::LoadModule(const char* filename)
return false;
}
#ifndef STATIC_LINK
- }
- else
- {
- log(DEFAULT,"InspIRCd: startup: Module Not Found %s",modfile);
+ }
+ else
+ {
+ log(DEFAULT,"InspIRCd: startup: Module Not Found %s",modfile);
snprintf(MODERR,MAXBUF,"Module file could not be found");
return false;
- }
+ }
#endif
MODCOUNT++;
FOREACH_MOD(I_OnLoadModule,OnLoadModule(modules[MODCOUNT],filename_str));
@@ -583,35 +583,35 @@ bool InspIRCd::LoadModule(const char* filename)
void InspIRCd::DoOneIteration(bool process_module_sockets)
{
- int activefds[MAX_DESCRIPTORS];
- int incomingSockfd;
- int in_port;
- userrec* cu = NULL;
- InspSocket* s = NULL;
- InspSocket* s_del = NULL;
- unsigned int numberactive;
- sockaddr_in sock_us; // our port number
- socklen_t uslen; // length of our port number
+ int activefds[MAX_DESCRIPTORS];
+ int incomingSockfd;
+ int in_port;
+ userrec* cu = NULL;
+ InspSocket* s = NULL;
+ InspSocket* s_del = NULL;
+ unsigned int numberactive;
+ sockaddr_in sock_us; // our port number
+ socklen_t uslen; // length of our port number
if (yield_depth > 100)
return;
yield_depth++;
- /* time() seems to be a pretty expensive syscall, so avoid calling it too much.
- * Once per loop iteration is pleanty.
- */
- OLDTIME = TIME;
- TIME = time(NULL);
-
- /* Run background module timers every few seconds
- * (the docs say modules shouldnt rely on accurate
- * timing using this event, so we dont have to
- * time this exactly).
- */
- if (((TIME % 5) == 0) && (!expire_run))
- {
- expire_lines();
+ /* time() seems to be a pretty expensive syscall, so avoid calling it too much.
+ * Once per loop iteration is pleanty.
+ */
+ OLDTIME = TIME;
+ TIME = time(NULL);
+
+ /* Run background module timers every few seconds
+ * (the docs say modules shouldnt rely on accurate
+ * timing using this event, so we dont have to
+ * time this exactly).
+ */
+ if (((TIME % 5) == 0) && (!expire_run))
+ {
+ expire_lines();
if (process_module_sockets)
{
/* Fix by brain - the addition of DoOneIteration means that this
@@ -626,17 +626,17 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
*
* This should do the job and fix the bug.
*/
- FOREACH_MOD(I_OnBackgroundTimer,OnBackgroundTimer(TIME));
+ FOREACH_MOD(I_OnBackgroundTimer,OnBackgroundTimer(TIME));
}
- TickMissedTimers(TIME);
- expire_run = true;
+ TickMissedTimers(TIME);
+ expire_run = true;
yield_depth--;
- return;
- }
- else if ((TIME % 5) == 1)
- {
- expire_run = false;
- }
+ return;
+ }
+ else if ((TIME % 5) == 1)
+ {
+ expire_run = false;
+ }
if (iterations++ == 15)
{
@@ -644,165 +644,165 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
DoBackgroundUserStuff(TIME);
}
- /* Once a second, do the background processing */
- if (TIME != OLDTIME)
- {
- if (TIME < OLDTIME)
- WriteOpers("*** \002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %d secs.",abs(OLDTIME-TIME));
+ /* Once a second, do the background processing */
+ if (TIME != OLDTIME)
+ {
+ if (TIME < OLDTIME)
+ WriteOpers("*** \002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %d secs.",abs(OLDTIME-TIME));
if ((TIME % 3600) == 0)
{
MaintainWhoWas(TIME);
}
- }
+ }
- /* Process timeouts on module sockets each time around
- * the loop. There shouldnt be many module sockets, at
- * most, 20 or so, so this won't be much of a performance
- * hit at all.
- */
+ /* Process timeouts on module sockets each time around
+ * the loop. There shouldnt be many module sockets, at
+ * most, 20 or so, so this won't be much of a performance
+ * hit at all.
+ */
if (process_module_sockets)
- DoSocketTimeouts(TIME);
-
- TickTimers(TIME);
-
- /* Call the socket engine to wait on the active
- * file descriptors. The socket engine has everything's
- * descriptors in its list... dns, modules, users,
- * servers... so its nice and easy, just one call.
- */
- if (!(numberactive = SE->Wait(activefds)))
+ DoSocketTimeouts(TIME);
+
+ TickTimers(TIME);
+
+ /* Call the socket engine to wait on the active
+ * file descriptors. The socket engine has everything's
+ * descriptors in its list... dns, modules, users,
+ * servers... so its nice and easy, just one call.
+ */
+ if (!(numberactive = SE->Wait(activefds)))
{
yield_depth--;
- return;
+ return;
}
- /**
- * Now process each of the fd's. For users, we have a fast
- * lookup table which can find a user by file descriptor, so
- * processing them by fd isnt expensive. If we have a lot of
- * listening ports or module sockets though, things could get
- * ugly.
- */
+ /**
+ * Now process each of the fd's. For users, we have a fast
+ * lookup table which can find a user by file descriptor, so
+ * processing them by fd isnt expensive. If we have a lot of
+ * listening ports or module sockets though, things could get
+ * ugly.
+ */
log(DEBUG,"There are %d fd's to process.",numberactive);
- for (unsigned int activefd = 0; activefd < numberactive; activefd++)
- {
- int socket_type = SE->GetType(activefds[activefd]);
- switch (socket_type)
- {
- case X_ESTAB_CLIENT:
+ for (unsigned int activefd = 0; activefd < numberactive; activefd++)
+ {
+ int socket_type = SE->GetType(activefds[activefd]);
+ switch (socket_type)
+ {
+ case X_ESTAB_CLIENT:
log(DEBUG,"Type: X_ESTAB_CLIENT: fd=%d",activefds[activefd]);
- cu = fd_ref_table[activefds[activefd]];
- if (cu)
- ProcessUser(cu);
-
- break;
-
- case X_ESTAB_MODULE:
+ cu = fd_ref_table[activefds[activefd]];
+ if (cu)
+ ProcessUser(cu);
+
+ break;
+
+ case X_ESTAB_MODULE:
log(DEBUG,"Type: X_ESTAB_MODULE: fd=%d",activefds[activefd]);
if (!process_module_sockets)
break;
- /* Process module-owned sockets.
- * Modules are encouraged to inherit their sockets from
- * InspSocket so we can process them neatly like this.
- */
- s = socket_ref[activefds[activefd]];
-
- if ((s) && (!s->Poll()))
- {
- log(DEBUG,"inspircd.cpp: Socket poll returned false, close and bail");
- SE->DelFd(s->GetFd());
+ /* Process module-owned sockets.
+ * Modules are encouraged to inherit their sockets from
+ * InspSocket so we can process them neatly like this.
+ */
+ s = socket_ref[activefds[activefd]];
+
+ if ((s) && (!s->Poll()))
+ {
+ log(DEBUG,"inspircd.cpp: Socket poll returned false, close and bail");
+ SE->DelFd(s->GetFd());
socket_ref[activefds[activefd]] = NULL;
- for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
- {
- s_del = (InspSocket*)*a;
- if ((s_del) && (s_del->GetFd() == activefds[activefd]))
- {
- module_sockets.erase(a);
- break;
- }
- }
- s->Close();
- delete s;
- }
+ for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
+ {
+ s_del = (InspSocket*)*a;
+ if ((s_del) && (s_del->GetFd() == activefds[activefd]))
+ {
+ module_sockets.erase(a);
+ break;
+ }
+ }
+ s->Close();
+ delete s;
+ }
else if (!s)
{
log(DEBUG,"WTF, X_ESTAB_MODULE for nonexistent InspSocket, removed!");
SE->DelFd(s->GetFd());
}
- break;
-
- case X_ESTAB_DNS:
- /* When we are using single-threaded dns,
- * the sockets for dns end up in our mainloop.
- * When we are using multi-threaded dns,
- * each thread has its own basic poll() loop
- * within it, making them 'fire and forget'
- * and independent of the mainloop.
- */
+ break;
+
+ case X_ESTAB_DNS:
+ /* When we are using single-threaded dns,
+ * the sockets for dns end up in our mainloop.
+ * When we are using multi-threaded dns,
+ * each thread has its own basic poll() loop
+ * within it, making them 'fire and forget'
+ * and independent of the mainloop.
+ */
#ifndef THREADED_DNS
log(DEBUG,"Type: X_ESTAB_DNS: fd=%d",activefds[activefd]);
- dns_poll(activefds[activefd]);
+ dns_poll(activefds[activefd]);
#endif
- break;
+ break;
case X_LISTEN:
log(DEBUG,"Type: X_LISTEN_MODULE: fd=%d",activefds[activefd]);
- /* It's a listener */
- uslen = sizeof(sock_us);
- length = sizeof(client);
- incomingSockfd = accept (activefds[activefd],(struct sockaddr*)&client,&length);
-
- if ((incomingSockfd > -1) && (!getsockname(incomingSockfd,(sockaddr*)&sock_us,&uslen)))
- {
- in_port = ntohs(sock_us.sin_port);
- log(DEBUG,"Accepted socket %d",incomingSockfd);
- /* Years and years ago, we used to resolve here
- * using gethostbyaddr(). That is sucky and we
- * don't do that any more...
- */
- NonBlocking(incomingSockfd);
- if (Config->GetIOHook(in_port))
- {
- try
- {
- Config->GetIOHook(in_port)->OnRawSocketAccept(incomingSockfd, (char*)inet_ntoa(client.sin_addr), in_port);
- }
- catch (ModuleException& modexcept)
- {
- log(DEBUG,"Module exception cought: %s",modexcept.GetReason());
- }
- }
- stats->statsAccept++;
- AddClient(incomingSockfd, in_port, false, client.sin_addr);
- log(DEBUG,"Adding client on port %lu fd=%lu",(unsigned long)in_port,(unsigned long)incomingSockfd);
- }
- else
- {
- log(DEBUG,"Accept failed on fd %lu: %s",(unsigned long)incomingSockfd,strerror(errno));
- shutdown(incomingSockfd,2);
- close(incomingSockfd);
- stats->statsRefused++;
- }
- break;
-
- default:
- /* Something went wrong if we're in here.
- * In fact, so wrong, im not quite sure
- * what we would do, so for now, its going
- * to safely do bugger all.
- */
+ /* It's a listener */
+ uslen = sizeof(sock_us);
+ length = sizeof(client);
+ incomingSockfd = accept (activefds[activefd],(struct sockaddr*)&client,&length);
+
+ if ((incomingSockfd > -1) && (!getsockname(incomingSockfd,(sockaddr*)&sock_us,&uslen)))
+ {
+ in_port = ntohs(sock_us.sin_port);
+ log(DEBUG,"Accepted socket %d",incomingSockfd);
+ /* Years and years ago, we used to resolve here
+ * using gethostbyaddr(). That is sucky and we
+ * don't do that any more...
+ */
+ NonBlocking(incomingSockfd);
+ if (Config->GetIOHook(in_port))
+ {
+ try
+ {
+ Config->GetIOHook(in_port)->OnRawSocketAccept(incomingSockfd, (char*)inet_ntoa(client.sin_addr), in_port);
+ }
+ catch (ModuleException& modexcept)
+ {
+ log(DEBUG,"Module exception cought: %s",modexcept.GetReason());
+ }
+ }
+ stats->statsAccept++;
+ AddClient(incomingSockfd, in_port, false, client.sin_addr);
+ log(DEBUG,"Adding client on port %lu fd=%lu",(unsigned long)in_port,(unsigned long)incomingSockfd);
+ }
+ else
+ {
+ log(DEBUG,"Accept failed on fd %lu: %s",(unsigned long)incomingSockfd,strerror(errno));
+ shutdown(incomingSockfd,2);
+ close(incomingSockfd);
+ stats->statsRefused++;
+ }
+ break;
+
+ default:
+ /* Something went wrong if we're in here.
+ * In fact, so wrong, im not quite sure
+ * what we would do, so for now, its going
+ * to safely do bugger all.
+ */
log(DEBUG,"Type: X_WHAT_THE_FUCK_BBQ: fd=%d",activefds[activefd]);
SE->DelFd(activefds[activefd]);
- break;
- }
- }
+ break;
+ }
+ }
yield_depth--;
}
@@ -810,12 +810,12 @@ int InspIRCd::Run()
{
/* Until THIS point, ServerInstance == NULL */
- LoadAllModules(this);
+ LoadAllModules(this);
/* Just in case no modules were loaded - fix for bug #101 */
this->BuildISupport();
- printf("\nInspIRCd is now running!\n");
+ printf("\nInspIRCd is now running!\n");
if (!Config->nofork)
{
@@ -857,7 +857,7 @@ int main(int argc, char** argv)
{
ServerInstance = new InspIRCd(argc, argv);
ServerInstance->Run();
- delete ServerInstance;
+ delete ServerInstance;
}
catch (std::bad_alloc)
{
diff --git a/src/message.cpp b/src/message.cpp
index 96e4b3141..1cc97743b 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -223,14 +223,14 @@ void ChangeName(userrec* user, const char* gecos)
void ChangeDisplayedHost(userrec* user, const char* host)
{
- if (user->fd > -1)
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnChangeLocalUserHost,OnChangeLocalUserHost(user,host));
- if (MOD_RESULT)
- return;
+ if (user->fd > -1)
+ {
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnChangeLocalUserHost,OnChangeLocalUserHost(user,host));
+ if (MOD_RESULT)
+ return;
FOREACH_MOD(I_OnChangeHost,OnChangeHost(user,host));
- }
+ }
strlcpy(user->dhost,host,63);
WriteServ(user->fd,"396 %s %s :is now your hidden host",user->nick,user->dhost);
}
@@ -239,23 +239,23 @@ void ChangeDisplayedHost(userrec* user, const char* host)
int isident(const char* n)
{
- if (!n || !*n)
- {
- return 0;
- }
- for (char* i = (char*)n; *i; i++)
- {
- if ((*i >= 'A') && (*i <= '}'))
- {
- continue;
- }
- if (strchr(".-0123456789",*i))
- {
- continue;
- }
+ if (!n || !*n)
+ {
return 0;
- }
- return 1;
+ }
+ for (char* i = (char*)n; *i; i++)
+ {
+ if ((*i >= 'A') && (*i <= '}'))
+ {
+ continue;
+ }
+ if (strchr(".-0123456789",*i))
+ {
+ continue;
+ }
+ return 0;
+ }
+ return 1;
}
diff --git a/src/mode.cpp b/src/mode.cpp
index 5d93eb161..cdf73350f 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -3,7 +3,7 @@
* +------------------------------------+
*
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- * E-mail:
+ * E-mail:
* <brain@chatspike.net>
* <Craig@chatspike.net>
*
@@ -390,10 +390,10 @@ char* ModeParser::TakeBan(userrec *user,char *dest,chanrec *chan,int status)
{
if (!strcasecmp(i->data,dest))
{
- int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnDelBan,OnDelBan(user,chan,dest));
- if (MOD_RESULT)
- return NULL;
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnDelBan,OnDelBan(user,chan,dest));
+ if (MOD_RESULT)
+ return NULL;
chan->bans.erase(i);
return dest;
}
@@ -533,10 +533,10 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
}
else
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'o', parameters[param], false, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'o', parameters[param], false, 1));
+ if (!MOD_RESULT)
+ {
r = TakeOps(user,parameters[param++],chan,status);
}
else param++;
@@ -553,20 +553,20 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
r = NULL;
if (mdir == 1)
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'h', parameters[param], true, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'h', parameters[param], true, 1));
+ if (!MOD_RESULT)
+ {
r = GiveHops(user,parameters[param++],chan,status);
}
else param++;
}
else
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'h', parameters[param], false, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'h', parameters[param], false, 1));
+ if (!MOD_RESULT)
+ {
r = TakeHops(user,parameters[param++],chan,status);
}
else param++;
@@ -584,20 +584,20 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
r = NULL;
if (mdir == 1)
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'v', parameters[param], true, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'v', parameters[param], true, 1));
+ if (!MOD_RESULT)
+ {
r = GiveVoice(user,parameters[param++],chan,status);
}
else param++;
}
else
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'v', parameters[param], false, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'v', parameters[param], false, 1));
+ if (!MOD_RESULT)
+ {
r = TakeVoice(user,parameters[param++],chan,status);
}
else param++;
@@ -614,20 +614,20 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
r = NULL;
if (mdir == 1)
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'b', parameters[param], true, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'b', parameters[param], true, 1));
+ if (!MOD_RESULT)
+ {
r = AddBan(user,parameters[param++],chan,status);
}
else param++;
}
else
{
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'b', parameters[param], false, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'b', parameters[param], false, 1));
+ if (!MOD_RESULT)
+ {
r = TakeBan(user,parameters[param++],chan,status);
}
else param++;
@@ -703,10 +703,10 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
if (previously_set_l)
break;
previously_unset_l = true;
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'l', "", false, 0));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'l', "", false, 0));
+ if (!MOD_RESULT)
+ {
if (chan->modes[CM_LIMIT])
{
*outl++ = 'l';
@@ -741,10 +741,10 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
if (invalid)
break;
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'l', parameters[param], true, 1));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'l', parameters[param], true, 1));
+ if (!MOD_RESULT)
+ {
chan->limit = atoi(parameters[param]);
@@ -764,10 +764,10 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
break;
case 'i':
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'i', "", mdir, 0));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'i', "", mdir, 0));
+ if (!MOD_RESULT)
+ {
if (mdir)
{
if (!(chan->modes[CM_INVITEONLY])) *outl++ = 'i';
@@ -782,82 +782,82 @@ void ModeParser::ProcessModes(char **parameters,userrec* user,chanrec *chan,int
break;
case 't':
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 't', "", mdir, 0));
- if (!MOD_RESULT)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 't', "", mdir, 0));
+ if (!MOD_RESULT)
+ {
if (mdir)
- {
+ {
if (!(chan->modes[CM_TOPICLOCK])) *outl++ = 't';
- chan->modes[CM_TOPICLOCK] = 1;
- }
- else
- {
+ chan->modes[CM_TOPICLOCK] = 1;
+ }
+ else
+ {
if (chan->modes[CM_TOPICLOCK]) *outl++ = 't';
- chan->modes[CM_TOPICLOCK] = 0;
- }
+ chan->modes[CM_TOPICLOCK] = 0;
+ }
}
break;
case 'n':
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'n', "", mdir, 0));
- if (!MOD_RESULT)
- {
- if (mdir)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'n', "", mdir, 0));
+ if (!MOD_RESULT)
+ {
+ if (mdir)
+ {
if (!(chan->modes[CM_NOEXTERNAL])) *outl++ = 'n';
- chan->modes[CM_NOEXTERNAL] = 1;
- }
- else
- {
+ chan->modes[CM_NOEXTERNAL] = 1;
+ }
+ else
+ {
if (chan->modes[CM_NOEXTERNAL]) *outl++ = 'n';
- chan->modes[CM_NOEXTERNAL] = 0;
- }
+ chan->modes[CM_NOEXTERNAL] = 0;
+ }
}
break;
case 'm':
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'm', "", mdir, 0));
- if (!MOD_RESULT)
- {
- if (mdir)
- {
- if (!(chan->modes[CM_MODERATED])) *outl++ = 'm';
- chan->modes[CM_MODERATED] = 1;
- }
- else
- {
- if (chan->modes[CM_MODERATED]) *outl++ = 'm';
- chan->modes[CM_MODERATED] = 0;
- }
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 'm', "", mdir, 0));
+ if (!MOD_RESULT)
+ {
+ if (mdir)
+ {
+ if (!(chan->modes[CM_MODERATED])) *outl++ = 'm';
+ chan->modes[CM_MODERATED] = 1;
+ }
+ else
+ {
+ if (chan->modes[CM_MODERATED]) *outl++ = 'm';
+ chan->modes[CM_MODERATED] = 0;
+ }
}
break;
case 's':
- MOD_RESULT = 0;
- FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 's', "", mdir, 0));
- if (!MOD_RESULT)
- {
- if (mdir)
- {
- if (!(chan->modes[CM_SECRET])) *outl++ = 's';
- chan->modes[CM_SECRET] = 1;
- if (chan->modes[CM_PRIVATE])
- {
- chan->modes[CM_PRIVATE] = 0;
- if (mdir)
- {
+ MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnRawMode,OnRawMode(user, chan, 's', "", mdir, 0));
+ if (!MOD_RESULT)
+ {
+ if (mdir)
+ {
+ if (!(chan->modes[CM_SECRET])) *outl++ = 's';
+ chan->modes[CM_SECRET] = 1;
+ if (chan->modes[CM_PRIVATE])
+ {
+ chan->modes[CM_PRIVATE] = 0;
+ if (mdir)
+ {
*outl++ = '-'; *outl++ = 'p'; *outl++ = '+';
- }
- }
- }
- else
- {
- if (chan->modes[CM_SECRET]) *outl++ = 's';
- chan->modes[CM_SECRET] = 0;
- }
+ }
+ }
+ }
+ else
+ {
+ if (chan->modes[CM_SECRET]) *outl++ = 's';
+ chan->modes[CM_SECRET] = 0;
+ }
}
break;
@@ -1431,8 +1431,8 @@ void ModeParser::ServerMode(char **parameters, int pcnt, userrec *user)
if ((dest) && (pcnt > 1))
{
- std::string tidied = ServerInstance->ModeGrok->CompressModes(parameters[1],false);
- parameters[1] = (char*)tidied.c_str();
+ std::string tidied = ServerInstance->ModeGrok->CompressModes(parameters[1],false);
+ parameters[1] = (char*)tidied.c_str();
char dmodes[MAXBUF];
strlcpy(dmodes,dest->modes,MAXBUF);
@@ -1451,8 +1451,8 @@ void ModeParser::ServerMode(char **parameters, int pcnt, userrec *user)
switch (*i)
{
- case ' ':
- continue;
+ case ' ':
+ continue;
case '+':
if ((direction != 1) && (next_ok))
@@ -1487,20 +1487,20 @@ void ModeParser::ServerMode(char **parameters, int pcnt, userrec *user)
{
charlcat(dmodes,*i,MAXBUF);
charlcat(outpars,*i,53);
- switch (*i)
- {
- case 'i':
- dest->modebits |= UM_INVISIBLE;
- break;
- case 's':
- dest->modebits |= UM_SERVERNOTICE;
- break;
- case 'w':
- dest->modebits |= UM_WALLOPS;
- break;
- default:
- break;
- }
+ switch (*i)
+ {
+ case 'i':
+ dest->modebits |= UM_INVISIBLE;
+ break;
+ case 's':
+ dest->modebits |= UM_SERVERNOTICE;
+ break;
+ case 'w':
+ dest->modebits |= UM_WALLOPS;
+ break;
+ default:
+ break;
+ }
}
}
}
@@ -1515,20 +1515,20 @@ void ModeParser::ServerMode(char **parameters, int pcnt, userrec *user)
{
charlcat(outpars,*i,MAXBUF);
charremove(dmodes,*i);
- switch (*i)
- {
- case 'i':
- dest->modebits &= ~UM_INVISIBLE;
- break;
- case 's':
- dest->modebits &= ~UM_SERVERNOTICE;
- break;
- case 'w':
- dest->modebits &= ~UM_WALLOPS;
- break;
- default:
- break;
- }
+ switch (*i)
+ {
+ case 'i':
+ dest->modebits &= ~UM_INVISIBLE;
+ break;
+ case 's':
+ dest->modebits &= ~UM_SERVERNOTICE;
+ break;
+ case 'w':
+ dest->modebits &= ~UM_WALLOPS;
+ break;
+ default:
+ break;
+ }
}
}
}
@@ -1536,43 +1536,43 @@ void ModeParser::ServerMode(char **parameters, int pcnt, userrec *user)
break;
}
}
- if (*outpars)
- {
- char b[MAXBUF];
- char* z = b;
-
- for (char* i = outpars; *i;)
- {
- *z++ = *i++;
- if (((*i == '-') || (*i == '+')) && ((*(i+1) == '-') || (*(i+1) == '+')))
- {
- // someones playing silly buggers and trying
- // to put a +- or -+ into the line...
- i++;
- }
- if (!*(i+1))
- {
- // Someone's trying to make the last character in
- // the line be a + or - symbol.
- if ((*i == '-') || (*i == '+'))
- {
- i++;
- }
- }
- }
- *z = 0;
-
- if ((*b) && (!IS_SINGLE(b,'+')) && (!IS_SINGLE(b,'-')))
- {
- WriteTo(user, dest, "MODE %s :%s", dest->nick, b);
- FOREACH_MOD(I_OnMode,OnMode(user, dest, TYPE_USER, b));
- }
-
- log(DEBUG,"Stripped mode line");
- log(DEBUG,"Line dest is now %s",dmodes);
- strlcpy(dest->modes,dmodes,MAXMODES-1);
-
- }
+ if (*outpars)
+ {
+ char b[MAXBUF];
+ char* z = b;
+
+ for (char* i = outpars; *i;)
+ {
+ *z++ = *i++;
+ if (((*i == '-') || (*i == '+')) && ((*(i+1) == '-') || (*(i+1) == '+')))
+ {
+ // someones playing silly buggers and trying
+ // to put a +- or -+ into the line...
+ i++;
+ }
+ if (!*(i+1))
+ {
+ // Someone's trying to make the last character in
+ // the line be a + or - symbol.
+ if ((*i == '-') || (*i == '+'))
+ {
+ i++;
+ }
+ }
+ }
+ *z = 0;
+
+ if ((*b) && (!IS_SINGLE(b,'+')) && (!IS_SINGLE(b,'-')))
+ {
+ WriteTo(user, dest, "MODE %s :%s", dest->nick, b);
+ FOREACH_MOD(I_OnMode,OnMode(user, dest, TYPE_USER, b));
+ }
+
+ log(DEBUG,"Stripped mode line");
+ log(DEBUG,"Line dest is now %s",dmodes);
+ strlcpy(dest->modes,dmodes,MAXMODES-1);
+
+ }
return;
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 680bd950a..2a7b2696f 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -324,12 +324,12 @@ void Server::AddSocket(InspSocket* sock)
void Server::RemoveSocket(InspSocket* sock)
{
- for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
- {
- InspSocket* s = (InspSocket*)*a;
- if (s == sock)
+ for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
+ {
+ InspSocket* s = (InspSocket*)*a;
+ if (s == sock)
s->MarkAsClosed();
- }
+ }
}
long Server::PriorityAfter(const std::string &modulename)
@@ -704,8 +704,8 @@ bool Server::UserToPseudo(userrec* user, const std::string &message)
}
ServerInstance->SE->DelFd(old_fd);
- shutdown(old_fd,2);
- close(old_fd);
+ shutdown(old_fd,2);
+ close(old_fd);
return true;
}
@@ -722,29 +722,29 @@ bool Server::PseudoToUser(userrec* alive, userrec* zombie, const std::string &me
std::string oldhost = alive->host;
std::string oldident = alive->ident;
kill_link(alive,message.c_str());
- if (find(local_users.begin(),local_users.end(),alive) != local_users.end())
- {
+ if (find(local_users.begin(),local_users.end(),alive) != local_users.end())
+ {
local_users.erase(find(local_users.begin(),local_users.end(),alive));
log(DEBUG,"Delete local user");
- }
+ }
// Fix by brain - cant write the user until their fd table entry is updated
fd_ref_table[zombie->fd] = zombie;
Write(zombie->fd,":%s!%s@%s NICK %s",oldnick.c_str(),oldident.c_str(),oldhost.c_str(),zombie->nick);
- for (std::vector<ucrec*>::const_iterator i = zombie->chans.begin(); i != zombie->chans.end(); i++)
- {
- if (((ucrec*)(*i))->channel != NULL)
- {
+ for (std::vector<ucrec*>::const_iterator i = zombie->chans.begin(); i != zombie->chans.end(); i++)
+ {
+ if (((ucrec*)(*i))->channel != NULL)
+ {
chanrec* Ptr = ((ucrec*)(*i))->channel;
WriteFrom(zombie->fd,zombie,"JOIN %s",Ptr->name);
- if (Ptr->topicset)
- {
- WriteServ(zombie->fd,"332 %s %s :%s", zombie->nick, Ptr->name, Ptr->topic);
- WriteServ(zombie->fd,"333 %s %s %s %d", zombie->nick, Ptr->name, Ptr->setby, Ptr->topicset);
- }
- userlist(zombie,Ptr);
- WriteServ(zombie->fd,"366 %s %s :End of /NAMES list.", zombie->nick, Ptr->name);
- }
- }
+ if (Ptr->topicset)
+ {
+ WriteServ(zombie->fd,"332 %s %s :%s", zombie->nick, Ptr->name, Ptr->topic);
+ WriteServ(zombie->fd,"333 %s %s %s %d", zombie->nick, Ptr->name, Ptr->setby, Ptr->topicset);
+ }
+ userlist(zombie,Ptr);
+ WriteServ(zombie->fd,"366 %s %s :End of /NAMES list.", zombie->nick, Ptr->name);
+ }
+ }
if ((find(local_users.begin(),local_users.end(),zombie) == local_users.end()) && (zombie->fd != FD_MAGIC_NUMBER))
local_users.push_back(zombie);
@@ -806,31 +806,35 @@ long Server::CalcDuration(const std::string &delta)
return duration(delta.c_str());
}
+/*
+ * XXX why on *earth* is this in modules.cpp...? I think
+ * perhaps we need a server.cpp for Server:: stuff where possible. -- w00t
+ */
bool Server::IsValidMask(const std::string &mask)
{
char* dest = (char*)mask.c_str();
- if (strchr(dest,'!')==0)
- return false;
- if (strchr(dest,'@')==0)
- return false;
- for (char* i = dest; *i; i++)
- if (*i < 32)
- return false;
- for (char* i = dest; *i; i++)
- if (*i > 126)
- return false;
- unsigned int c = 0;
- for (char* i = dest; *i; i++)
- if (*i == '!')
- c++;
- if (c>1)
- return false;
- c = 0;
- for (char* i = dest; *i; i++)
- if (*i == '@')
- c++;
- if (c>1)
- return false;
+ if (strchr(dest,'!')==0)
+ return false;
+ if (strchr(dest,'@')==0)
+ return false;
+ for (char* i = dest; *i; i++)
+ if (*i < 32)
+ return false;
+ for (char* i = dest; *i; i++)
+ if (*i > 126)
+ return false;
+ unsigned int c = 0;
+ for (char* i = dest; *i; i++)
+ if (*i == '!')
+ c++;
+ if (c>1)
+ return false;
+ c = 0;
+ for (char* i = dest; *i; i++)
+ if (*i == '@')
+ c++;
+ if (c>1)
+ return false;
return true;
}
diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp
index ade243fb4..267fc71b4 100644
--- a/src/modules/extra/m_filter_pcre.cpp
+++ b/src/modules/extra/m_filter_pcre.cpp
@@ -95,10 +95,10 @@ class ModuleFilterPCRE : public Module
delete Conf;
}
- void Implements(char* List)
- {
- List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnRehash] = 1;
- }
+ void Implements(char* List)
+ {
+ List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnRehash] = 1;
+ }
// format of a config entry is <keyword pattern="^regexp$" reason="Some reason here" action="kill/block">
@@ -170,22 +170,22 @@ class ModuleFilterPCRE : public Module
}
Srv->Log(DEFAULT,std::string("m_filter_pcre: read configuration from ")+filterfile);
- filters.clear();
- for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
- {
- std::string pattern = MyConf->ReadValue("keyword","pattern",index);
- re = pcre_compile(pattern.c_str(),0,&error,&erroffset,NULL);
- if (!re)
- {
- log(DEFAULT,"Error in regular expression: %s at offset %d: %s\n", pattern.c_str(), erroffset, error);
- log(DEFAULT,"Regular expression %s not loaded.", pattern.c_str());
- }
- else
- {
- filters.push_back(re);
- log(DEFAULT,"Regular expression %s loaded.", pattern.c_str());
- }
- }
+ filters.clear();
+ for (int index = 0; index < MyConf->Enumerate("keyword"); index++)
+ {
+ std::string pattern = MyConf->ReadValue("keyword","pattern",index);
+ re = pcre_compile(pattern.c_str(),0,&error,&erroffset,NULL);
+ if (!re)
+ {
+ log(DEFAULT,"Error in regular expression: %s at offset %d: %s\n", pattern.c_str(), erroffset, error);
+ log(DEFAULT,"Regular expression %s not loaded.", pattern.c_str());
+ }
+ else
+ {
+ filters.push_back(re);
+ log(DEFAULT,"Regular expression %s loaded.", pattern.c_str());
+ }
+ }
}
diff --git a/src/modules/extra/m_sql.cpp b/src/modules/extra/m_sql.cpp
index 515ce792d..ef3fbf21d 100644
--- a/src/modules/extra/m_sql.cpp
+++ b/src/modules/extra/m_sql.cpp
@@ -92,15 +92,15 @@ class SQLConnection
// the number of effected rows is returned in the return value.
unsigned long QueryCount(std::string query)
{
- int r = mysql_query(&connection, query.c_str());
- if (!r)
- {
- res = mysql_store_result(&connection);
- unsigned long rows = mysql_affected_rows(&connection);
- mysql_free_result(res);
- return rows;
- }
- return 0;
+ int r = mysql_query(&connection, query.c_str());
+ if (!r)
+ {
+ res = mysql_store_result(&connection);
+ unsigned long rows = mysql_affected_rows(&connection);
+ mysql_free_result(res);
+ return rows;
+ }
+ return 0;
}
// This method fetches a row, if available from the database. You must issue a query
diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp
index c9a86e9bc..845c3e0d9 100644
--- a/src/modules/extra/m_sqllog.cpp
+++ b/src/modules/extra/m_sqllog.cpp
@@ -57,8 +57,7 @@ class ModuleSQLLog : public Module
return (SQLModule);
}
- ModuleSQLLog(Server* Me)
- : Module::Module(Me)
+ ModuleSQLLog(Server* Me) : Module::Module(Me)
{
Srv = Me;
ReadConfig();
@@ -67,7 +66,7 @@ class ModuleSQLLog : public Module
void Implements(char* List)
{
List[I_OnRehash] = List[I_OnOper] = List[I_OnGlobalOper] = List[I_OnKill] = 1;
- List[I_OnPreCommand] = List[I_OnUserConnect] = List[I_OnGlobalConnect] = 1;
+ List[I_OnPreCommand] = List[I_OnUserConnect] = List[I_OnGlobalConnect] = 1;
List[I_OnUserQuit] = List[I_OnLoadModule] = 1;
}
@@ -79,40 +78,49 @@ class ModuleSQLLog : public Module
long InsertNick(const std::string &nick)
{
long nid = -1;
- SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT id,actor FROM ircd_log_actors WHERE actor='"+nick+"'");
- Request queryrequest((char*)query, this, SQLModule);
- SQLResult* result = (SQLResult*)queryrequest.Send();
- if (result->GetType() == SQL_OK)
- {
- SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,"");
- Request rowquery((char*)rowrequest, this, SQLModule);
- SQLResult* rowresult = (SQLResult*)rowquery.Send();
- if (rowresult->GetType() == SQL_ROW)
- {
- nid = atoi(rowresult->GetField("id").c_str());
- delete rowresult;
- }
- delete rowrequest;
- delete result;
- }
- query->SetQueryType(SQL_DONE);
- query->SetConnID(dbid);
- Request donerequest((char*)query, this, SQLModule);
- donerequest.Send();
- delete query;
+
+ SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT id,actor FROM ircd_log_actors WHERE actor='"+nick+"'");
+ Request queryrequest((char*)query, this, SQLModule);
+ SQLResult* result = (SQLResult*)queryrequest.Send();
+
+ if (result->GetType() == SQL_OK)
+ {
+ SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,"");
+ Request rowquery((char*)rowrequest, this, SQLModule);
+ SQLResult* rowresult = (SQLResult*)rowquery.Send();
+
+ if (rowresult->GetType() == SQL_ROW)
+ {
+ nid = atoi(rowresult->GetField("id").c_str());
+ delete rowresult;
+ }
+
+ delete rowrequest;
+ delete result;
+ }
+
+ query->SetQueryType(SQL_DONE);
+ query->SetConnID(dbid);
+ Request donerequest((char*)query, this, SQLModule);
+ donerequest.Send();
+ delete query;
+
if (nid < 1)
{
SQLRequest* query2 = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_actors VALUES('','"+nick+"')");
Request queryrequest2((char*)query2, this, SQLModule);
SQLResult* result2 = (SQLResult*)queryrequest2.Send();
- if (result2->GetType() == SQL_ERROR)
- {
- Srv->Log(DEFAULT,"SQL log error: " + result2->GetError());
- }
+
+ if (result2->GetType() == SQL_ERROR)
+ {
+ Srv->Log(DEFAULT,"SQL log error: " + result2->GetError());
+ }
+
if (result2)
delete result;
if (query2)
delete query2;
+
nid = InsertNick(nick);
}
return nid;
@@ -121,61 +129,74 @@ class ModuleSQLLog : public Module
void InsertEntry(unsigned long category,unsigned long nickid,unsigned long hostid,unsigned long sourceid,unsigned long date)
{
char querybuffer[MAXBUF];
+
snprintf(querybuffer,MAXBUF,"INSERT INTO ircd_log VALUES('',%lu,%lu,%lu,%lu,%lu)",(unsigned long)category,(unsigned long)nickid,(unsigned long)hostid,(unsigned long)sourceid,(unsigned long)date);
SQLRequest* query = new SQLRequest(SQL_COUNT,dbid,querybuffer);
Request queryrequest((char*)query, this, SQLModule);
SQLResult* result = (SQLResult*)queryrequest.Send();
+
if (result->GetType() == SQL_ERROR)
{
Srv->Log(DEFAULT,"SQL log error: " + result->GetError());
}
+
if (result)
delete result;
if (query)
delete query;
+
return;
}
long InsertHost(const std::string &host)
{
- long hid = -1;
- SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT id,hostname FROM ircd_log_hosts WHERE hostname='"+host+"'");
- Request queryrequest((char*)query, this, SQLModule);
- SQLResult* result = (SQLResult*)queryrequest.Send();
- if (result->GetType() == SQL_OK)
- {
- SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,"");
- Request rowquery((char*)rowrequest, this, SQLModule);
- SQLResult* rowresult = (SQLResult*)rowquery.Send();
- if (rowresult->GetType() == SQL_ROW)
- {
- hid = atoi(rowresult->GetField("id").c_str());
- delete rowresult;
- }
- delete rowrequest;
- delete result;
- }
- query->SetQueryType(SQL_DONE);
- query->SetConnID(dbid);
- Request donerequest((char*)query, this, SQLModule);
- donerequest.Send();
- delete query;
- if (hid < 1)
- {
- SQLRequest* query2 = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_hosts VALUES('','"+host+"')");
- Request queryrequest2((char*)query2, this, SQLModule);
- SQLResult* result2 = (SQLResult*)queryrequest2.Send();
- if (result2->GetType() == SQL_ERROR)
- {
- Srv->Log(DEFAULT,"SQL log error: " + result2->GetError());
- }
- if (result)
- delete result2;
+ long hid = -1;
+
+ SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT id,hostname FROM ircd_log_hosts WHERE hostname='"+host+"'");
+ Request queryrequest((char*)query, this, SQLModule);
+ SQLResult* result = (SQLResult*)queryrequest.Send();
+
+ if (result->GetType() == SQL_OK)
+ {
+ SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,"");
+ Request rowquery((char*)rowrequest, this, SQLModule);
+ SQLResult* rowresult = (SQLResult*)rowquery.Send();
+
+ if (rowresult->GetType() == SQL_ROW)
+ {
+ hid = atoi(rowresult->GetField("id").c_str());
+ delete rowresult;
+ }
+
+ delete rowrequest;
+ delete result;
+ }
+
+ query->SetQueryType(SQL_DONE);
+ query->SetConnID(dbid);
+ Request donerequest((char*)query, this, SQLModule);
+ donerequest.Send();
+ delete query;
+
+ if (hid < 1)
+ {
+ SQLRequest* query2 = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_hosts VALUES('','"+host+"')");
+ Request queryrequest2((char*)query2, this, SQLModule);
+ SQLResult* result2 = (SQLResult*)queryrequest2.Send();
+
+ if (result2->GetType() == SQL_ERROR)
+ {
+ Srv->Log(DEFAULT,"SQL log error: " + result2->GetError());
+ }
+
+ if (result)
+ delete result2;
if (query)
delete query2;
- hid = InsertHost(host);
- }
- return hid;
+ hid = InsertHost(host);
+ }
+
+ return hid;
}
void AddLogEntry(int category, const std::string &nick, const std::string &host, const std::string &source)
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 109be1e3d..27e6e3f02 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -189,7 +189,7 @@ class ModuleSSLOpenSSL : public Module
{
log(DEFAULT, "m_ssl_openssl.so: Can't read CA list from ", cafile.c_str());
}
-
+
FILE* dhpfile = fopen(dhfile.c_str(), "r");
DH* ret;
diff --git a/src/modules/m_antibottler.cpp b/src/modules/m_antibottler.cpp
index 89effc607..58ee0b5d6 100644
--- a/src/modules/m_antibottler.cpp
+++ b/src/modules/m_antibottler.cpp
@@ -33,10 +33,10 @@ class ModuleAntiBottler : public Module
Srv = Me;
}
- void Implements(char* List)
- {
- List[I_OnServerRaw] = 1;
- }
+ void Implements(char* List)
+ {
+ List[I_OnServerRaw] = 1;
+ }
virtual ~ModuleAntiBottler()
diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp
index 03b4f0f9d..ee1a63424 100644
--- a/src/modules/m_censor.cpp
+++ b/src/modules/m_censor.cpp
@@ -3,7 +3,7 @@
* +------------------------------------+
*
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- * E-mail:
+ * E-mail:
* <brain@chatspike.net>
* <Craig@chatspike.net>
*
@@ -70,10 +70,10 @@ class ModuleCensor : public Module
}
- virtual void On005Numeric(std::string &output)
- {
+ virtual void On005Numeric(std::string &output)
+ {
InsertMode(output,"G",4);
- }
+ }
virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
@@ -158,10 +158,10 @@ class ModuleCensor : public Module
throw(e);
}
censors.clear();
- for (int index = 0; index < MyConf->Enumerate("badword"); index++)
- {
- irc::string pattern = (MyConf->ReadValue("badword","text",index)).c_str();
- irc::string replace = (MyConf->ReadValue("badword","replace",index)).c_str();
+ for (int index = 0; index < MyConf->Enumerate("badword"); index++)
+ {
+ irc::string pattern = (MyConf->ReadValue("badword","text",index)).c_str();
+ irc::string replace = (MyConf->ReadValue("badword","replace",index)).c_str();
censors[pattern] = replace;
}
delete Conf;
diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp
index 90f564ee1..9e8d36ff8 100644
--- a/src/modules/m_chanfilter.cpp
+++ b/src/modules/m_chanfilter.cpp
@@ -53,10 +53,10 @@ class ModuleChanFilter : public Module
List[I_On005Numeric] = List[I_OnUserPart] = List[I_OnRehash] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnExtendedMode] = List[I_OnSendList] = List[I_OnSyncChannel] = 1;
}
- virtual void On005Numeric(std::string &output)
- {
+ virtual void On005Numeric(std::string &output)
+ {
InsertMode(output,"g",1);
- }
+ }
virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partreason)
{
@@ -80,8 +80,8 @@ class ModuleChanFilter : public Module
MaxEntries = Conf->ReadInteger("chanfilter","maxsize",0,true);
}
- virtual int ProcessMessages(userrec* user,chanrec* chan,std::string &text)
- {
+ virtual int ProcessMessages(userrec* user,chanrec* chan,std::string &text)
+ {
// Create a copy of the string in irc::string
irc::string line = text.c_str();
diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp
index b7d67d9ae..b6f277c03 100644
--- a/src/modules/m_chanprotect.cpp
+++ b/src/modules/m_chanprotect.cpp
@@ -59,10 +59,10 @@ class ModuleChanProtect : public Module
List[I_On005Numeric] = List[I_OnUserKick] = List[I_OnUserPart] = List[I_OnRehash] = List[I_OnUserJoin] = List[I_OnAccessCheck] = List[I_OnExtendedMode] = List[I_OnSendList] = List[I_OnSyncChannel] = 1;
}
- virtual void On005Numeric(std::string &output)
- {
+ virtual void On005Numeric(std::string &output)
+ {
InsertMode(output,"qa",1);
- }
+ }
virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason)
{
@@ -301,18 +301,18 @@ class ModuleChanProtect : public Module
}
WriteServ(user->fd,"387 %s %s :End of channel founder list",user->nick, channel->name);
}
- if (mode == 'a')
- {
- chanuserlist cl = Srv->GetUsers(channel);
- for (unsigned int i = 0; i < cl.size(); i++)
- {
- if (cl[i]->GetExt("cm_protect_"+std::string(channel->name)))
- {
- WriteServ(user->fd,"388 %s %s %s",user->nick, channel->name,cl[i]->nick);
- }
- }
+ if (mode == 'a')
+ {
+ chanuserlist cl = Srv->GetUsers(channel);
+ for (unsigned int i = 0; i < cl.size(); i++)
+ {
+ if (cl[i]->GetExt("cm_protect_"+std::string(channel->name)))
+ {
+ WriteServ(user->fd,"388 %s %s %s",user->nick, channel->name,cl[i]->nick);
+ }
+ }
WriteServ(user->fd,"389 %s %s :End of channel protected user list",user->nick, channel->name);
- }
+ }
}
diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp
index d77ddf515..1a547f548 100644
--- a/src/modules/m_chghost.cpp
+++ b/src/modules/m_chghost.cpp
@@ -30,12 +30,12 @@ static Server *Srv;
class cmd_chghost : public command_t
{
public:
- cmd_chghost () : command_t("CHGHOST",'o',2)
- {
- this->source = "m_chghost.so";
- }
+ cmd_chghost () : command_t("CHGHOST",'o',2)
+ {
+ this->source = "m_chghost.so";
+ }
- void Handle(char **parameters, int pcnt, userrec *user)
+ void Handle(char **parameters, int pcnt, userrec *user)
{
char * x = parameters[1];
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index 92ae1af6c..4b9be01c4 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -368,22 +368,22 @@ class ModuleCloaking : public Module
this->GenHash(dest->host,ra);
std::string b = "";
in_addr testaddr;
- std::string hostcloak = prefix + "-" + std::string(ra) + a;
- /* Fix by brain - if the cloaked host is > the max length of a host (64 bytes
- * according to the DNS RFC) then tough titty, they get cloaked as an IP.
- * Their ISP shouldnt go to town on subdomains, or they shouldnt have a kiddie
- * vhost.
- */
- if ((!inet_aton(dest->host,&testaddr)) && (hostcloak.length() < 64))
- {
- // if they have a hostname, make something appropriate
- b = hostcloak;
- }
- else
- {
- // else, they have an ip
- b = std::string(ra) + "." + prefix + ".cloak";
- }
+ std::string hostcloak = prefix + "-" + std::string(ra) + a;
+ /* Fix by brain - if the cloaked host is > the max length of a host (64 bytes
+ * according to the DNS RFC) then tough titty, they get cloaked as an IP.
+ * Their ISP shouldnt go to town on subdomains, or they shouldnt have a kiddie
+ * vhost.
+ */
+ if ((!inet_aton(dest->host,&testaddr)) && (hostcloak.length() < 64))
+ {
+ // if they have a hostname, make something appropriate
+ b = hostcloak;
+ }
+ else
+ {
+ // else, they have an ip
+ b = std::string(ra) + "." + prefix + ".cloak";
+ }
Srv->Log(DEBUG,"cloak: allocated "+b);
Srv->ChangeHost(dest,b);
}
diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp
index c838a495d..cfa96e2b3 100644
--- a/src/modules/m_denychans.cpp
+++ b/src/modules/m_denychans.cpp
@@ -57,8 +57,8 @@ class ModuleDenyChannels : public Module
List[I_OnUserPreJoin] = List[I_OnRehash] = 1;
}
- virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
- {
+ virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
+ {
for (int j =0; j < Conf->Enumerate("badchan"); j++)
{
irc::string cn = Conf->ReadValue("badchan","name",j).c_str();
@@ -78,7 +78,7 @@ class ModuleDenyChannels : public Module
}
}
return 0;
- }
+ }
};
// stuff down here is the module-factory stuff. For basic modules you can ignore this.
diff --git a/src/modules/m_devoice.cpp b/src/modules/m_devoice.cpp
index 3ea72de39..75bc4c4f3 100644
--- a/src/modules/m_devoice.cpp
+++ b/src/modules/m_devoice.cpp
@@ -46,12 +46,12 @@ class cmd_devoice : public command_t
*
* - I'm not aware what checking I need, so for now... be supreme evil.
*/
- char* modes[3];
- modes[0] = parameters[0];
- modes[1] = "-v";
- modes[2] = user->nick;
+ char* modes[3];
+ modes[0] = parameters[0];
+ modes[1] = "-v";
+ modes[2] = user->nick;
- Srv->SendMode(modes,3,user);
+ Srv->SendMode(modes,3,user);
}
};
@@ -96,7 +96,7 @@ class ModuleDeVoiceFactory : public ModuleFactory
};
-extern "C" void * init_module( void )
+extern "C" void * devoice_init( void )
{
return new ModuleDeVoiceFactory;
}
diff --git a/src/modules/m_globalload.cpp b/src/modules/m_globalload.cpp
index 4456a1352..1cb14ba83 100644
--- a/src/modules/m_globalload.cpp
+++ b/src/modules/m_globalload.cpp
@@ -16,12 +16,7 @@
using namespace std;
-/*
- * DEVOICE module for InspIRCd
- * Syntax: /DEVOICE <#chan>
- */
-
-/* $ModDesc: Provides voiced users with the ability to devoice themselves. */
+/* $ModDesc: Allows global loading of a module. */
#include <stdio.h>
#include "users.h"
@@ -42,15 +37,15 @@ class cmd_gloadmodule : public command_t
void Handle (char **parameters, int pcnt, userrec *user)
{
- if (ServerInstance->LoadModule(parameters[0]))
- {
- WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
- WriteServ(user->fd,"975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
- }
- else
- {
- WriteServ(user->fd,"974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
- }
+ if (ServerInstance->LoadModule(parameters[0]))
+ {
+ WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
+ WriteServ(user->fd,"975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
+ }
+ else
+ {
+ WriteServ(user->fd,"974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
+ }
}
};
@@ -64,14 +59,14 @@ class cmd_gunloadmodule : public command_t
void Handle (char **parameters, int pcnt, userrec *user)
{
- if (ServerInstance->UnloadModule(parameters[0]))
- {
- WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
- WriteServ(user->fd,"973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
- }
+ if (ServerInstance->UnloadModule(parameters[0]))
+ {
+ WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
+ WriteServ(user->fd,"973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
+ }
else
{
- WriteServ(user->fd,"972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
+ WriteServ(user->fd,"972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
}
}
};
diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp
index 49dd99f67..a4a5a8b08 100644
--- a/src/modules/m_hostchange.cpp
+++ b/src/modules/m_hostchange.cpp
@@ -46,7 +46,7 @@ class ModuleHostChange : public Module
: Module::Module(Me)
{
Srv = Me;
- Conf = new ConfigReader;
+ Conf = new ConfigReader;
OnRehash("");
}
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index f11d6f330..2c6e40c8c 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -71,16 +71,16 @@ class RFC1413 : public InspSocket
if (section)
{
while (*section == ' ') section++; // strip leading spaces
- for (char* j = section; *j; j++)
- if ((*j < 33) || (*j > 126))
+ for (char* j = section; *j; j++)
+ if ((*j < 33) || (*j > 126))
*j = '\0'; // truncate at invalid chars
- if (*section)
- {
- strlcpy(u->ident,section,IDENTMAX);
- Srv->Log(DEBUG,"IDENT SET: "+std::string(u->ident));
- Srv->SendServ(u->fd,"NOTICE "+std::string(u->nick)+" :*** Found your ident: "+std::string(u->ident));
- }
- return false;
+ if (*section)
+ {
+ strlcpy(u->ident,section,IDENTMAX);
+ Srv->Log(DEBUG,"IDENT SET: "+std::string(u->ident));
+ Srv->SendServ(u->fd,"NOTICE "+std::string(u->nick)+" :*** Found your ident: "+std::string(u->ident));
+ }
+ return false;
}
}
}
@@ -158,10 +158,12 @@ class ModuleIdent : public Module
virtual void OnUserRegister(userrec* user)
{
- // when the new user connects, before they authenticate with USER/NICK/PASS, we do
- // their ident lookup. We do this by instantiating an object of type RFC1413, which
- // is derived from InspSocket, and inserting it into the socket engine using the
- // Server::AddSocket() call.
+ /*
+ * when the new user connects, before they authenticate with USER/NICK/PASS, we do
+ * their ident lookup. We do this by instantiating an object of type RFC1413, which
+ * is derived from InspSocket, and inserting it into the socket engine using the
+ * Server::AddSocket() call.
+ */
Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :*** Looking up your ident...");
RFC1413* ident = new RFC1413(user, IdentTimeout, Srv);
if (ident->GetState() != I_ERROR)
@@ -178,9 +180,11 @@ class ModuleIdent : public Module
virtual bool OnCheckReady(userrec* user)
{
- // The socket engine will clean up their ident request for us when it completes,
- // either due to timeout or due to closing, so, we just hold them until they dont
- // have an ident field any more.
+ /*
+ * The socket engine will clean up their ident request for us when it completes,
+ * either due to timeout or due to closing, so, we just hold them until they dont
+ * have an ident field any more.
+ */
RFC1413* ident = (RFC1413*)user->GetExt("ident_data");
return (!ident);
}
@@ -198,20 +202,22 @@ class ModuleIdent : public Module
}
}
- virtual void OnUserDisconnect(userrec* user)
- {
- // when the user quits tidy up any ident lookup they have pending to keep things tidy.
- // When we call RemoveSocket, the abstractions tied into the system evnetually work their
- // way to RFC1459::OnClose(), which shrinks off the ident_data for us, so we dont need
- // to do it here. If we don't tidy this up, there may still be lingering idents for users
- // who have quit, as class RFC1459 is only loosely bound to userrec* via a pair of pointers
- // and this would leave at least one of the invalid ;)
+ virtual void OnUserDisconnect(userrec* user)
+ {
+ /*
+ * when the user quits tidy up any ident lookup they have pending to keep things tidy.
+ * When we call RemoveSocket, the abstractions tied into the system evnetually work their
+ * way to RFC1459::OnClose(), which shrinks off the ident_data for us, so we dont need
+ * to do it here. If we don't tidy this up, there may still be lingering idents for users
+ * who have quit, as class RFC1459 is only loosely bound to userrec* via a pair of pointers
+ * and this would leave at least one of the invalid ;)
+ */
RFC1413* ident = (RFC1413*)user->GetExt("ident_data");
- if (ident)
- {
+ if (ident)
+ {
Srv->RemoveSocket(ident);
- }
- }
+ }
+ }
virtual ~ModuleIdent()
{
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index 9169cfd4c..c22fe5ff0 100644
--- a/src/modules/m_knock.cpp
+++ b/src/modules/m_knock.cpp
@@ -84,10 +84,10 @@ class ModuleKnock : public Module
List[I_On005Numeric] = List[I_OnExtendedMode] = 1;
}
- virtual void On005Numeric(std::string &output)
- {
+ virtual void On005Numeric(std::string &output)
+ {
InsertMode(output,"K",4);
- }
+ }
virtual ~ModuleKnock()
{
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index 681ba616a..36d2ea1be 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -198,12 +198,12 @@ class ModuleMsgFlood : public Module
}
}
- virtual void OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status)
+ virtual void OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status)
{
- if (target_type == TYPE_CHANNEL)
- {
- ProcessMessages(user,(chanrec*)dest,text);
- }
+ if (target_type == TYPE_CHANNEL)
+ {
+ ProcessMessages(user,(chanrec*)dest,text);
+ }
}
virtual void OnUserNotice(userrec* user, void* dest, int target_type, const std::string &text, char status)
diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp
index 42d233002..7d69a92b6 100644
--- a/src/modules/m_noctcp.cpp
+++ b/src/modules/m_noctcp.cpp
@@ -42,10 +42,10 @@ class ModuleNoCTCP : public Module
List[I_OnExtendedMode] = List[I_On005Numeric] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
}
- virtual void On005Numeric(std::string &output)
- {
+ virtual void On005Numeric(std::string &output)
+ {
InsertMode(output,"C",4);
- }
+ }
virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
{
diff --git a/src/modules/m_nokicks.cpp b/src/modules/m_nokicks.cpp
index be16da608..564ff86e6 100644
--- a/src/modules/m_nokicks.cpp
+++ b/src/modules/m_nokicks.cpp
@@ -42,10 +42,10 @@ class ModuleNoKicks : public Module
List[I_On005Numeric] = List[I_OnAccessCheck] = List[I_OnExtendedMode] = 1;
}
- virtual void On005Numeric(std::string &output)
- {
+ virtual void On005Numeric(std::string &output)
+ {
InsertMode(output,"Q",4);
- }
+ }
virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type)
{
diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp
index 78d10db33..e4e2b72f3 100644
--- a/src/modules/m_nonicks.cpp
+++ b/src/modules/m_nonicks.cpp
@@ -53,10 +53,10 @@ class ModuleNoNickChange : public Module
List[I_On005Numeric] = List[I_OnUserPreNick] = List[I_OnExtendedMode] = 1;
}
- virtual void On005Numeric(std::string &output)
- {
+ virtual void On005Numeric(std::string &output)
+ {
InsertMode(output,"N",4);
- }
+ }
virtual int OnUserPreNick(userrec* user, const std::string &newnick)
{
diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp
index 1e977d355..0a079e885 100644
--- a/src/modules/m_nonotice.cpp
+++ b/src/modules/m_nonotice.cpp
@@ -63,10 +63,10 @@ class ModuleNoNotice : public Module
return 0;
}
- virtual void On005Numeric(std::string &output)
- {
+ virtual void On005Numeric(std::string &output)
+ {
InsertMode(output,"T",4);
- }
+ }
virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
{
diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp
index 7ff66bdb2..01b55f9cc 100644
--- a/src/modules/m_operchans.cpp
+++ b/src/modules/m_operchans.cpp
@@ -66,10 +66,10 @@ class ModuleOperChans : public Module
return 0;
}
- virtual void On005Numeric(std::string &output)
- {
+ virtual void On005Numeric(std::string &output)
+ {
InsertMode(output,"O",4);
- }
+ }
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
{
diff --git a/src/modules/m_operjoin.cpp b/src/modules/m_operjoin.cpp
index cba931257..2517b385f 100644
--- a/src/modules/m_operjoin.cpp
+++ b/src/modules/m_operjoin.cpp
@@ -60,22 +60,22 @@ class ModuleOperjoin : public Module
class ModuleOperjoinFactory : public ModuleFactory
{
public:
- ModuleOperjoinFactory()
- {
- }
-
- ~ModuleOperjoinFactory()
- {
- }
-
- virtual Module * CreateModule(Server* Me)
- {
- return new ModuleOperjoin(Me);
- }
+ ModuleOperjoinFactory()
+ {
+ }
+
+ ~ModuleOperjoinFactory()
+ {
+ }
+
+ virtual Module * CreateModule(Server* Me)
+ {
+ return new ModuleOperjoin(Me);
+ }
};
extern "C" void * init_module( void )
{
- return new ModuleOperjoinFactory;
+ return new ModuleOperjoinFactory;
}
diff --git a/src/modules/m_operlevels.cpp b/src/modules/m_operlevels.cpp
index b4a76d5c0..8d545ade8 100644
--- a/src/modules/m_operlevels.cpp
+++ b/src/modules/m_operlevels.cpp
@@ -87,23 +87,23 @@ class ModuleOperLevels : public Module
class ModuleOperLevelsFactory : public ModuleFactory
{
public:
- ModuleOperLevelsFactory()
- {
- }
+ ModuleOperLevelsFactory()
+ {
+ }
- ~ModuleOperLevelsFactory()
- {
- }
+ ~ModuleOperLevelsFactory()
+ {
+ }
- virtual Module * CreateModule(Server* Me)
- {
- return new ModuleOperLevels(Me);
- }
+ virtual Module * CreateModule(Server* Me)
+ {
+ return new ModuleOperLevels(Me);
+ }
};
-extern "C" void * init_module( void )
+extern "C" void * operlevels_init( void )
{
- return new ModuleOperLevelsFactory;
+ return new ModuleOperLevelsFactory;
}
diff --git a/src/modules/m_opermodes.cpp b/src/modules/m_opermodes.cpp
index d99a7ad8a..6bf823d31 100644
--- a/src/modules/m_opermodes.cpp
+++ b/src/modules/m_opermodes.cpp
@@ -64,12 +64,12 @@ class ModuleModesOnOper : public Module
// whenever a user opers, go through the oper types, find their <type:modes>,
// and if they have one apply their modes. The mode string can contain +modes
// to add modes to the user or -modes to take modes from the user.
- for (int j =0; j < Conf->Enumerate("type"); j++)
- {
- std::string typen = Conf->ReadValue("type","name",j);
- if (!strcmp(typen.c_str(),user->oper))
- {
- std::string ThisOpersModes = Conf->ReadValue("type","modes",j);
+ for (int j =0; j < Conf->Enumerate("type"); j++)
+ {
+ std::string typen = Conf->ReadValue("type","name",j);
+ if (!strcmp(typen.c_str(),user->oper))
+ {
+ std::string ThisOpersModes = Conf->ReadValue("type","modes",j);
char first = *(ThisOpersModes.c_str());
if ((first != '+') && (first != '-'))
ThisOpersModes = "+" + ThisOpersModes;
@@ -80,9 +80,9 @@ class ModuleModesOnOper : public Module
modes[1] = (char*)ThisOpersModes.c_str();
Srv->SendMode(modes,2,user);
}
- break;
- }
- }
+ break;
+ }
+ }
}
};
diff --git a/src/modules/m_operwho.cpp b/src/modules/m_operwho.cpp
index 626c03df6..61832cd4b 100644
--- a/src/modules/m_operwho.cpp
+++ b/src/modules/m_operwho.cpp
@@ -165,7 +165,7 @@ class ModuleOperWho : public Module
}
if (*u->oper) { strlcat(tmp, "*" ,9); }
WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, u->chans.size() && ((ucrec*)*(u->chans.begin()))->channel ? ((ucrec*)*(u->chans.begin()))->channel->name
- : "*", u->ident, u->dhost, u->server, u->nick, tmp, u->fullname);
+ : "*", u->ident, u->dhost, u->server, u->nick, tmp, u->fullname);
}
WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
return 1;
@@ -173,10 +173,10 @@ class ModuleOperWho : public Module
}
if (pcnt == 2)
{
- if ((!strcmp(parameters[0],"0")) || (!strcmp(parameters[0],"*")) && (!strcmp(parameters[1],"o")))
- {
+ if ((!strcmp(parameters[0],"0")) || (!strcmp(parameters[0],"*")) && (!strcmp(parameters[1],"o")))
+ {
for (std::vector<userrec*>::iterator i = all_opers.begin(); i != all_opers.end(); i++)
- {
+ {
// If i were a rich man.. I wouldn't need to me making these bugfixes..
// But i'm a poor bastard with nothing better to do.
userrec* oper = *i;
@@ -186,12 +186,12 @@ class ModuleOperWho : public Module
} else {
strlcat(tmp, "H" ,9);
}
- WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans.size() && ((ucrec*)*(oper->chans.begin()))->channel ?
+ WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans.size() && ((ucrec*)*(oper->chans.begin()))->channel ?
((ucrec*)*(oper->chans.begin()))->channel->name : "*", oper->ident, oper->host, oper->server, oper->nick, tmp, oper->fullname);
- }
- WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
- return 1;
- }
+ }
+ WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
+ return 1;
+ }
}
return 0;
}
diff --git a/src/modules/m_park.cpp b/src/modules/m_park.cpp
index 4cd163af1..935efa39c 100644
--- a/src/modules/m_park.cpp
+++ b/src/modules/m_park.cpp
@@ -69,7 +69,7 @@ class cmd_park : public command_t
int othersessions = 0;
/* XXX - why can't just use pinfo.size() like we do below, rather than iterating over the whole vector? -- w00t */
if (pinfo.size())
- for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
+ for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
if (j->host == std::string(user->host))
othersessions++;
if (othersessions >= ConcurrentParks)
@@ -153,8 +153,8 @@ class cmd_unpark : public command_t
if (key == atoi(parameters[1]))
{
// first part the user from all chans theyre on, so things dont get messy
- for (std::vector<ucrec*>::iterator i = user->chans.begin(); i != user->chans.end(); i++)
- {
+ for (std::vector<ucrec*>::iterator i = user->chans.begin(); i != user->chans.end(); i++)
+ {
if (((ucrec*)(*i))->channel != NULL)
{
Srv->PartUserFromChannel(user,((ucrec*)(*i))->channel->name,"Unparking");
@@ -240,24 +240,24 @@ class ModulePark : public Module
this->ReadSettings();
}
- virtual void On005Numeric(std::string &output)
- {
- output = output + std::string(" PARK");
- }
+ virtual void On005Numeric(std::string &output)
+ {
+ output = output + std::string(" PARK");
+ }
- virtual void OnUserQuit(userrec* user, const std::string &reason)
- {
- std::string nick = user->nick;
- // track quits in our parked user list
- for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
- {
- if (j->nick == nick)
- {
- pinfo.erase(j);
- break;
- }
- }
- }
+ virtual void OnUserQuit(userrec* user, const std::string &reason)
+ {
+ std::string nick = user->nick;
+ // track quits in our parked user list
+ for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
+ {
+ if (j->nick == nick)
+ {
+ pinfo.erase(j);
+ break;
+ }
+ }
+ }
virtual void OnPrePrivmsg(userrec* user, userrec* dest, const std::string &text)
@@ -283,42 +283,42 @@ class ModulePark : public Module
// track nickchanges in our parked user list
// (this isnt too efficient, i'll tidy it up some time)
/* XXX - perhaps extend the user record, or, that wouldn't work - perhaps use a map? -- w00t */
- for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
- {
- if (j->nick == std::string(user->nick))
- {
- j->nick = newnick;
- break;
- }
- }
+ for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
+ {
+ if (j->nick == std::string(user->nick))
+ {
+ j->nick = newnick;
+ break;
+ }
+ }
return 0;
}
virtual void OnBackgroundTimer(time_t curtime)
{
- // look for parked clients which have timed out (this needs tidying)
- if (pinfo.empty())
- return;
- bool go_again = true;
- while (go_again)
- {
- go_again = false;
- for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
- {
- if (time(NULL) >= (j->parktime+ParkMaxTime))
- {
- userrec* thisnick = Srv->FindNick(j->nick);
+ // look for parked clients which have timed out (this needs tidying)
+ if (pinfo.empty())
+ return;
+ bool go_again = true;
+ while (go_again)
+ {
+ go_again = false;
+ for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
+ {
+ if (time(NULL) >= (j->parktime+ParkMaxTime))
+ {
+ userrec* thisnick = Srv->FindNick(j->nick);
// THIS MUST COME BEFORE THE QuitUser - QuitUser can
// create a recursive call to OnUserQuit in this module
// and then corrupt the pointer!
pinfo.erase(j);
- if (thisnick)
- Srv->QuitUser(thisnick,"PARK timeout");
- go_again = true;
- break;
- }
- }
- }
+ if (thisnick)
+ Srv->QuitUser(thisnick,"PARK timeout");
+ go_again = true;
+ break;
+ }
+ }
+ }
}
/* XXX - why is OnPrePrivmsg seperated here, I assume there is reason for the extra function call? --w00t */
@@ -332,11 +332,11 @@ class ModulePark : public Module
return 0;
}
- virtual void OnWhois(userrec* src, userrec* dst)
- {
+ virtual void OnWhois(userrec* src, userrec* dst)
+ {
if (dst->GetExt("park_awaylog"))
- Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a parked client");
- }
+ Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a parked client");
+ }
virtual Version GetVersion()
{
diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp
index 430adf9ef..a3b4c4a7e 100644
--- a/src/modules/m_randquote.cpp
+++ b/src/modules/m_randquote.cpp
@@ -99,7 +99,7 @@ class ModuleRandQuote : public Module
{
RandquoteException e("m_randquote: Quotefile not specified - Please check your config.");
throw(e);
- }
+ }
quotes = new FileReader(q_file);
if(!quotes->Exists())
diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp
index fab61d07c..7662ef5d4 100644
--- a/src/modules/m_remove.cpp
+++ b/src/modules/m_remove.cpp
@@ -150,10 +150,10 @@ class ModuleRemove : public Module
List[I_On005Numeric] = 1;
}
- virtual void On005Numeric(std::string &output)
- {
- output = output + std::string(" REMOVE");
- }
+ virtual void On005Numeric(std::string &output)
+ {
+ output = output + std::string(" REMOVE");
+ }
virtual ~ModuleRemove()
{
diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp
index d4173213e..e9ea965f9 100644
--- a/src/modules/m_safelist.cpp
+++ b/src/modules/m_safelist.cpp
@@ -3,13 +3,13 @@
* +------------------------------------+
*
* InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- * E-mail:
- * <brain@chatspike.net>
- * <Craig@chatspike.net>
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
*
* Written by Craig Edwards, Craig McLure, and others.
* This program is free but copyrighted software; see
- * the file COPYING for details.
+ * the file COPYING for details.
*
* ---------------------------------------------------
*/
@@ -62,44 +62,44 @@ class ListTimer : public InspTimer
virtual void Tick(time_t TIME)
{
- bool go_again = true;
+ bool go_again = true;
- while (go_again)
- {
- go_again = false;
- for (UserList::iterator iter = listusers.begin(); iter != listusers.end(); iter++)
- {
- /*
- * What we do here:
- * - Get where they are up to
- * - If it's > GetChannelCount, erase them from the iterator, set go_again to true
- * - If not, spool the next 20 channels
- */
- userrec* u = (userrec*)(*iter);
- ListData* ld = (ListData*)u->GetExt("safelist_cache");
- if (ld->list_position > Srv->GetChannelCount())
- {
- u->Shrink("safelist_cache");
- delete ld;
- listusers.erase(iter);
- go_again = true;
- break;
- }
+ while (go_again)
+ {
+ go_again = false;
+ for (UserList::iterator iter = listusers.begin(); iter != listusers.end(); iter++)
+ {
+ /*
+ * What we do here:
+ * - Get where they are up to
+ * - If it's > GetChannelCount, erase them from the iterator, set go_again to true
+ * - If not, spool more channels
+ */
+ userrec* u = (userrec*)(*iter);
+ ListData* ld = (ListData*)u->GetExt("safelist_cache");
+ if (ld->list_position > Srv->GetChannelCount())
+ {
+ u->Shrink("safelist_cache");
+ delete ld;
+ listusers.erase(iter);
+ go_again = true;
+ break;
+ }
- log(DEBUG, "m_safelist.so: resuming spool of list to client %s at channel %ld", u->nick, ld->list_position);
- chan = NULL;
- /* Attempt to fill up to half the user's sendq with /LIST output */
- long amount_sent = 0;
- do
- {
- log(DEBUG,"Channel %ld",ld->list_position);
+ log(DEBUG, "m_safelist.so: resuming spool of list to client %s at channel %ld", u->nick, ld->list_position);
+ chan = NULL;
+ /* Attempt to fill up to half the user's sendq with /LIST output */
+ long amount_sent = 0;
+ do
+ {
+ log(DEBUG,"Channel %ld",ld->list_position);
if (!ld->list_position)
WriteServ(u->fd,"321 %s Channel :Users Name",u->nick);
- chan = Srv->GetChannelIndex(ld->list_position);
- /* spool details */
+ chan = Srv->GetChannelIndex(ld->list_position);
+ /* spool details */
bool has_user = (chan && chan->HasUser(u));
- if ((chan) && (((!(chan->modes[CM_PRIVATE])) && (!(chan->modes[CM_SECRET]))) || (has_user)))
- {
+ if ((chan) && (((!(chan->modes[CM_PRIVATE])) && (!(chan->modes[CM_SECRET]))) || (has_user)))
+ {
long users = usercount(chan);
if (users)
{
@@ -109,24 +109,24 @@ class ListTimer : public InspTimer
log(DEBUG,"m_safelist.so: Sent %ld of safe %ld / 4",amount_sent,u->sendqmax);
WriteServ_NoFormat(u->fd,buffer);
}
- }
- else
- {
+ }
+ else
+ {
if (!chan)
{
- if (!ld->list_ended)
- {
- ld->list_ended = true;
- WriteServ(u->fd,"323 %s :End of channel list.",u->nick);
- }
+ if (!ld->list_ended)
+ {
+ ld->list_ended = true;
+ WriteServ(u->fd,"323 %s :End of channel list.",u->nick);
+ }
}
- }
+ }
- ld->list_position++;
- }
- while ((chan != NULL) && (amount_sent < (u->sendqmax / 4)));
- }
- }
+ ld->list_position++;
+ }
+ while ((chan != NULL) && (amount_sent < (u->sendqmax / 4)));
+ }
+ }
ListTimer* MyTimer = new ListTimer(1,Srv);
Srv->AddTimer(MyTimer);
@@ -220,16 +220,16 @@ class ModuleSafeList : public Module
return 1;
}
- virtual void OnCleanup(int target_type, void* item)
- {
- if(target_type == TYPE_USER)
+ virtual void OnCleanup(int target_type, void* item)
+ {
+ if(target_type == TYPE_USER)
{
userrec* u = (userrec*)item;
ListData* ld = (ListData*)u->GetExt("safelist_cache");
if (ld)
{
u->Shrink("safelist_cache");
- delete ld;
+ delete ld;
}
for (UserList::iterator iter = listusers.begin(); iter != listusers.end(); iter++)
{
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index b4118da07..4beda4423 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -71,22 +71,22 @@ class cmd_silence : public command_t
// does it contain any entries and does it exist?
if (sl)
{
- if (sl->size())
- {
- for (silencelist::iterator i = sl->begin(); i != sl->end(); i++)
- {
+ if (sl->size())
+ {
+ for (silencelist::iterator i = sl->begin(); i != sl->end(); i++)
+ {
// search through for the item
irc::string listitem = i->c_str();
irc::string target = nick;
if (listitem == target)
- {
- sl->erase(i);
+ {
+ sl->erase(i);
WriteServ(user->fd,"950 %s %s :Removed %s!*@* from silence list",user->nick, user->nick,nick);
// we have modified the vector from within a loop, we must now bail out
- return;
- }
- }
- }
+ return;
+ }
+ }
+ }
if (!sl->size())
{
// tidy up -- if a user's list is empty, theres no use having it
@@ -178,9 +178,9 @@ class ModuleSilence : public Module
{
for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)
{
- irc::string listitem = c->c_str();
- irc::string target = user->nick;
- if (listitem == target)
+ irc::string listitem = c->c_str();
+ irc::string target = user->nick;
+ if (listitem == target)
{
return 1;
}
@@ -190,10 +190,10 @@ class ModuleSilence : public Module
return 0;
}
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
- {
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
+ {
return OnUserPreNotice(user,dest,target_type,text,status);
- }
+ }
virtual ~ModuleSilence()
{
diff --git a/src/modules/m_spy.cpp b/src/modules/m_spy.cpp
index a32561760..32c19ccc9 100644
--- a/src/modules/m_spy.cpp
+++ b/src/modules/m_spy.cpp
@@ -65,30 +65,30 @@ void spy_userlist(userrec *user,chanrec *c)
{
static char list[MAXBUF];
- if ((!c) || (!user))
- return;
-
- snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
-
- CUList *ulist= c->GetUsers();
- for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- strlcat(list,cmode(i->second,c),MAXBUF);
- strlcat(list,i->second->nick,MAXBUF);
- strlcat(list," ",MAXBUF);
- if (strlen(list)>(480-NICKMAX))
- {
- /* list overflowed into
- * multiple numerics */
- WriteServ_NoFormat(user->fd,list);
- snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
- }
- }
- /* if whats left in the list isnt empty, send it */
- if (list[strlen(list)-1] != ':')
- {
- WriteServ_NoFormat(user->fd,list);
- }
+ if ((!c) || (!user))
+ return;
+
+ snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
+
+ CUList *ulist= c->GetUsers();
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ strlcat(list,cmode(i->second,c),MAXBUF);
+ strlcat(list,i->second->nick,MAXBUF);
+ strlcat(list," ",MAXBUF);
+ if (strlen(list)>(480-NICKMAX))
+ {
+ /* list overflowed into
+ * multiple numerics */
+ WriteServ_NoFormat(user->fd,list);
+ snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
+ }
+ }
+ /* if whats left in the list isnt empty, send it */
+ if (list[strlen(list)-1] != ':')
+ {
+ WriteServ_NoFormat(user->fd,list);
+ }
}
@@ -96,20 +96,20 @@ void spy_userlist(userrec *user,chanrec *c)
class cmd_spylist : public command_t
{
public:
- cmd_spylist () : command_t("SPYLIST", 'o', 0)
- {
- this->source = "m_spy.so";
- }
+ cmd_spylist () : command_t("SPYLIST", 'o', 0)
+ {
+ this->source = "m_spy.so";
+ }
void Handle (char **parameters, int pcnt, userrec *user)
{
WriteOpers("*** Oper %s used SPYLIST to list +s/+p channels and keys.",user->nick);
WriteServ(user->fd,"321 %s Channel :Users Name",user->nick);
- for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++)
- {
+ for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++)
+ {
WriteServ(user->fd,"322 %s %s %d :[+%s] %s",user->nick,i->second->name,usercount(i->second),chanmodes(i->second,true),i->second->topic);
- }
- WriteServ(user->fd,"323 %s :End of channel list.",user->nick);
+ }
+ WriteServ(user->fd,"323 %s :End of channel list.",user->nick);
}
};
@@ -123,29 +123,29 @@ class cmd_spynames : public command_t
void Handle (char **parameters, int pcnt, userrec *user)
{
- chanrec* c;
+ chanrec* c;
- if (!pcnt)
- {
- WriteServ(user->fd,"366 %s * :End of /NAMES list.",user->nick);
- return;
- }
+ if (!pcnt)
+ {
+ WriteServ(user->fd,"366 %s * :End of /NAMES list.",user->nick);
+ return;
+ }
- if (ServerInstance->Parser->LoopCall(this,parameters,pcnt,user,0,pcnt-1,0))
- return;
+ if (ServerInstance->Parser->LoopCall(this,parameters,pcnt,user,0,pcnt-1,0))
+ return;
WriteOpers("*** Oper %s used SPYNAMES to view the users on %s",user->nick,parameters[0]);
- c = FindChan(parameters[0]);
- if (c)
- {
- spy_userlist(user,c);
- WriteServ(user->fd,"366 %s %s :End of /NAMES list.", user->nick, c->name);
- }
- else
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- }
+ c = FindChan(parameters[0]);
+ if (c)
+ {
+ spy_userlist(user,c);
+ WriteServ(user->fd,"366 %s %s :End of /NAMES list.", user->nick, c->name);
+ }
+ else
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
}
};
diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp
index 22b1cf7e8..7a5a1141d 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -58,10 +58,10 @@ class ModuleStripColor : public Module
}
}
- virtual void On005Numeric(std::string &output)
- {
+ virtual void On005Numeric(std::string &output)
+ {
InsertMode(output,"S",4);
- }
+ }
virtual ~ModuleStripColor()
{
@@ -176,7 +176,7 @@ class ModuleStripColorFactory : public ModuleFactory
};
-extern "C" void * init_module( void )
+extern "C" void * stripcolor_init( void )
{
return new ModuleStripColorFactory;
}
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index 190f89f0e..98a76ad63 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -62,8 +62,8 @@ class cmd_tban : public command_t
}
for (timedbans::iterator i = TimedBanList.begin(); i < TimedBanList.end(); i++)
{
- irc::string listitem = i->mask.c_str();
- irc::string target = parameters[2];
+ irc::string listitem = i->mask.c_str();
+ irc::string target = parameters[2];
irc::string listchan = i->channel.c_str();
irc::string targetchan = parameters[0];
if ((listitem == target) && (listchan == targetchan))
@@ -129,16 +129,16 @@ class ModuleTimedBans : public Module
virtual int OnDelBan(userrec* source, chanrec* chan, const std::string &banmask)
{
- for (timedbans::iterator i = TimedBanList.begin(); i < TimedBanList.end(); i++)
- {
- irc::string listitem = banmask.c_str();
- irc::string target = i->mask.c_str();
- if (listitem == target)
- {
- TimedBanList.erase(i);
- break;
- }
- }
+ for (timedbans::iterator i = TimedBanList.begin(); i < TimedBanList.end(); i++)
+ {
+ irc::string listitem = banmask.c_str();
+ irc::string target = i->mask.c_str();
+ if (listitem == target)
+ {
+ TimedBanList.erase(i);
+ break;
+ }
+ }
return 0;
}
diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp
index 07e975392..14660cf1e 100644
--- a/src/modules/m_uninvite.cpp
+++ b/src/modules/m_uninvite.cpp
@@ -37,50 +37,50 @@ class cmd_uninvite : public command_t
void Handle (char **parameters, int pcnt, userrec *user)
{
- userrec* u = Find(parameters[0]);
- chanrec* c = FindChan(parameters[1]);
-
- if ((!c) || (!u))
- {
- if (!c)
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[1]);
- }
- else
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- }
-
- return;
- }
-
- if (c->modes[CM_INVITEONLY])
- {
- if (cstatus(user,c) < STATUS_HOP)
- {
- WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
- return;
- }
- }
+ userrec* u = Find(parameters[0]);
+ chanrec* c = FindChan(parameters[1]);
+
+ if ((!c) || (!u))
+ {
+ if (!c)
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[1]);
+ }
+ else
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
+
+ return;
+ }
+
+ if (c->modes[CM_INVITEONLY])
+ {
+ if (cstatus(user,c) < STATUS_HOP)
+ {
+ WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
+ return;
+ }
+ }
irc::string xname(c->name);
- if (!u->IsInvited(xname))
- {
- WriteServ(user->fd,"491 %s %s %s :Is not invited to channel %s",user->nick,u->nick,c->name,c->name);
- return;
- }
- if (!c->HasUser(user))
- {
- WriteServ(user->fd,"492 %s %s :You're not on that channel!",user->nick, c->name);
- return;
- }
-
- u->RemoveInvite(xname);
- WriteServ(user->fd,"494 %s %s %s :Uninvited",user->nick,c->name,u->nick);
+ if (!u->IsInvited(xname))
+ {
+ WriteServ(user->fd,"491 %s %s %s :Is not invited to channel %s",user->nick,u->nick,c->name,c->name);
+ return;
+ }
+ if (!c->HasUser(user))
+ {
+ WriteServ(user->fd,"492 %s %s :You're not on that channel!",user->nick, c->name);
+ return;
+ }
+
+ u->RemoveInvite(xname);
+ WriteServ(user->fd,"494 %s %s %s :Uninvited",user->nick,c->name,u->nick);
WriteServ(u->fd,"493 %s :You were uninvited from %s by %s",u->nick,c->name,user->nick);
- WriteChannel(c,user,"NOTICE %s :*** %s uninvited %s.",c->name,user->nick,u->nick);
- }
+ WriteChannel(c,user,"NOTICE %s :*** %s uninvited %s.",c->name,user->nick,u->nick);
+ }
};
class ModuleUninvite : public Module
diff --git a/src/modules/m_userip.cpp b/src/modules/m_userip.cpp
index fe6435b9d..55101705e 100644
--- a/src/modules/m_userip.cpp
+++ b/src/modules/m_userip.cpp
@@ -37,18 +37,18 @@ class cmd_userip : public command_t
void Handle (char **parameters, int pcnt, userrec *user)
{
- char Return[MAXBUF],junk[MAXBUF];
- snprintf(Return,MAXBUF,"340 %s :",user->nick);
- for (int i = 0; i < pcnt; i++)
- {
- userrec *u = Find(parameters[i]);
- if (u)
- {
- snprintf(junk,MAXBUF,"%s%s=+%s@%s ",u->nick,*u->oper ? "*" : "",u->ident,(char*)inet_ntoa(u->ip4));
- strlcat(Return,junk,MAXBUF);
- }
- }
- WriteServ(user->fd,Return);
+ char Return[MAXBUF],junk[MAXBUF];
+ snprintf(Return,MAXBUF,"340 %s :",user->nick);
+ for (int i = 0; i < pcnt; i++)
+ {
+ userrec *u = Find(parameters[i]);
+ if (u)
+ {
+ snprintf(junk,MAXBUF,"%s%s=+%s@%s ",u->nick,*u->oper ? "*" : "",u->ident,(char*)inet_ntoa(u->ip4));
+ strlcat(Return,junk,MAXBUF);
+ }
+ }
+ WriteServ(user->fd,Return);
}
};
@@ -69,10 +69,10 @@ class ModuleUserIP : public Module
List[I_On005Numeric] = 1;
}
- virtual void On005Numeric(std::string &output)
- {
+ virtual void On005Numeric(std::string &output)
+ {
output = output + std::string(" USERIP");
- }
+ }
virtual ~ModuleUserIP()
{
diff --git a/src/modules/m_vhost.cpp b/src/modules/m_vhost.cpp
index 22bb771c2..a2e77f091 100644
--- a/src/modules/m_vhost.cpp
+++ b/src/modules/m_vhost.cpp
@@ -29,30 +29,30 @@ static Server* Srv;
class cmd_vhost : public command_t
{
public:
- cmd_vhost() : command_t("VHOST", 0, 2)
- {
- this->source = "m_vhost.so";
- }
+ cmd_vhost() : command_t("VHOST", 0, 2)
+ {
+ this->source = "m_vhost.so";
+ }
- void Handle (char **parameters, int pcnt, userrec *user)
- {
- for (int index = 0; index < Conf->Enumerate("vhost"); index++)
- {
- std::string mask = Conf->ReadValue("vhost","host",index);
+ void Handle (char **parameters, int pcnt, userrec *user)
+ {
+ for (int index = 0; index < Conf->Enumerate("vhost"); index++)
+ {
+ std::string mask = Conf->ReadValue("vhost","host",index);
std::string username = Conf->ReadValue("vhost","user",index);
std::string pass = Conf->ReadValue("vhost","pass",index);
- if ((!strcmp(parameters[0],username.c_str())) && (!strcmp(parameters[1],pass.c_str())))
- {
- if (mask != "")
- {
- Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
- Srv->ChangeHost(user,mask);
- return;
- }
- }
- }
+ if ((!strcmp(parameters[0],username.c_str())) && (!strcmp(parameters[1],pass.c_str())))
+ {
+ if (mask != "")
+ {
+ Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
+ Srv->ChangeHost(user,mask);
+ return;
+ }
+ }
+ }
Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Invalid username or password.");
- }
+ }
};
class ModuleVHost : public Module
@@ -62,13 +62,12 @@ class ModuleVHost : public Module
cmd_vhost* mycommand;
public:
- ModuleVHost(Server* Me)
- : Module::Module(Me)
+ ModuleVHost(Server* Me) : Module::Module(Me)
{
Srv = Me;
- Conf = new ConfigReader;
- mycommand = new cmd_vhost();
- Srv->AddCommand(mycommand);
+ Conf = new ConfigReader;
+ mycommand = new cmd_vhost();
+ Srv->AddCommand(mycommand);
}
virtual ~ModuleVHost()
diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp
index e3a0815a5..1e11dfd51 100644
--- a/src/modules/m_watch.cpp
+++ b/src/modules/m_watch.cpp
@@ -51,17 +51,17 @@ class cmd_watch : public command_t
{
if (!pcnt)
{
- for (watchlist::iterator q = watches.begin(); q != watches.end(); q++)
- {
- if (q->watcher == user)
- {
+ for (watchlist::iterator q = watches.begin(); q != watches.end(); q++)
+ {
+ if (q->watcher == user)
+ {
userrec* targ = Srv->FindNick(q->target);
if (targ)
{
WriteServ(user->fd,"604 %s %s %s %s %lu :is online",user->nick,targ->nick,targ->ident,targ->dhost,targ->age);
}
- }
- }
+ }
+ }
WriteServ(user->fd,"607 %s :End of WATCH list",user->nick);
}
else if (pcnt > 0)
@@ -72,46 +72,46 @@ class cmd_watch : public command_t
if (!strcasecmp(nick,"C"))
{
// watch clear
- bool done = false;
- while (!done)
- {
- done = true;
- for (watchlist::iterator q = watches.begin(); q != watches.end(); q++)
- {
- if (q->watcher == user)
- {
- done = false;
- watches.erase(q);
- break;
- }
- }
- }
+ bool done = false;
+ while (!done)
+ {
+ done = true;
+ for (watchlist::iterator q = watches.begin(); q != watches.end(); q++)
+ {
+ if (q->watcher == user)
+ {
+ done = false;
+ watches.erase(q);
+ break;
+ }
+ }
+ }
}
else if (!strcasecmp(nick,"L"))
{
- for (watchlist::iterator q = watches.begin(); q != watches.end(); q++)
- {
- if (q->watcher == user)
- {
- userrec* targ = Srv->FindNick(q->target);
- if (targ)
- {
- WriteServ(user->fd,"604 %s %s %s %s %lu :is online",user->nick,targ->nick,targ->ident,targ->dhost,targ->age);
- }
- }
- }
- WriteServ(user->fd,"607 %s :End of WATCH list",user->nick);
+ for (watchlist::iterator q = watches.begin(); q != watches.end(); q++)
+ {
+ if (q->watcher == user)
+ {
+ userrec* targ = Srv->FindNick(q->target);
+ if (targ)
+ {
+ WriteServ(user->fd,"604 %s %s %s %s %lu :is online",user->nick,targ->nick,targ->ident,targ->dhost,targ->age);
+ }
+ }
+ }
+ WriteServ(user->fd,"607 %s :End of WATCH list",user->nick);
}
else if (!strcasecmp(nick,"S"))
{
std::string list = "";
- for (watchlist::iterator q = watches.begin(); q != watches.end(); q++)
- {
- if (q->watcher == user)
- {
+ for (watchlist::iterator q = watches.begin(); q != watches.end(); q++)
+ {
+ if (q->watcher == user)
+ {
list = list + " " + q->target;
- }
- }
+ }
+ }
char* l = (char*)list.c_str();
if (*l == ' ')
l++;
@@ -123,25 +123,25 @@ class cmd_watch : public command_t
// removing an item from the list
nick++;
irc::string n1 = nick;
- for (watchlist::iterator q = watches.begin(); q != watches.end(); q++)
- {
- if (q->watcher == user)
- {
+ for (watchlist::iterator q = watches.begin(); q != watches.end(); q++)
+ {
+ if (q->watcher == user)
+ {
irc::string n2 = q->target.c_str();
userrec* a = Srv->FindNick(q->target);
- if (a)
- {
- WriteServ(user->fd,"602 %s %s %s %s %lu :stopped watching",user->nick,a->nick,a->ident,a->dhost,a->age);
- }
- else
- {
- WriteServ(user->fd,"602 %s %s * * 0 :stopped watching",user->nick,q->target.c_str());
- }
- if (n1 == n2)
- {
- watches.erase(q);
- break;
- }
+ if (a)
+ {
+ WriteServ(user->fd,"602 %s %s %s %s %lu :stopped watching",user->nick,a->nick,a->ident,a->dhost,a->age);
+ }
+ else
+ {
+ WriteServ(user->fd,"602 %s %s * * 0 :stopped watching",user->nick,q->target.c_str());
+ }
+ if (n1 == n2)
+ {
+ watches.erase(q);
+ break;
+ }
}
}
}
@@ -170,15 +170,15 @@ class cmd_watch : public command_t
watches.push_back(w);
log(DEBUG,"*** Added %s to watchlist of %s",nick,user->nick);
}
- userrec* a = Srv->FindNick(nick);
- if (a)
- {
- WriteServ(user->fd,"604 %s %s %s %s %lu :is online",user->nick,a->nick,a->ident,a->dhost,a->age);
- }
- else
- {
- WriteServ(user->fd,"605 %s %s * * 0 :is offline",user->nick,nick);
- }
+ userrec* a = Srv->FindNick(nick);
+ if (a)
+ {
+ WriteServ(user->fd,"604 %s %s %s %s %lu :is online",user->nick,a->nick,a->ident,a->dhost,a->age);
+ }
+ else
+ {
+ WriteServ(user->fd,"605 %s %s * * 0 :is offline",user->nick,nick);
+ }
}
}
}
diff --git a/src/socket.cpp b/src/socket.cpp
index 1b2683257..1b657e568 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -73,7 +73,7 @@ InspSocket::InspSocket(const std::string &ahost, int aport, bool listening, unsi
this->OnError(I_ERR_SOCKET);
this->ClosePending = true;
log(DEBUG,"OpenTCPSocket() error");
- return;
+ return;
}
else
{
@@ -109,7 +109,7 @@ InspSocket::InspSocket(const std::string &ahost, int aport, bool listening, unsi
this->dns.SetNS(std::string(Config->DNSServer));
this->dns.ForwardLookupWithFD(host,fd);
timeout_end = time(NULL) + maxtime;
- timeout = false;
+ timeout = false;
this->state = I_RESOLVING;
socket_ref[this->fd] = this;
}
@@ -125,7 +125,7 @@ InspSocket::InspSocket(const std::string &ahost, int aport, bool listening, unsi
void InspSocket::SetQueues(int nfd)
{
- // attempt to increase socket sendq and recvq as high as its possible
+ // attempt to increase socket sendq and recvq as high as its possible
int sendbuf = 32768;
int recvbuf = 32768;
setsockopt(nfd,SOL_SOCKET,SO_SNDBUF,(const void *)&sendbuf,sizeof(sendbuf));
@@ -210,11 +210,11 @@ void InspSocket::Close()
if (this->fd != -1)
{
this->OnClose();
- shutdown(this->fd,2);
- close(this->fd);
+ shutdown(this->fd,2);
+ close(this->fd);
socket_ref[this->fd] = NULL;
this->ClosePending = true;
- this->fd = -1;
+ this->fd = -1;
}
}
diff --git a/src/users.cpp b/src/users.cpp
index e67ad7cec..be24db697 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -69,6 +69,7 @@ bool InitTypes(const char* tag)
if (n->second)
delete[] n->second;
}
+
opertypes.clear();
return true;
}
@@ -80,6 +81,7 @@ bool InitClasses(const char* tag)
if (n->second)
delete[] n->second;
}
+
operclass.clear();
return true;
}
@@ -88,6 +90,7 @@ bool DoType(const char* tag, char** entries, void** values, int* types)
{
char* TypeName = (char*)values[0];
char* Classes = (char*)values[1];
+
opertypes[TypeName] = strdup(Classes);
log(DEBUG,"Read oper TYPE '%s' with classes '%s'",TypeName,Classes);
return true;
@@ -97,6 +100,7 @@ bool DoClass(const char* tag, char** entries, void** values, int* types)
{
char* ClassName = (char*)values[0];
char* CommandList = (char*)values[1];
+
operclass[ClassName] = strdup(CommandList);
log(DEBUG,"Read oper CLASS '%s' with commands '%s'",ClassName,CommandList);
return true;
@@ -120,14 +124,15 @@ userrec::userrec()
sendq = "";
chans.clear();
invites.clear();
- chans.resize(MAXCHANS);
- for (unsigned int n = 0; n < MAXCHANS; n++)
- {
+ chans.resize(MAXCHANS);
+
+ for (unsigned int n = 0; n < MAXCHANS; n++)
+ {
ucrec* x = new ucrec();
chans[n] = x;
x->channel = NULL;
x->uc_modes = 0;
- }
+ }
}
userrec::~userrec()
@@ -139,6 +144,7 @@ userrec::~userrec()
}
}
+/* XXX - minor point, other *Host functions return a char *, this one creates it. Might be nice to be consistant? */
void userrec::MakeHost(char* nhost)
{
/* This is much faster than snprintf */
@@ -191,7 +197,8 @@ int userrec::ReadData(void* buffer, size_t size)
{
return read(this->fd, buffer, size);
}
- else return 0;
+ else
+ return 0;
}
@@ -216,11 +223,13 @@ bool userrec::IsInvited(irc::string &channel)
for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
{
irc::string compare = i->channel;
+
if (compare == channel)
{
return true;
}
}
+
return false;
}
@@ -232,6 +241,7 @@ InvitedList* userrec::GetInviteList()
void userrec::InviteTo(irc::string &channel)
{
Invited i;
+
i.channel = channel;
invites.push_back(i);
}
@@ -239,16 +249,18 @@ void userrec::InviteTo(irc::string &channel)
void userrec::RemoveInvite(irc::string &channel)
{
log(DEBUG,"Removing invites");
+
if (invites.size())
{
for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
{
irc::string compare = i->channel;
+
if (compare == channel)
{
invites.erase(i);
return;
- }
+ }
}
}
}
@@ -259,10 +271,13 @@ bool userrec::HasPermission(const std::string &command)
char* savept;
char* savept2;
- // users on remote servers can completely bypass
- // all permissions based checks.
- // This prevents desyncs when one server has different
- // type/class tags to another.
+ /*
+ * users on remote servers can completely bypass all permissions based checks.
+ * This prevents desyncs when one server has different type/class tags to another.
+ * That having been said, this does open things up to the possibility of source changes
+ * allowing remote kills, etc - but if they have access to the src, they most likely have
+ * access to the conf - so it's an end to a means either way.
+ */
if (!IS_LOCAL(this))
return true;
@@ -304,15 +319,18 @@ bool userrec::HasPermission(const std::string &command)
bool userrec::AddBuffer(const std::string &a)
{
- std::string b = "";
+ std::string b = "";
char* n = (char*)a.c_str();
- for (char* i = n; *i; i++)
+
+ for (char* i = n; *i; i++)
{
- if ((*i != '\r') && (*i != '\0') && (*i != 7))
- b = b + *i;
+ if ((*i != '\r') && (*i != '\0') && (*i != 7))
+ b = b + *i;
}
+
recvq.append(b);
unsigned int i = 0;
+
// count the size of the first line in the buffer.
while (i < recvq.length())
{
@@ -324,49 +342,61 @@ bool userrec::AddBuffer(const std::string &a)
this->SetWriteError("RecvQ exceeded");
WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax);
}
- // return false if we've had more than 600 characters WITHOUT
- // a carriage return (this is BAD, drop the socket)
+
+ /*
+ * return false if we've had more than 600 characters WITHOUT
+ * a carriage return (this is BAD, drop the socket)
+ */
return (i < 600);
}
bool userrec::BufferIsReady()
{
unsigned int t = recvq.length();
- for (unsigned int i = 0; i < t; i++)
+
+ for (unsigned int i = 0; i < t; i++)
if (recvq[i] == '\n')
return true;
- return false;
+ return false;
}
void userrec::ClearBuffer()
{
- recvq = "";
+ recvq = "";
}
std::string userrec::GetBuffer()
{
if (recvq == "")
return "";
- char* line = (char*)recvq.c_str();
- std::string ret = "";
- while ((*line != '\n') && (*line))
- {
- ret = ret + *line;
- line++;
- }
- while ((*line == '\n') || (*line == '\r'))
- line++;
- recvq = line;
- return ret;
+
+ char* line = (char*)recvq.c_str();
+
+ std::string ret = "";
+
+ while ((*line != '\n') && (*line))
+ {
+ ret = ret + *line;
+ line++;
+ }
+
+ while ((*line == '\n') || (*line == '\r'))
+ line++;
+
+ recvq = line;
+
+ return ret;
}
void userrec::AddWriteBuf(const std::string &data)
{
if (*this->GetWriteError())
return;
+
if (sendq.length() + data.length() > (unsigned)this->sendqmax)
{
- /* Fix by brain - Set the error text BEFORE calling writeopers, because
+ /*
+ * Fix by brain - Set the error text BEFORE calling writeopers, because
* if we dont it'll recursively call here over and over again trying
* to repeatedly add the text to the sendq!
*/
@@ -374,9 +404,9 @@ void userrec::AddWriteBuf(const std::string &data)
WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
return;
}
- std::stringstream stream;
- stream << sendq << data;
- sendq = stream.str();
+ std::stringstream stream;
+ stream << sendq << data;
+ sendq = stream.str();
}
// send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it)
@@ -417,27 +447,26 @@ const char* userrec::GetWriteError()
void AddOper(userrec* user)
{
- log(DEBUG,"Oper added to optimization list");
- all_opers.push_back(user);
+ log(DEBUG,"Oper added to optimization list");
+ all_opers.push_back(user);
}
void DeleteOper(userrec* user)
{
- for (std::vector<userrec*>::iterator a = all_opers.begin(); a < all_opers.end(); a++)
- {
- if (*a == user)
- {
- log(DEBUG,"Oper removed from optimization list");
- all_opers.erase(a);
- return;
- }
- }
+ for (std::vector<userrec*>::iterator a = all_opers.begin(); a < all_opers.end(); a++)
+ {
+ if (*a == user)
+ {
+ log(DEBUG,"Oper removed from optimization list");
+ all_opers.erase(a);
+ return;
+ }
+ }
}
void kill_link(userrec *user,const char* r)
{
- user_hash::iterator iter = clientlist.find(user->nick);
-
+ user_hash::iterator iter = clientlist.find(user->nick);
/*
* I'm pretty sure returning here is causing a desync when part of the net thinks a user is gone,
@@ -450,66 +479,74 @@ void kill_link(userrec *user,const char* r)
* return;
*/
- char reason[MAXBUF];
-
- strlcpy(reason,r,MAXQUIT-1);
+ char reason[MAXBUF];
- log(DEBUG,"kill_link: %s '%s'",user->nick,reason);
+ strlcpy(reason,r,MAXQUIT-1);
+ log(DEBUG,"kill_link: %s '%s'",user->nick,reason);
+
if (IS_LOCAL(user))
- Write(user->fd,"ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason);
+ Write(user->fd,"ERROR :Closing link (%s@%s) [%s]",user->ident,user->host,reason);
- if (user->registered == 7) {
+ if (user->registered == 7)
+ {
purge_empty_chans(user);
- FOREACH_MOD(I_OnUserQuit,OnUserQuit(user,reason));
- WriteCommonExcept(user,"QUIT :%s",reason);
- }
+ FOREACH_MOD(I_OnUserQuit,OnUserQuit(user,reason));
+ WriteCommonExcept(user,"QUIT :%s",reason);
+ }
if (IS_LOCAL(user))
- user->FlushWriteBuf();
+ user->FlushWriteBuf();
- FOREACH_MOD(I_OnUserDisconnect,OnUserDisconnect(user));
+ FOREACH_MOD(I_OnUserDisconnect,OnUserDisconnect(user));
- if (IS_LOCAL(user))
- {
+ if (IS_LOCAL(user))
+ {
if (Config->GetIOHook(user->port))
{
try
{
- Config->GetIOHook(user->port)->OnRawSocketClose(user->fd);
+ Config->GetIOHook(user->port)->OnRawSocketClose(user->fd);
+ }
+ catch (ModuleException& modexcept)
+ {
+ log(DEBUG,"Module exception cought: %s",modexcept.GetReason());
}
- catch (ModuleException& modexcept)
- {
- log(DEBUG,"Module exception cought: %s",modexcept.GetReason());
- }
}
- ServerInstance->SE->DelFd(user->fd);
- user->CloseSocket();
- }
-
- // this must come before the WriteOpers so that it doesnt try to fill their buffer with anything
- // if they were an oper with +s.
- if (user->registered == 7) {
- // fix by brain: only show local quits because we only show local connects (it just makes SENSE)
- if (IS_LOCAL(user))
- WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason);
- AddWhoWas(user);
- }
-
- if (iter != clientlist.end())
- {
- log(DEBUG,"deleting user hash value %lx",(unsigned long)user);
- if (IS_LOCAL(user))
+
+ ServerInstance->SE->DelFd(user->fd);
+ user->CloseSocket();
+ }
+
+ /*
+ * this must come before the WriteOpers so that it doesnt try to fill their buffer with anything
+ * if they were an oper with +s.
+ *
+ * XXX -
+ * In the current implementation, we only show local quits, as we only show local connects. With
+ * the proposed implmentation of snomasks however, this will likely change in the (near?) future.
+ */
+ if (user->registered == 7)
+ {
+ if (IS_LOCAL(user))
+ WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason);
+ AddWhoWas(user);
+ }
+
+ if (iter != clientlist.end())
+ {
+ log(DEBUG,"deleting user hash value %lx",(unsigned long)user);
+ if (IS_LOCAL(user))
{
- fd_ref_table[user->fd] = NULL;
+ fd_ref_table[user->fd] = NULL;
if (find(local_users.begin(),local_users.end(),user) != local_users.end())
{
local_users.erase(find(local_users.begin(),local_users.end(),user));
log(DEBUG,"Delete local user");
}
}
- clientlist.erase(iter);
+ clientlist.erase(iter);
delete user;
- }
+ }
}
WhoWasGroup::WhoWasGroup(userrec* user) : host(NULL), dhost(NULL), ident(NULL), server(NULL), gecos(NULL), signon(user->signon)
@@ -536,7 +573,8 @@ WhoWasGroup::~WhoWasGroup()
/* adds or updates an entry in the whowas list */
void AddWhoWas(userrec* u)
{
- whowas_users::iterator iter = whowas.find(u->nick);
+ whowas_users::iterator iter = whowas.find(u->nick);
+
if (iter == whowas.end())
{
whowas_set* n = new whowas_set;
@@ -547,12 +585,14 @@ void AddWhoWas(userrec* u)
else
{
whowas_set* group = (whowas_set*)iter->second;
+
if (group->size() > 10)
{
WhoWasGroup *a = (WhoWasGroup*)*(group->begin());
delete a;
group->pop_front();
}
+
WhoWasGroup *a = new WhoWasGroup(u);
group->push_back(a);
}
@@ -584,110 +624,115 @@ void AddClient(int socket, int port, bool iscached, in_addr ip4)
const char *ipaddr = inet_ntoa(ip4);
int j = 0;
- // fix by brain.
- // as these nicknames are 'RFC impossible', we can be sure nobody is going to be
- // using one as a registered connection. As theyre per fd, we can also safely assume
- // that we wont have collisions. Therefore, if the nick exists in the list, its only
- // used by a dead socket, erase the iterator so that the new client may reclaim it.
- // this was probably the cause of 'server ignores me when i hammer it with reconnects'
- // issue in earlier alphas/betas
- if (iter != clientlist.end())
- {
- userrec* goner = iter->second;
- delete goner;
- clientlist.erase(iter);
- }
+ /*
+ * fix by brain.
+ * as these nicknames are 'RFC impossible', we can be sure nobody is going to be
+ * using one as a registered connection. As they are per fd, we can also safely assume
+ * that we wont have collisions. Therefore, if the nick exists in the list, its only
+ * used by a dead socket, erase the iterator so that the new client may reclaim it.
+ * this was probably the cause of 'server ignores me when i hammer it with reconnects'
+ * issue in earlier alphas/betas
+ */
+ if (iter != clientlist.end())
+ {
+ userrec* goner = iter->second;
+ delete goner;
+ clientlist.erase(iter);
+ }
log(DEBUG,"AddClient: %d %d %s",socket,port,ipaddr);
- clientlist[tempnick] = new userrec();
- clientlist[tempnick]->fd = socket;
- strlcpy(clientlist[tempnick]->nick,tempnick.c_str(),NICKMAX-1);
+ clientlist[tempnick] = new userrec();
+ clientlist[tempnick]->fd = socket;
+ strlcpy(clientlist[tempnick]->nick,tempnick.c_str(),NICKMAX-1);
/* Smarter than your average bear^H^H^H^Hset of strlcpys. */
for (char* temp = (char*)ipaddr; *temp && j < 64; temp++, j++)
clientlist[tempnick]->dhost[j] = clientlist[tempnick]->host[j] = *temp;
clientlist[tempnick]->dhost[j] = clientlist[tempnick]->host[j] = 0;
- clientlist[tempnick]->server = (char*)FindServerNamePtr(Config->ServerName);
+ clientlist[tempnick]->server = (char*)FindServerNamePtr(Config->ServerName);
/* We don't need range checking here, we KNOW 'unknown\0' will fit into the ident field. */
- strcpy(clientlist[tempnick]->ident, "unknown");
+ strcpy(clientlist[tempnick]->ident, "unknown");
- clientlist[tempnick]->registered = 0;
- clientlist[tempnick]->signon = TIME + Config->dns_timeout;
- clientlist[tempnick]->lastping = 1;
+ clientlist[tempnick]->registered = 0;
+ clientlist[tempnick]->signon = TIME + Config->dns_timeout;
+ clientlist[tempnick]->lastping = 1;
clientlist[tempnick]->ip4 = ip4;
- clientlist[tempnick]->port = port;
-
- // set the registration timeout for this user
- unsigned long class_regtimeout = 90;
- int class_flood = 0;
- long class_threshold = 5;
- long class_sqmax = 262144; // 256kb
- long class_rqmax = 4096; // 4k
-
- for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
- {
- if ((i->type == CC_ALLOW) && (match(ipaddr,i->host.c_str())))
- {
- class_regtimeout = (unsigned long)i->registration_timeout;
- class_flood = i->flood;
- clientlist[tempnick]->pingmax = i->pingtime;
- class_threshold = i->threshold;
- class_sqmax = i->sendqmax;
- class_rqmax = i->recvqmax;
- break;
- }
- }
-
- clientlist[tempnick]->nping = TIME+clientlist[tempnick]->pingmax + Config->dns_timeout;
- clientlist[tempnick]->timeout = TIME+class_regtimeout;
- clientlist[tempnick]->flood = class_flood;
- clientlist[tempnick]->threshold = class_threshold;
- clientlist[tempnick]->sendqmax = class_sqmax;
- clientlist[tempnick]->recvqmax = class_rqmax;
+ clientlist[tempnick]->port = port;
+
+ // set the registration timeout for this user
+ unsigned long class_regtimeout = 90;
+ int class_flood = 0;
+ long class_threshold = 5;
+ long class_sqmax = 262144; // 256kb
+ long class_rqmax = 4096; // 4k
+
+ for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
+ {
+ if ((i->type == CC_ALLOW) && (match(ipaddr,i->host.c_str())))
+ {
+ class_regtimeout = (unsigned long)i->registration_timeout;
+ class_flood = i->flood;
+ clientlist[tempnick]->pingmax = i->pingtime;
+ class_threshold = i->threshold;
+ class_sqmax = i->sendqmax;
+ class_rqmax = i->recvqmax;
+ break;
+ }
+ }
+
+ clientlist[tempnick]->nping = TIME+clientlist[tempnick]->pingmax + Config->dns_timeout;
+ clientlist[tempnick]->timeout = TIME+class_regtimeout;
+ clientlist[tempnick]->flood = class_flood;
+ clientlist[tempnick]->threshold = class_threshold;
+ clientlist[tempnick]->sendqmax = class_sqmax;
+ clientlist[tempnick]->recvqmax = class_rqmax;
fd_ref_table[socket] = clientlist[tempnick];
local_users.push_back(clientlist[tempnick]);
- if (local_users.size() > Config->SoftLimit)
- {
- kill_link(clientlist[tempnick],"No more connections allowed");
- return;
- }
-
- if (local_users.size() >= MAXCLIENTS)
- {
- kill_link(clientlist[tempnick],"No more connections allowed");
- return;
- }
-
- // this is done as a safety check to keep the file descriptors within range of fd_ref_table.
- // its a pretty big but for the moment valid assumption:
- // file descriptors are handed out starting at 0, and are recycled as theyre freed.
- // therefore if there is ever an fd over 65535, 65536 clients must be connected to the
- // irc server at once (or the irc server otherwise initiating this many connections, files etc)
- // which for the time being is a physical impossibility (even the largest networks dont have more
- // than about 10,000 users on ONE server!)
- if ((unsigned)socket >= MAX_DESCRIPTORS)
- {
- kill_link(clientlist[tempnick],"Server is full");
- return;
- }
- char* e = matches_exception(ipaddr);
- if (!e)
- {
- char* r = matches_zline(ipaddr);
- if (r)
- {
- char reason[MAXBUF];
- snprintf(reason,MAXBUF,"Z-Lined: %s",r);
- kill_link(clientlist[tempnick],reason);
- return;
- }
- }
-
- ServerInstance->SE->AddFd(socket,true,X_ESTAB_CLIENT);
+ if (local_users.size() > Config->SoftLimit)
+ {
+ kill_link(clientlist[tempnick],"No more connections allowed");
+ return;
+ }
+
+ if (local_users.size() >= MAXCLIENTS)
+ {
+ kill_link(clientlist[tempnick],"No more connections allowed");
+ return;
+ }
+
+ /*
+ * XXX -
+ * this is done as a safety check to keep the file descriptors within range of fd_ref_table.
+ * its a pretty big but for the moment valid assumption:
+ * file descriptors are handed out starting at 0, and are recycled as theyre freed.
+ * therefore if there is ever an fd over 65535, 65536 clients must be connected to the
+ * irc server at once (or the irc server otherwise initiating this many connections, files etc)
+ * which for the time being is a physical impossibility (even the largest networks dont have more
+ * than about 10,000 users on ONE server!)
+ */
+ if ((unsigned)socket >= MAX_DESCRIPTORS)
+ {
+ kill_link(clientlist[tempnick],"Server is full");
+ return;
+ }
+ char* e = matches_exception(ipaddr);
+ if (!e)
+ {
+ char* r = matches_zline(ipaddr);
+ if (r)
+ {
+ char reason[MAXBUF];
+ snprintf(reason,MAXBUF,"Z-Lined: %s",r);
+ kill_link(clientlist[tempnick],reason);
+ return;
+ }
+ }
+
+ ServerInstance->SE->AddFd(socket,true,X_ESTAB_CLIENT);
WriteServ(clientlist[tempnick]->fd,"NOTICE Auth :*** Looking up your hostname...");
}
@@ -717,9 +762,9 @@ long FindMatchingLocal(userrec* user)
void FullConnectUser(userrec* user, CullList* Goners)
{
- ServerInstance->stats->statsConnects++;
- user->idle_lastmsg = TIME;
- log(DEBUG,"ConnectUser: %s",user->nick);
+ ServerInstance->stats->statsConnects++;
+ user->idle_lastmsg = TIME;
+ log(DEBUG,"ConnectUser: %s",user->nick);
ConnectClass a = GetClass(user);
@@ -728,11 +773,13 @@ void FullConnectUser(userrec* user, CullList* Goners)
Goners->AddItem(user,"Unauthorised connection");
return;
}
+
if ((*(a.pass.c_str())) && (!user->haspassed))
- {
+ {
Goners->AddItem(user,"Invalid password");
- return;
- }
+ return;
+ }
+
if (FindMatchingLocal(user) > a.maxlocal)
{
Goners->AddItem(user,"No more connections allowed from your host via this connect class (local)");
@@ -746,124 +793,141 @@ void FullConnectUser(userrec* user, CullList* Goners)
return;
}
- char match_against[MAXBUF];
- snprintf(match_against,MAXBUF,"%s@%s",user->ident,user->host);
- char* e = matches_exception(match_against);
- if (!e)
- {
- char* r = matches_gline(match_against);
- if (r)
- {
- char reason[MAXBUF];
- snprintf(reason,MAXBUF,"G-Lined: %s",r);
+ char match_against[MAXBUF];
+ snprintf(match_against,MAXBUF,"%s@%s",user->ident,user->host);
+ char* e = matches_exception(match_against);
+
+ if (!e)
+ {
+ char* r = matches_gline(match_against);
+
+ if (r)
+ {
+ char reason[MAXBUF];
+ snprintf(reason,MAXBUF,"G-Lined: %s",r);
Goners->AddItem(user,reason);
- return;
- }
- r = matches_kline(user->host);
- if (r)
- {
- char reason[MAXBUF];
- snprintf(reason,MAXBUF,"K-Lined: %s",r);
- Goners->AddItem(user,reason);
- return;
- }
- }
-
-
- WriteServ(user->fd,"NOTICE Auth :Welcome to \002%s\002!",Config->Network);
- WriteServ(user->fd,"001 %s :Welcome to the %s IRC Network %s!%s@%s",user->nick,Config->Network,user->nick,user->ident,user->host);
- WriteServ(user->fd,"002 %s :Your host is %s, running version %s",user->nick,Config->ServerName,VERSION);
- WriteServ(user->fd,"003 %s :This server was created %s %s",user->nick,__TIME__,__DATE__);
- WriteServ(user->fd,"004 %s %s %s iowghrasxRVSCWBG lvhopsmntikrcaqbegIOLQRSKVHGCNT vhobeIaqglk",user->nick,Config->ServerName,VERSION);
- // anfl @ #ratbox, efnet reminded me that according to the RFC this cant contain more than 13 tokens per line...
- // so i'd better split it :)
- std::stringstream out(Config->data005);
- std::string token = "";
- std::string line5 = "";
- int token_counter = 0;
- while (!out.eof())
- {
- out >> token;
- line5 = line5 + token + " ";
- token_counter++;
- if ((token_counter >= 13) || (out.eof() == true))
- {
- WriteServ(user->fd,"005 %s %s:are supported by this server",user->nick,line5.c_str());
- line5 = "";
- token_counter = 0;
- }
- }
- ShowMOTD(user);
-
- // fix 3 by brain, move registered = 7 below these so that spurious modes and host changes dont go out
- // onto the network and produce 'fake direction'
- FOREACH_MOD(I_OnUserConnect,OnUserConnect(user));
- FOREACH_MOD(I_OnGlobalConnect,OnGlobalConnect(user));
- user->registered = 7;
- WriteOpers("*** Client connecting on port %lu: %s!%s@%s [%s]",(unsigned long)user->port,user->nick,user->ident,user->host,(char*)inet_ntoa(user->ip4));
-}
-
-/* re-allocates a nick in the user_hash after they change nicknames,
- * returns a pointer to the new user as it may have moved */
+ return;
+ }
+
+ r = matches_kline(user->host);
+
+ if (r)
+ {
+ char reason[MAXBUF];
+ snprintf(reason,MAXBUF,"K-Lined: %s",r);
+ Goners->AddItem(user,reason);
+ return;
+ }
+ }
+
+
+ WriteServ(user->fd,"NOTICE Auth :Welcome to \002%s\002!",Config->Network);
+ WriteServ(user->fd,"001 %s :Welcome to the %s IRC Network %s!%s@%s",user->nick,Config->Network,user->nick,user->ident,user->host);
+ WriteServ(user->fd,"002 %s :Your host is %s, running version %s",user->nick,Config->ServerName,VERSION);
+ WriteServ(user->fd,"003 %s :This server was created %s %s",user->nick,__TIME__,__DATE__);
+ WriteServ(user->fd,"004 %s %s %s iowghrasxRVSCWBG lvhopsmntikrcaqbegIOLQRSKVHGCNT vhobeIaqglk",user->nick,Config->ServerName,VERSION);
+
+ // anfl @ #ratbox, efnet reminded me that according to the RFC this cant contain more than 13 tokens per line...
+ // so i'd better split it :)
+ std::stringstream out(Config->data005);
+ std::string token = "";
+ std::string line5 = "";
+ int token_counter = 0;
+
+ while (!out.eof())
+ {
+ out >> token;
+ line5 = line5 + token + " ";
+ token_counter++;
+
+ if ((token_counter >= 13) || (out.eof() == true))
+ {
+ WriteServ(user->fd,"005 %s %s:are supported by this server",user->nick,line5.c_str());
+ line5 = "";
+ token_counter = 0;
+ }
+ }
+
+ ShowMOTD(user);
+ /*
+ * fix 3 by brain, move registered = 7 below these so that spurious modes and host
+ * changes dont go out onto the network and produce 'fake direction'.
+ */
+ FOREACH_MOD(I_OnUserConnect,OnUserConnect(user));
+ FOREACH_MOD(I_OnGlobalConnect,OnGlobalConnect(user));
+ user->registered = 7;
+ WriteOpers("*** Client connecting on port %lu: %s!%s@%s [%s]",(unsigned long)user->port,user->nick,user->ident,user->host,(char*)inet_ntoa(user->ip4));
+}
+
+/** ReHashNick()
+ * re-allocates a nick in the user_hash after they change nicknames,
+ * returns a pointer to the new user as it may have moved
+ */
userrec* ReHashNick(char* Old, char* New)
{
- //user_hash::iterator newnick;
- user_hash::iterator oldnick = clientlist.find(Old);
+ //user_hash::iterator newnick;
+ user_hash::iterator oldnick = clientlist.find(Old);
- log(DEBUG,"ReHashNick: %s %s",Old,New);
+ log(DEBUG,"ReHashNick: %s %s",Old,New);
- if (!strcasecmp(Old,New))
- {
- log(DEBUG,"old nick is new nick, skipping");
- return oldnick->second;
- }
+ if (!strcasecmp(Old,New))
+ {
+ log(DEBUG,"old nick is new nick, skipping");
+ return oldnick->second;
+ }
- if (oldnick == clientlist.end()) return NULL; /* doesnt exist */
+ if (oldnick == clientlist.end())
+ return NULL; /* doesnt exist */
- log(DEBUG,"ReHashNick: Found hashed nick %s",Old);
+ log(DEBUG,"ReHashNick: Found hashed nick %s",Old);
- userrec* olduser = oldnick->second;
- clientlist[New] = olduser;
- clientlist.erase(oldnick);
+ userrec* olduser = oldnick->second;
+ clientlist[New] = olduser;
+ clientlist.erase(oldnick);
- log(DEBUG,"ReHashNick: Nick rehashed as %s",New);
+ log(DEBUG,"ReHashNick: Nick rehashed as %s",New);
- return clientlist[New];
+ return clientlist[New];
}
void force_nickchange(userrec* user,const char* newnick)
{
- char nick[MAXBUF];
- int MOD_RESULT = 0;
+ char nick[MAXBUF];
+ int MOD_RESULT = 0;
- *nick = 0;
+ *nick = 0;
- FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,newnick));
- if (MOD_RESULT) {
- ServerInstance->stats->statsCollisions++;
- kill_link(user,"Nickname collision");
- return;
- }
- if (matches_qline(newnick))
- {
+ FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,newnick));
+
+ if (MOD_RESULT)
+ {
ServerInstance->stats->statsCollisions++;
- kill_link(user,"Nickname collision");
- return;
- }
-
- if (user)
- {
- if (newnick)
- {
- strlcpy(nick,newnick,MAXBUF-1);
- }
- if (user->registered == 7)
- {
- char* pars[1];
- pars[0] = nick;
+ kill_link(user,"Nickname collision");
+ return;
+ }
+
+ if (matches_qline(newnick))
+ {
+ ServerInstance->stats->statsCollisions++;
+ kill_link(user,"Nickname collision");
+ return;
+ }
+
+ if (user)
+ {
+ if (newnick)
+ {
+ strlcpy(nick,newnick,MAXBUF-1);
+ }
+
+ if (user->registered == 7)
+ {
+ char* pars[1];
+
+ pars[0] = nick;
std::string cmd = "NICK";
- ServerInstance->Parser->CallHandler(cmd,pars,1,user);
- }
- }
+ ServerInstance->Parser->CallHandler(cmd,pars,1,user);
+ }
+ }
}
diff --git a/src/xline.cpp b/src/xline.cpp
index abd09a0ab..602b67835 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -122,6 +122,7 @@ bool DoZLine(const char* tag, char** entries, void** values, int* types)
{
char* reason = (char*)values[0];
char* ipmask = (char*)values[1];
+
add_zline(0,"<Config>",reason,ipmask);
log(DEBUG,"Read Z line (badip tag): ipmask=%s reason=%s",ipmask,reason);
return true;
@@ -131,6 +132,7 @@ bool DoQLine(const char* tag, char** entries, void** values, int* types)
{
char* reason = (char*)values[0];
char* nick = (char*)values[1];
+
add_qline(0,"<Config>",reason,nick);
log(DEBUG,"Read Q line (badnick tag): nick=%s reason=%s",nick,reason);
return true;
@@ -140,6 +142,7 @@ bool DoKLine(const char* tag, char** entries, void** values, int* types)
{
char* reason = (char*)values[0];
char* host = (char*)values[1];
+
add_kline(0,"<Config>",reason,host);
log(DEBUG,"Read K line (badhost tag): host=%s reason=%s",host,reason);
return true;
@@ -149,6 +152,7 @@ bool DoELine(const char* tag, char** entries, void** values, int* types)
{
char* reason = (char*)values[0];
char* host = (char*)values[1];
+
add_eline(0,"<Config>",reason,host);
log(DEBUG,"Read E line (exception tag): host=%s reason=%s",host,reason);
return true;
@@ -159,6 +163,7 @@ bool DoELine(const char* tag, char** entries, void** values, int* types)
bool add_gline(long duration, const char* source,const char* reason,const char* hostmask)
{
bool ret = del_gline(hostmask);
+
GLine item;
item.duration = duration;
strlcpy(item.hostmask,hostmask,199);
@@ -166,6 +171,7 @@ bool add_gline(long duration, const char* source,const char* reason,const char*
strlcpy(item.source,source,255);
item.n_matches = 0;
item.set_time = TIME;
+
if (duration)
{
glines.push_back(item);
@@ -175,6 +181,7 @@ bool add_gline(long duration, const char* source,const char* reason,const char*
{
pglines.push_back(item);
}
+
return !ret;
}
@@ -182,17 +189,17 @@ bool add_gline(long duration, const char* source,const char* reason,const char*
bool add_eline(long duration, const char* source, const char* reason, const char* hostmask)
{
- bool ret = del_eline(hostmask);
- ELine item;
- item.duration = duration;
- strlcpy(item.hostmask,hostmask,199);
- strlcpy(item.reason,reason,MAXBUF);
- strlcpy(item.source,source,255);
- item.n_matches = 0;
- item.set_time = TIME;
+ bool ret = del_eline(hostmask);
+ ELine item;
+ item.duration = duration;
+ strlcpy(item.hostmask,hostmask,199);
+ strlcpy(item.reason,reason,MAXBUF);
+ strlcpy(item.source,source,255);
+ item.n_matches = 0;
+ item.set_time = TIME;
if (duration)
{
- elines.push_back(item);
+ elines.push_back(item);
sort(elines.begin(), elines.end(),ESortComparison);
}
else
@@ -309,14 +316,14 @@ bool del_gline(const char* hostmask)
bool del_eline(const char* hostmask)
{
- for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
- {
- if (!strcasecmp(hostmask,i->hostmask))
- {
- elines.erase(i);
- return true;
- }
- }
+ for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
+ {
+ if (!strcasecmp(hostmask,i->hostmask))
+ {
+ elines.erase(i);
+ return true;
+ }
+ }
for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
{
if (!strcasecmp(hostmask,i->hostmask))
@@ -325,7 +332,7 @@ bool del_eline(const char* hostmask)
return true;
}
}
- return false;
+ return false;
}
// deletes a q:line, returns true if the line existed and was removed
@@ -442,8 +449,8 @@ char* matches_qline(const char* nick)
char* matches_gline(const char* host)
{
- if ((glines.empty()) && (pglines.empty()))
- return NULL;
+ if ((glines.empty()) && (pglines.empty()))
+ return NULL;
for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
if (match(host,i->hostmask))
return i->reason;
@@ -455,17 +462,17 @@ char* matches_gline(const char* host)
char* matches_exception(const char* host)
{
- if ((elines.empty()) && (pelines.empty()))
- return NULL;
+ if ((elines.empty()) && (pelines.empty()))
+ return NULL;
char host2[MAXBUF];
snprintf(host2,MAXBUF,"*@%s",host);
- for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
- if ((match(host,i->hostmask)) || (match(host2,i->hostmask)))
- return i->reason;
+ for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
+ if ((match(host,i->hostmask)) || (match(host2,i->hostmask)))
+ return i->reason;
for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
if ((match(host,i->hostmask)) || (match(host2,i->hostmask)))
return i->reason;
- return NULL;
+ return NULL;
}
@@ -557,8 +564,8 @@ void zline_set_creation_time(char* ip, time_t create_time)
char* matches_zline(const char* ipaddr)
{
- if ((zlines.empty()) && (pzlines.empty()))
- return NULL;
+ if ((zlines.empty()) && (pzlines.empty()))
+ return NULL;
for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
if (match(ipaddr,i->ipaddr))
return i->reason;
@@ -572,8 +579,8 @@ char* matches_zline(const char* ipaddr)
char* matches_kline(const char* host)
{
- if ((klines.empty()) && (pklines.empty()))
- return NULL;
+ if ((klines.empty()) && (pklines.empty()))
+ return NULL;
for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++)
if (match(host,i->hostmask))
return i->reason;
@@ -590,7 +597,7 @@ bool GSortComparison ( const GLine one, const GLine two )
bool ESortComparison ( const ELine one, const ELine two )
{
- return (one.duration + one.set_time) < (two.duration + two.set_time);
+ return (one.duration + one.set_time) < (two.duration + two.set_time);
}
bool ZSortComparison ( const ZLine one, const ZLine two )
@@ -600,12 +607,12 @@ bool ZSortComparison ( const ZLine one, const ZLine two )
bool KSortComparison ( const KLine one, const KLine two )
{
- return (one.duration + one.set_time) < (two.duration + two.set_time);
+ return (one.duration + one.set_time) < (two.duration + two.set_time);
}
bool QSortComparison ( const QLine one, const QLine two )
{
- return (one.duration + one.set_time) < (two.duration + two.set_time);
+ return (one.duration + one.set_time) < (two.duration + two.set_time);
}
// removes lines that have expired
@@ -751,8 +758,8 @@ void stats_z(userrec* user)
void stats_e(userrec* user)
{
- for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
- WriteServ(user->fd,"223 %s :%s %d %d %s :%s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
+ for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
+ WriteServ(user->fd,"223 %s :%s %d %d %s :%s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
WriteServ(user->fd,"223 %s :%s %d %d %s :%s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
}