summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp146
-rw-r--r--src/cmd_die.cpp2
-rw-r--r--src/cmd_eline.cpp6
-rw-r--r--src/cmd_gline.cpp6
-rw-r--r--src/cmd_invite.cpp4
-rw-r--r--src/cmd_ison.cpp5
-rw-r--r--src/cmd_kick.cpp7
-rw-r--r--src/cmd_kill.cpp8
-rw-r--r--src/cmd_kline.cpp6
-rw-r--r--src/cmd_list.cpp2
-rw-r--r--src/cmd_loadmodule.cpp2
-rw-r--r--src/cmd_names.cpp4
-rw-r--r--src/cmd_nick.cpp4
-rw-r--r--src/cmd_notice.cpp4
-rw-r--r--src/cmd_oper.cpp8
-rw-r--r--src/cmd_part.cpp2
-rw-r--r--src/cmd_pass.cpp2
-rw-r--r--src/cmd_privmsg.cpp4
-rw-r--r--src/cmd_qline.cpp6
-rw-r--r--src/cmd_quit.cpp8
-rw-r--r--src/cmd_rehash.cpp2
-rw-r--r--src/cmd_restart.cpp4
-rw-r--r--src/cmd_server.cpp5
-rw-r--r--src/cmd_stats.cpp2
-rw-r--r--src/cmd_topic.cpp4
-rw-r--r--src/cmd_unloadmodule.cpp2
-rw-r--r--src/cmd_userhost.cpp5
-rw-r--r--src/cmd_who.cpp2
-rw-r--r--src/cmd_whois.cpp7
-rw-r--r--src/cmd_zline.cpp6
-rw-r--r--src/commands.cpp6
-rw-r--r--src/configreader.cpp61
-rw-r--r--src/helperfuncs.cpp306
-rw-r--r--src/inspircd.cpp6
-rw-r--r--src/inspstring.cpp39
-rw-r--r--src/mode.cpp8
-rw-r--r--src/modes/cmode_b.cpp2
-rw-r--r--src/modes/cmode_h.cpp20
-rw-r--r--src/modes/cmode_o.cpp26
-rw-r--r--src/modes/cmode_v.cpp26
-rw-r--r--src/modules.cpp23
-rw-r--r--src/modules/extra/m_sqlauth.cpp6
-rw-r--r--src/modules/m_alias.cpp6
-rw-r--r--src/modules/m_blockamsg.cpp2
-rw-r--r--src/modules/m_cban.cpp10
-rw-r--r--src/modules/m_cgiirc.cpp12
-rw-r--r--src/modules/m_chanprotect.cpp10
-rw-r--r--src/modules/m_check.cpp6
-rw-r--r--src/modules/m_chghost.cpp6
-rw-r--r--src/modules/m_chgident.cpp9
-rw-r--r--src/modules/m_connflood.cpp4
-rw-r--r--src/modules/m_filter.cpp7
-rw-r--r--src/modules/m_globalload.cpp4
-rw-r--r--src/modules/m_httpd_stats.cpp2
-rw-r--r--src/modules/m_knock.cpp3
-rw-r--r--src/modules/m_nicklock.cpp9
-rw-r--r--src/modules/m_operlevels.cpp4
-rw-r--r--src/modules/m_override.cpp22
-rw-r--r--src/modules/m_park.cpp4
-rw-r--r--src/modules/m_redirect.cpp2
-rw-r--r--src/modules/m_remove.cpp6
-rw-r--r--src/modules/m_safelist.cpp2
-rw-r--r--src/modules/m_sajoin.cpp4
-rw-r--r--src/modules/m_samode.cpp2
-rw-r--r--src/modules/m_sanick.cpp4
-rw-r--r--src/modules/m_sapart.cpp7
-rw-r--r--src/modules/m_saquit.cpp4
-rw-r--r--src/modules/m_sethost.cpp4
-rw-r--r--src/modules/m_setident.cpp4
-rw-r--r--src/modules/m_setidle.cpp4
-rw-r--r--src/modules/m_spanningtree.cpp180
-rw-r--r--src/modules/m_spy.cpp8
-rw-r--r--src/modules/m_swhois.cpp8
-rw-r--r--src/modules/m_timedbans.cpp4
-rw-r--r--src/modules/m_uninvite.cpp6
-rw-r--r--src/modules/m_userip.cpp4
-rw-r--r--src/modules/m_watch.cpp9
-rw-r--r--src/userprocess.cpp8
-rw-r--r--src/users.cpp68
-rw-r--r--src/xline.cpp10
80 files changed, 635 insertions, 637 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index d50841de7..a78b92642 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -224,7 +224,7 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo
int MOD_RESULT = 0;
strlcpy(cname,cn,CHANMAX);
- chanrec* Ptr = FindChan(cname);
+ chanrec* Ptr = Instance->FindChan(cname);
if (!Ptr)
{
@@ -455,7 +455,7 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr,ucrec *a,userrec* u
user->WriteServ("332 %s %s :%s", user->nick, Ptr->name, Ptr->topic);
user->WriteServ("333 %s %s %s %lu", user->nick, Ptr->name, Ptr->setby, (unsigned long)Ptr->topicset);
}
- userlist(user,Ptr);
+ Ptr->UserList(user);
user->WriteServ("366 %s %s :End of /NAMES list.", user->nick, Ptr->name);
}
FOREACH_MOD_I(Instance,I_OnUserJoin,OnUserJoin(user,Ptr));
@@ -739,3 +739,145 @@ void chanrec::WriteAllExceptSender(userrec* user, char status, const std::string
}
}
+/*
+ * return a count of the users on a specific channel accounting for
+ * invisible users who won't increase the count. e.g. for /LIST
+ */
+int chanrec::CountInvisible()
+{
+ int count = 0;
+ CUList *ulist= this->GetUsers();
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ if (!(i->second->modes[UM_INVISIBLE]))
+ count++;
+ }
+
+ return count;
+}
+
+char* chanrec::ChanModes(bool showkey)
+{
+ static char scratch[MAXBUF];
+ static char sparam[MAXBUF];
+ char* offset = scratch;
+ std::string extparam = "";
+
+ *scratch = '\0';
+ *sparam = '\0';
+
+ /* This was still iterating up to 190, chanrec::custom_modes is only 64 elements -- Om */
+ for(int n = 0; n < 64; n++)
+ {
+ if(this->modes[n])
+ {
+ *offset++ = n + 65;
+ extparam = "";
+ switch (n)
+ {
+ case CM_KEY:
+ extparam = (showkey ? this->key : "<key>");
+ break;
+ case CM_LIMIT:
+ extparam = ConvToStr(this->limit);
+ break;
+ case CM_NOEXTERNAL:
+ case CM_TOPICLOCK:
+ case CM_INVITEONLY:
+ case CM_MODERATED:
+ case CM_SECRET:
+ case CM_PRIVATE:
+ /* We know these have no parameters */
+ break;
+ default:
+ extparam = this->GetModeParameter(n + 65);
+ break;
+ }
+ if (extparam != "")
+ {
+ charlcat(sparam,' ',MAXBUF);
+ strlcat(sparam,extparam.c_str(),MAXBUF);
+ }
+ }
+ }
+
+ /* Null terminate scratch */
+ *offset = '\0';
+ strlcat(scratch,sparam,MAXBUF);
+ return scratch;
+}
+
+/* compile a userlist of a channel into a string, each nick seperated by
+ * spaces and op, voice etc status shown as @ and +, and send it to 'user'
+ */
+void chanrec::UserList(userrec *user)
+{
+ char list[MAXBUF];
+ size_t dlen, curlen;
+
+ dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, this->name);
+
+ int numusers = 0;
+ char* ptr = list + dlen;
+
+ CUList *ulist= this->GetUsers();
+
+ /* Improvement by Brain - this doesnt change in value, so why was it inside
+ * the loop?
+ */
+ bool has_user = this->HasUser(user);
+
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ if ((!has_user) && (i->second->modes[UM_INVISIBLE]))
+ {
+ /*
+ * user is +i, and source not on the channel, does not show
+ * nick in NAMES list
+ */
+ continue;
+ }
+
+ size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", cmode(i->second, this), i->second->nick);
+
+ curlen += ptrlen;
+ ptr += ptrlen;
+
+ numusers++;
+
+ if (curlen > (480-NICKMAX))
+ {
+ /* list overflowed into multiple numerics */
+ user->WriteServ(list);
+
+ /* reset our lengths */
+ dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, this->name);
+ ptr = list + dlen;
+
+ ptrlen = 0;
+ numusers = 0;
+ }
+ }
+
+ /* if whats left in the list isnt empty, send it */
+ if (numusers)
+ {
+ user->WriteServ(list);
+ }
+}
+
+long chanrec::GetMaxBans()
+{
+ std::string x;
+ for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
+ {
+ x = n->first;
+ if (match(this->name,x.c_str()))
+ {
+ return n->second;
+ }
+ }
+ return 64;
+}
+
+
diff --git a/src/cmd_die.cpp b/src/cmd_die.cpp
index 93b9f4987..366173758 100644
--- a/src/cmd_die.cpp
+++ b/src/cmd_die.cpp
@@ -53,6 +53,6 @@ void cmd_die::Handle (const char** parameters, int pcnt, userrec *user)
else
{
log(SPARSE, "Failed /DIE command from %s!%s@%s", user->nick, user->ident, user->host);
- WriteOpers("*** Failed DIE Command from %s!%s@%s.",user->nick,user->ident,user->host);
+ ServerInstance->WriteOpers("*** Failed DIE Command from %s!%s@%s.",user->nick,user->ident,user->host);
}
}
diff --git a/src/cmd_eline.cpp b/src/cmd_eline.cpp
index 4c674f262..e2679fc14 100644
--- a/src/cmd_eline.cpp
+++ b/src/cmd_eline.cpp
@@ -41,11 +41,11 @@ void cmd_eline::Handle (const char** parameters, int pcnt, userrec *user)
if (!duration(parameters[1]))
{
- WriteOpers("*** %s added permanent E-line for %s.",user->nick,parameters[0]);
+ ServerInstance->WriteOpers("*** %s added permanent E-line for %s.",user->nick,parameters[0]);
}
else
{
- WriteOpers("*** %s added timed E-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+ ServerInstance->WriteOpers("*** %s added timed E-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
}
}
else
@@ -53,7 +53,7 @@ void cmd_eline::Handle (const char** parameters, int pcnt, userrec *user)
if (del_eline(parameters[0]))
{
FOREACH_MOD(I_OnDelELine,OnDelELine(user, parameters[0]));
- WriteOpers("*** %s Removed E-line on %s.",user->nick,parameters[0]);
+ ServerInstance->WriteOpers("*** %s Removed E-line on %s.",user->nick,parameters[0]);
}
else
{
diff --git a/src/cmd_gline.cpp b/src/cmd_gline.cpp
index 2b774fb1d..ea526f8c8 100644
--- a/src/cmd_gline.cpp
+++ b/src/cmd_gline.cpp
@@ -41,11 +41,11 @@ void cmd_gline::Handle (const char** parameters, int pcnt, userrec *user)
if (!duration(parameters[1]))
{
- WriteOpers("*** %s added permanent G-line for %s.",user->nick,parameters[0]);
+ ServerInstance->WriteOpers("*** %s added permanent G-line for %s.",user->nick,parameters[0]);
}
else
{
- WriteOpers("*** %s added timed G-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+ ServerInstance->WriteOpers("*** %s added timed G-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
}
apply_lines(APPLY_GLINES);
@@ -55,7 +55,7 @@ void cmd_gline::Handle (const char** parameters, int pcnt, userrec *user)
if (del_gline(parameters[0]))
{
FOREACH_MOD(I_OnDelGLine,OnDelGLine(user, parameters[0]));
- WriteOpers("*** %s Removed G-line on %s.",user->nick,parameters[0]);
+ ServerInstance->WriteOpers("*** %s Removed G-line on %s.",user->nick,parameters[0]);
}
else
{
diff --git a/src/cmd_invite.cpp b/src/cmd_invite.cpp
index 0255c23dd..78de20cd8 100644
--- a/src/cmd_invite.cpp
+++ b/src/cmd_invite.cpp
@@ -34,8 +34,8 @@ void cmd_invite::Handle (const char** parameters, int pcnt, userrec *user)
if (pcnt == 2)
{
- userrec* u = Find(parameters[0]);
- chanrec* c = FindChan(parameters[1]);
+ userrec* u = ServerInstance->FindNick(parameters[0]);
+ chanrec* c = ServerInstance->FindChan(parameters[1]);
if ((!c) || (!u))
{
diff --git a/src/cmd_ison.cpp b/src/cmd_ison.cpp
index 0b0ec24a5..1fefeab1c 100644
--- a/src/cmd_ison.cpp
+++ b/src/cmd_ison.cpp
@@ -19,8 +19,11 @@
#include "users.h"
#include "commands.h"
#include "helperfuncs.h"
+#include "inspircd.h"
#include "commands/cmd_ison.h"
+extern InspIRCd* ServerInstance;
+
void cmd_ison::Handle (const char** parameters, int pcnt, userrec *user)
{
char retbuf[MAXBUF];
@@ -30,7 +33,7 @@ void cmd_ison::Handle (const char** parameters, int pcnt, userrec *user)
for (int i = 0; i < pcnt; i++)
{
- u = Find(parameters[i]);
+ u = ServerInstance->FindNick(parameters[i]);
if (u)
{
diff --git a/src/cmd_kick.cpp b/src/cmd_kick.cpp
index 042c6c02d..5c03921b6 100644
--- a/src/cmd_kick.cpp
+++ b/src/cmd_kick.cpp
@@ -18,13 +18,16 @@
#include "users.h"
#include "commands.h"
#include "helperfuncs.h"
+#include "inspircd.h"
#include "commands/cmd_kick.h"
+extern InspIRCd* ServerInstance;
+
void cmd_kick::Handle (const char** parameters, int pcnt, userrec *user)
{
char reason[MAXKICK];
- chanrec* c = FindChan(parameters[0]);
- userrec* u = Find(parameters[1]);
+ chanrec* c = ServerInstance->FindChan(parameters[0]);
+ userrec* u = ServerInstance->FindNick(parameters[1]);
if (!u || !c)
{
diff --git a/src/cmd_kill.cpp b/src/cmd_kill.cpp
index 22525e8cf..86a014267 100644
--- a/src/cmd_kill.cpp
+++ b/src/cmd_kill.cpp
@@ -31,7 +31,7 @@ extern std::vector<ircd_module*> factory;
void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
{
- userrec *u = Find(parameters[0]);
+ userrec *u = ServerInstance->FindNick(parameters[0]);
char killreason[MAXBUF];
int MOD_RESULT = 0;
@@ -51,7 +51,7 @@ void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
if (!IS_LOCAL(u))
{
// remote kill
- WriteOpers("*** Remote kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
+ ServerInstance->WriteOpers("*** Remote kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
snprintf(killreason, MAXQUIT,"[%s] Killed (%s (%s))", ServerInstance->Config->ServerName, user->nick, parameters[1]);
u->WriteCommonExcept("QUIT :%s", killreason);
FOREACH_MOD(I_OnRemoteKill, OnRemoteKill(user, u, killreason));
@@ -66,7 +66,7 @@ void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
if (u->registered == REG_ALL)
{
- purge_empty_chans(u);
+ u->PurgeEmptyChannels();
}
DELETE(u);
@@ -76,7 +76,7 @@ void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
// local kill
log(DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1]);
user->WriteTo(u, "KILL %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1]);
- WriteOpers("*** Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
+ ServerInstance->WriteOpers("*** Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
snprintf(killreason,MAXQUIT,"Killed (%s (%s))", user->nick, parameters[1]);
userrec::QuitUser(ServerInstance, u, killreason);
}
diff --git a/src/cmd_kline.cpp b/src/cmd_kline.cpp
index 3feb15d10..5bdba041d 100644
--- a/src/cmd_kline.cpp
+++ b/src/cmd_kline.cpp
@@ -49,11 +49,11 @@ void cmd_kline::Handle (const char** parameters, int pcnt, userrec *user)
if (!duration(parameters[1]))
{
- WriteOpers("*** %s added permanent K-line for %s.",user->nick,parameters[0]);
+ ServerInstance->WriteOpers("*** %s added permanent K-line for %s.",user->nick,parameters[0]);
}
else
{
- WriteOpers("*** %s added timed K-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+ ServerInstance->WriteOpers("*** %s added timed K-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
}
apply_lines(APPLY_KLINES);
@@ -63,7 +63,7 @@ void cmd_kline::Handle (const char** parameters, int pcnt, userrec *user)
if (del_kline(parameters[0]))
{
FOREACH_MOD(I_OnDelKLine,OnDelKLine(user, parameters[0]));
- WriteOpers("*** %s Removed K-line on %s.",user->nick,parameters[0]);
+ ServerInstance->WriteOpers("*** %s Removed K-line on %s.",user->nick,parameters[0]);
}
else
{
diff --git a/src/cmd_list.cpp b/src/cmd_list.cpp
index 3dbb3c2e2..ded20d077 100644
--- a/src/cmd_list.cpp
+++ b/src/cmd_list.cpp
@@ -34,7 +34,7 @@ void cmd_list::Handle (const char** parameters, int pcnt, userrec *user)
{
long users = i->second->GetUserCounter();
if (users)
- user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,users,chanmodes(i->second,n),i->second->topic);
+ user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,users,i->second->ChanModes(n),i->second->topic);
}
}
user->WriteServ("323 %s :End of channel list.",user->nick);
diff --git a/src/cmd_loadmodule.cpp b/src/cmd_loadmodule.cpp
index ace2debf7..bef24f321 100644
--- a/src/cmd_loadmodule.cpp
+++ b/src/cmd_loadmodule.cpp
@@ -26,7 +26,7 @@ void cmd_loadmodule::Handle (const char** parameters, int pcnt, userrec *user)
{
if (ServerInstance->LoadModule(parameters[0]))
{
- WriteOpers("*** NEW MODULE: %s",parameters[0]);
+ ServerInstance->WriteOpers("*** NEW MODULE: %s",parameters[0]);
user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
}
else
diff --git a/src/cmd_names.cpp b/src/cmd_names.cpp
index 318846d13..0ce00e4ba 100644
--- a/src/cmd_names.cpp
+++ b/src/cmd_names.cpp
@@ -35,7 +35,7 @@ void cmd_names::Handle (const char** parameters, int pcnt, userrec *user)
if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
return;
- c = FindChan(parameters[0]);
+ c = ServerInstance->FindChan(parameters[0]);
if (c)
{
if ((c->modes[CM_SECRET]) && (!c->HasUser(user)))
@@ -43,7 +43,7 @@ void cmd_names::Handle (const char** parameters, int pcnt, userrec *user)
user->WriteServ("401 %s %s :No such nick/channel",user->nick, c->name);
return;
}
- userlist(user,c);
+ c->UserList(user);
user->WriteServ("366 %s %s :End of /NAMES list.", user->nick, c->name);
}
else
diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp
index b0810a2e5..9313899f7 100644
--- a/src/cmd_nick.cpp
+++ b/src/cmd_nick.cpp
@@ -92,11 +92,11 @@ void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user)
}
if (matches_qline(parameters[0]))
{
- WriteOpers("*** Q-Lined nickname %s from %s!%s@%s: %s",parameters[0],user->nick,user->ident,user->host,matches_qline(parameters[0]));
+ ServerInstance->WriteOpers("*** Q-Lined nickname %s from %s!%s@%s: %s",parameters[0],user->nick,user->ident,user->host,matches_qline(parameters[0]));
user->WriteServ("432 %s %s :Invalid nickname: %s",user->nick,parameters[0],matches_qline(parameters[0]));
return;
}
- if ((Find(parameters[0])) && (Find(parameters[0]) != user))
+ if ((ServerInstance->FindNick(parameters[0])) && (ServerInstance->FindNick(parameters[0]) != user))
{
user->WriteServ("433 %s %s :Nickname is already in use.",user->nick,parameters[0]);
return;
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
index f1e814198..6825ea5ea 100644
--- a/src/cmd_notice.cpp
+++ b/src/cmd_notice.cpp
@@ -69,7 +69,7 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user)
}
if (*parameters[0] == '#')
{
- chan = FindChan(parameters[0]);
+ chan = ServerInstance->FindChan(parameters[0]);
if (chan)
{
if (IS_LOCAL(user))
@@ -113,7 +113,7 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user)
return;
}
- dest = Find(parameters[0]);
+ dest = ServerInstance->FindNick(parameters[0]);
if (dest)
{
int MOD_RESULT = 0;
diff --git a/src/cmd_oper.cpp b/src/cmd_oper.cpp
index 7fa598934..085b6983d 100644
--- a/src/cmd_oper.cpp
+++ b/src/cmd_oper.cpp
@@ -97,7 +97,7 @@ void cmd_oper::Handle (const char** parameters, int pcnt, userrec *user)
if (!isnick(TypeName))
{
user->WriteServ("491 %s :Invalid oper type (oper types must follow the same syntax as nicknames)",user->nick);
- WriteOpers("*** CONFIGURATION ERROR! Oper type invalid for OperType '%s'",OperType);
+ ServerInstance->WriteOpers("*** CONFIGURATION ERROR! Oper type invalid for OperType '%s'",OperType);
log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: credentials valid, but oper type erroneous.",user->nick,user->ident,user->host);
return;
}
@@ -113,7 +113,7 @@ void cmd_oper::Handle (const 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);
+ ServerInstance->WriteOpers("*** %s (%s@%s) is now an IRC operator of type %s",user->nick,user->ident,user->host,OperType);
user->WriteServ("381 %s :You are now an IRC operator of type %s",user->nick,OperType);
if (!user->modes[UM_OPERATOR])
user->Oper(OperType);
@@ -123,13 +123,13 @@ void cmd_oper::Handle (const char** parameters, int pcnt, userrec *user)
if (!fail2)
{
user->WriteServ("491 %s :Invalid oper credentials",user->nick);
- WriteOpers("*** WARNING! Failed oper attempt by %s!%s@%s!",user->nick,user->ident,user->host);
+ ServerInstance->WriteOpers("*** WARNING! Failed oper attempt by %s!%s@%s!",user->nick,user->ident,user->host);
log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: user, host or password did not match.",user->nick,user->ident,user->host);
}
else
{
user->WriteServ("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);
+ ServerInstance->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);
}
}
diff --git a/src/cmd_part.cpp b/src/cmd_part.cpp
index beb590ab9..88aab1abf 100644
--- a/src/cmd_part.cpp
+++ b/src/cmd_part.cpp
@@ -27,7 +27,7 @@ void cmd_part::Handle (const char** parameters, int pcnt, userrec *user)
if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
return;
- chanrec* c = FindChan(parameters[0]);
+ chanrec* c = ServerInstance->FindChan(parameters[0]);
if (c)
{
diff --git a/src/cmd_pass.cpp b/src/cmd_pass.cpp
index 7abb7f2ab..35a65b3c5 100644
--- a/src/cmd_pass.cpp
+++ b/src/cmd_pass.cpp
@@ -27,7 +27,7 @@ void cmd_pass::Handle (const char** parameters, int pcnt, userrec *user)
user->WriteServ("462 %s :You may not reregister",user->nick);
return;
}
- ConnectClass a = GetClass(user);
+ ConnectClass a = user->GetClass();
strlcpy(user->password,parameters[0],63);
if (!strcmp(parameters[0],a.pass.c_str()))
{
diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp
index 8a2175ecc..e72e1ef75 100644
--- a/src/cmd_privmsg.cpp
+++ b/src/cmd_privmsg.cpp
@@ -67,7 +67,7 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user)
}
if (parameters[0][0] == '#')
{
- chan = FindChan(parameters[0]);
+ chan = ServerInstance->FindChan(parameters[0]);
if (chan)
{
if (IS_LOCAL(user))
@@ -109,7 +109,7 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user)
return;
}
- dest = Find(parameters[0]);
+ dest = ServerInstance->FindNick(parameters[0]);
if (dest)
{
if ((IS_LOCAL(user)) && (*dest->awaymsg))
diff --git a/src/cmd_qline.cpp b/src/cmd_qline.cpp
index e38c02880..1452a0658 100644
--- a/src/cmd_qline.cpp
+++ b/src/cmd_qline.cpp
@@ -38,11 +38,11 @@ void cmd_qline::Handle (const char** parameters, int pcnt, userrec *user)
FOREACH_MOD(I_OnAddQLine,OnAddQLine(duration(parameters[1]), user, parameters[2], parameters[0]));
if (!duration(parameters[1]))
{
- WriteOpers("*** %s added permanent Q-line for %s.",user->nick,parameters[0]);
+ ServerInstance->WriteOpers("*** %s added permanent Q-line for %s.",user->nick,parameters[0]);
}
else
{
- WriteOpers("*** %s added timed Q-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+ ServerInstance->WriteOpers("*** %s added timed Q-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
}
apply_lines(APPLY_QLINES);
}
@@ -51,7 +51,7 @@ void cmd_qline::Handle (const char** parameters, int pcnt, userrec *user)
if (del_qline(parameters[0]))
{
FOREACH_MOD(I_OnDelQLine,OnDelQLine(user, parameters[0]));
- WriteOpers("*** %s Removed Q-line on %s.",user->nick,parameters[0]);
+ ServerInstance->WriteOpers("*** %s Removed Q-line on %s.",user->nick,parameters[0]);
}
else
{
diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp
index feaab0fe4..3673b8427 100644
--- a/src/cmd_quit.cpp
+++ b/src/cmd_quit.cpp
@@ -62,12 +62,12 @@ void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
if (user->fd > -1)
{
user->Write("ERROR :Closing link (%s@%s) [%s%s]",user->ident,user->host,ServerInstance->Config->PrefixQuit,parameters[0]);
- WriteOpers("*** Client exiting: %s!%s@%s [%s%s]",user->nick,user->ident,user->host,ServerInstance->Config->PrefixQuit,parameters[0]);
+ ServerInstance->WriteOpers("*** Client exiting: %s!%s@%s [%s%s]",user->nick,user->ident,user->host,ServerInstance->Config->PrefixQuit,parameters[0]);
user->WriteCommonExcept("QUIT :%s%s",ServerInstance->Config->PrefixQuit,parameters[0]);
}
else
{
- WriteOpers("*** Client exiting at %s: %s!%s@%s [%s]",user->server,user->nick,user->ident,user->host,parameters[0]);
+ ServerInstance->WriteOpers("*** Client exiting at %s: %s!%s@%s [%s]",user->server,user->nick,user->ident,user->host,parameters[0]);
user->WriteCommonExcept("QUIT :%s",parameters[0]);
}
FOREACH_MOD(I_OnUserQuit,OnUserQuit(user,std::string(ServerInstance->Config->PrefixQuit)+std::string(parameters[0])));
@@ -76,7 +76,7 @@ void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
else
{
user->Write("ERROR :Closing link (%s@%s) [QUIT]",user->ident,user->host);
- WriteOpers("*** Client exiting: %s!%s@%s [Client exited]",user->nick,user->ident,user->host);
+ ServerInstance->WriteOpers("*** Client exiting: %s!%s@%s [Client exited]",user->nick,user->ident,user->host);
user->WriteCommonExcept("QUIT :Client exited");
FOREACH_MOD(I_OnUserQuit,OnUserQuit(user,"Client exited"));
@@ -104,7 +104,7 @@ void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
}
if (user->registered == REG_ALL) {
- purge_empty_chans(user);
+ user->PurgeEmptyChannels();
}
if (user->fd > -1)
ServerInstance->fd_ref_table[user->fd] = NULL;
diff --git a/src/cmd_rehash.cpp b/src/cmd_rehash.cpp
index b452a8d0c..eeb8958f9 100644
--- a/src/cmd_rehash.cpp
+++ b/src/cmd_rehash.cpp
@@ -37,7 +37,7 @@ void cmd_rehash::Handle (const char** parameters, int pcnt, userrec *user)
}
else
{
- WriteOpers("%s is rehashing config file %s",user->nick,CleanFilename(CONFIG_FILE));
+ ServerInstance->WriteOpers("%s is rehashing config file %s",user->nick,CleanFilename(CONFIG_FILE));
ServerInstance->Config->Read(false,user);
}
FOREACH_MOD(I_OnRehash,OnRehash(parameter));
diff --git a/src/cmd_restart.cpp b/src/cmd_restart.cpp
index 81c45386f..318a8ee31 100644
--- a/src/cmd_restart.cpp
+++ b/src/cmd_restart.cpp
@@ -28,7 +28,7 @@ void cmd_restart::Handle (const char** parameters, int pcnt, userrec *user)
log(DEFAULT,"Restart: %s",user->nick);
if (!strcmp(parameters[0],ServerInstance->Config->restartpass))
{
- WriteOpers("*** RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host);
+ ServerInstance->WriteOpers("*** RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host);
argv[0] = ServerInstance->Config->MyExecutable;
argv[1] = "-wait";
@@ -58,6 +58,6 @@ void cmd_restart::Handle (const char** parameters, int pcnt, userrec *user)
}
else
{
- WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host);
+ ServerInstance->WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host);
}
}
diff --git a/src/cmd_server.cpp b/src/cmd_server.cpp
index bd41e5595..93274e040 100644
--- a/src/cmd_server.cpp
+++ b/src/cmd_server.cpp
@@ -17,10 +17,13 @@
#include "users.h"
#include "commands.h"
#include "helperfuncs.h"
+#include "inspircd.h"
#include "commands/cmd_server.h"
+extern InspIRCd* ServerInstance;
+
void cmd_server::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ("666 %s :You cannot identify as a server, you are a USER. IRC Operators informed.",user->nick);
- WriteOpers("*** WARNING: %s attempted to issue a SERVER command and is registered as a user!",user->nick);
+ ServerInstance->WriteOpers("*** WARNING: %s attempted to issue a SERVER command and is registered as a user!",user->nick);
}
diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp
index 6f124d6eb..194b8b24c 100644
--- a/src/cmd_stats.cpp
+++ b/src/cmd_stats.cpp
@@ -260,7 +260,7 @@ void DoStats(char statschar, userrec* user, string_list &results)
}
results.push_back(sn+" 219 "+user->nick+" "+statschar+" :End of /STATS report");
- WriteOpers("*** Notice: %s '%c' requested by %s (%s@%s)",(!strcmp(user->server,ServerInstance->Config->ServerName) ? "Stats" : "Remote stats"),statschar,user->nick,user->ident,user->host);
+ ServerInstance->WriteOpers("*** Notice: %s '%c' requested by %s (%s@%s)",(!strcmp(user->server,ServerInstance->Config->ServerName) ? "Stats" : "Remote stats"),statschar,user->nick,user->ident,user->host);
return;
}
diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp
index 913b80dd3..bd7308f26 100644
--- a/src/cmd_topic.cpp
+++ b/src/cmd_topic.cpp
@@ -35,7 +35,7 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
if (pcnt == 1)
{
- Ptr = FindChan(parameters[0]);
+ Ptr = ServerInstance->FindChan(parameters[0]);
if (Ptr)
{
if ((Ptr->modes[CM_SECRET]) && (!Ptr->HasUser(user)))
@@ -61,7 +61,7 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
}
else if (pcnt>1)
{
- Ptr = FindChan(parameters[0]);
+ Ptr = ServerInstance->FindChan(parameters[0]);
if (Ptr)
{
if (IS_LOCAL(user))
diff --git a/src/cmd_unloadmodule.cpp b/src/cmd_unloadmodule.cpp
index ca1667d1a..70cf2c698 100644
--- a/src/cmd_unloadmodule.cpp
+++ b/src/cmd_unloadmodule.cpp
@@ -26,7 +26,7 @@ void cmd_unloadmodule::Handle (const char** parameters, int pcnt, userrec *user)
{
if (ServerInstance->UnloadModule(parameters[0]))
{
- WriteOpers("*** MODULE UNLOADED: %s",parameters[0]);
+ ServerInstance->WriteOpers("*** MODULE UNLOADED: %s",parameters[0]);
user->WriteServ("973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
}
else
diff --git a/src/cmd_userhost.cpp b/src/cmd_userhost.cpp
index 49a81c402..64210b57a 100644
--- a/src/cmd_userhost.cpp
+++ b/src/cmd_userhost.cpp
@@ -18,8 +18,11 @@
#include "users.h"
#include "commands.h"
#include "helperfuncs.h"
+#include "inspircd.h"
#include "commands/cmd_userhost.h"
+extern InspIRCd* ServerInstance;
+
void cmd_userhost::Handle (const char** parameters, int pcnt, userrec *user)
{
char Return[MAXBUF],junk[MAXBUF];
@@ -27,7 +30,7 @@ void cmd_userhost::Handle (const char** parameters, int pcnt, userrec *user)
for (int i = 0; i < pcnt; i++)
{
- userrec *u = Find(parameters[i]);
+ userrec *u = ServerInstance->FindNick(parameters[i]);
if(u)
{
if(*u->oper)
diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp
index de3f30196..140fa92e2 100644
--- a/src/cmd_who.cpp
+++ b/src/cmd_who.cpp
@@ -115,7 +115,7 @@ void cmd_who::Handle (const char** parameters, int pcnt, userrec *user)
/* who on a channel? */
- ch = FindChan(matchtext);
+ ch = ServerInstance->FindChan(matchtext);
if (ch)
{
diff --git a/src/cmd_whois.cpp b/src/cmd_whois.cpp
index 5f980750b..09e8eea65 100644
--- a/src/cmd_whois.cpp
+++ b/src/cmd_whois.cpp
@@ -24,7 +24,7 @@
#include "commands/cmd_whois.h"
extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
+
extern int MODCOUNT;
extern ModuleList modules;
extern FactoryList factory;
@@ -68,7 +68,7 @@ void do_whois(userrec* user, userrec* dest,unsigned long signon, unsigned long i
}
else
{
- user->WriteServ("312 %s %s %s :%s",user->nick, dest->nick, dest->server, GetServerDescription(dest->server).c_str());
+ user->WriteServ("312 %s %s %s :%s",user->nick, dest->nick, dest->server, ServerInstance->GetServerDescription(dest->server).c_str());
}
if (*dest->awaymsg)
{
@@ -107,7 +107,7 @@ void cmd_whois::Handle (const char** parameters, int pcnt, userrec *user)
if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
return;
- dest = Find(parameters[0]);
+ dest = ServerInstance->FindNick(parameters[0]);
if (dest)
{
do_whois(user,dest,0,0,parameters[0]);
@@ -119,3 +119,4 @@ void cmd_whois::Handle (const char** parameters, int pcnt, userrec *user)
user->WriteServ("318 %s %s :End of /WHOIS list.",user->nick, parameters[0]);
}
}
+
diff --git a/src/cmd_zline.cpp b/src/cmd_zline.cpp
index cb838b2de..ab068479e 100644
--- a/src/cmd_zline.cpp
+++ b/src/cmd_zline.cpp
@@ -44,11 +44,11 @@ void cmd_zline::Handle (const char** parameters, int pcnt, userrec *user)
FOREACH_MOD(I_OnAddZLine,OnAddZLine(duration(parameters[1]), user, parameters[2], parameters[0]));
if (!duration(parameters[1]))
{
- WriteOpers("*** %s added permanent Z-line for %s.",user->nick,parameters[0]);
+ ServerInstance->WriteOpers("*** %s added permanent Z-line for %s.",user->nick,parameters[0]);
}
else
{
- WriteOpers("*** %s added timed Z-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+ ServerInstance->WriteOpers("*** %s added timed Z-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
}
apply_lines(APPLY_ZLINES);
}
@@ -57,7 +57,7 @@ void cmd_zline::Handle (const char** parameters, int pcnt, userrec *user)
if (del_zline(parameters[0]))
{
FOREACH_MOD(I_OnDelZLine,OnDelZLine(user, parameters[0]));
- WriteOpers("*** %s Removed Z-line on %s.",user->nick,parameters[0]);
+ ServerInstance->WriteOpers("*** %s Removed Z-line on %s.",user->nick,parameters[0]);
}
else
{
diff --git a/src/commands.cpp b/src/commands.cpp
index b1eb51490..8a7e38204 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -209,7 +209,7 @@ bool host_matches_everyone(const std::string &mask, userrec* user)
float percent = ((float)matches / (float)ServerInstance->clientlist.size()) * 100;
if (percent > (float)atof(itrigger))
{
- WriteOpers("*** \2WARNING\2: %s tried to set a G/K/E line mask of %s, which covers %.2f%% of the network!",user->nick,mask.c_str(),percent);
+ ServerInstance->WriteOpers("*** \2WARNING\2: %s tried to set a G/K/E line mask of %s, which covers %.2f%% of the network!",user->nick,mask.c_str(),percent);
return true;
}
return false;
@@ -235,7 +235,7 @@ bool ip_matches_everyone(const std::string &ip, userrec* user)
float percent = ((float)matches / (float)ServerInstance->clientlist.size()) * 100;
if (percent > (float)atof(itrigger))
{
- WriteOpers("*** \2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick,ip.c_str(),percent);
+ ServerInstance->WriteOpers("*** \2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick,ip.c_str(),percent);
return true;
}
return false;
@@ -261,7 +261,7 @@ bool nick_matches_everyone(const std::string &nick, userrec* user)
float percent = ((float)matches / (float)ServerInstance->clientlist.size()) * 100;
if (percent > (float)atof(itrigger))
{
- WriteOpers("*** \2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick,nick.c_str(),percent);
+ ServerInstance->WriteOpers("*** \2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick,nick.c_str(),percent);
return true;
}
return false;
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 0b712ca6c..184387890 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -27,7 +27,6 @@
#include "userprocess.h"
#include "xline.h"
-extern InspIRCd* ServerInstance;
extern time_t TIME;
extern int MODCOUNT;
@@ -38,7 +37,7 @@ using irc::sockets::BindPorts;
std::vector<std::string> old_module_names, new_module_names, added_modules, removed_modules;
-ServerConfig::ServerConfig()
+ServerConfig::ServerConfig(InspIRCd* Instance) : ServerInstance(Instance)
{
this->ClearStack();
*TempDir = *ServerName = *Network = *ServerDesc = *AdminName = '\0';
@@ -116,8 +115,8 @@ bool ServerConfig::CheckOnce(char* tag, bool bail, userrec* user)
}
else
{
- WriteOpers("There were errors in the configuration file:");
- WriteOpers("You have more than one <%s> tag, this is not permitted.\n",tag);
+ ServerInstance->WriteOpers("There were errors in the configuration file:");
+ ServerInstance->WriteOpers("You have more than one <%s> tag, this is not permitted.\n",tag);
}
}
return false;
@@ -138,8 +137,8 @@ bool ServerConfig::CheckOnce(char* tag, bool bail, userrec* user)
}
else
{
- WriteOpers("There were errors in the configuration file:");
- WriteOpers("You have not defined a <%s> tag, this is required.",tag);
+ ServerInstance->WriteOpers("There were errors in the configuration file:");
+ ServerInstance->WriteOpers("You have not defined a <%s> tag, this is required.",tag);
}
}
return false;
@@ -285,20 +284,20 @@ bool ValidateServerName(ServerConfig* conf, const char* tag, const char* value,
bool ValidateNetBufferSize(ServerConfig* conf, const char* tag, const char* value, void* data)
{
- if ((!ServerInstance->Config->NetBufferSize) || (ServerInstance->Config->NetBufferSize > 65535) || (ServerInstance->Config->NetBufferSize < 1024))
+ if ((!conf->NetBufferSize) || (conf->NetBufferSize > 65535) || (conf->NetBufferSize < 1024))
{
log(DEFAULT,"No NetBufferSize specified or size out of range, setting to default of 10240.");
- ServerInstance->Config->NetBufferSize = 10240;
+ conf->NetBufferSize = 10240;
}
return true;
}
bool ValidateMaxWho(ServerConfig* conf, const char* tag, const char* value, void* data)
{
- if ((!ServerInstance->Config->MaxWhoResults) || (ServerInstance->Config->MaxWhoResults > 65535) || (ServerInstance->Config->MaxWhoResults < 1))
+ if ((!conf->MaxWhoResults) || (conf->MaxWhoResults > 65535) || (conf->MaxWhoResults < 1))
{
log(DEFAULT,"No MaxWhoResults specified or size out of range, setting to default of 128.");
- ServerInstance->Config->MaxWhoResults = 128;
+ conf->MaxWhoResults = 128;
}
return true;
}
@@ -306,32 +305,32 @@ bool ValidateMaxWho(ServerConfig* conf, const char* tag, const char* value, void
bool ValidateLogLevel(ServerConfig* conf, const char* tag, const char* value, void* data)
{
const char* dbg = (const char*)data;
- ServerInstance->Config->LogLevel = DEFAULT;
+ conf->LogLevel = DEFAULT;
if (!strcmp(dbg,"debug"))
{
- ServerInstance->Config->LogLevel = DEBUG;
- ServerInstance->Config->debugging = 1;
+ conf->LogLevel = DEBUG;
+ conf->debugging = 1;
}
else if (!strcmp(dbg,"verbose"))
- ServerInstance->Config->LogLevel = VERBOSE;
+ conf->LogLevel = VERBOSE;
else if (!strcmp(dbg,"default"))
- ServerInstance->Config->LogLevel = DEFAULT;
+ conf->LogLevel = DEFAULT;
else if (!strcmp(dbg,"sparse"))
- ServerInstance->Config->LogLevel = SPARSE;
+ conf->LogLevel = SPARSE;
else if (!strcmp(dbg,"none"))
- ServerInstance->Config->LogLevel = NONE;
+ conf->LogLevel = NONE;
return true;
}
bool ValidateMotd(ServerConfig* conf, const char* tag, const char* value, void* data)
{
- conf->ReadFile(ServerInstance->Config->MOTD,ServerInstance->Config->motd);
+ conf->ReadFile(conf->MOTD,conf->motd);
return true;
}
bool ValidateRules(ServerConfig* conf, const char* tag, const char* value, void* data)
{
- conf->ReadFile(ServerInstance->Config->RULES,ServerInstance->Config->rules);
+ conf->ReadFile(conf->RULES,conf->rules);
return true;
}
@@ -340,7 +339,7 @@ bool ValidateRules(ServerConfig* conf, const char* tag, const char* value, void*
bool InitConnect(ServerConfig* conf, const char* tag)
{
log(DEFAULT,"Reading connect classes...");
- ServerInstance->Config->Classes.clear();
+ conf->Classes.clear();
return true;
}
@@ -394,13 +393,13 @@ bool DoConnect(ServerConfig* conf, const char* tag, char** entries, void** value
c.registration_timeout = 90;
if (c.pingtime == 0)
c.pingtime = 120;
- ServerInstance->Config->Classes.push_back(c);
+ conf->Classes.push_back(c);
}
else
{
c.host = deny;
c.type = CC_DENY;
- ServerInstance->Config->Classes.push_back(c);
+ conf->Classes.push_back(c);
log(DEBUG,"Read connect class type DENY, host=%s",deny);
}
@@ -419,7 +418,7 @@ bool DoneConnect(ServerConfig* conf, const char* tag)
*/
bool InitULine(ServerConfig* conf, const char* tag)
{
- ServerInstance->Config->ulines.clear();
+ conf->ulines.clear();
return true;
}
@@ -429,7 +428,7 @@ bool DoULine(ServerConfig* conf, const char* tag, char** entries, void** values,
{
char* server = (char*)values[0];
log(DEBUG,"Read ULINE '%s'",server);
- ServerInstance->Config->ulines.push_back(server);
+ conf->ulines.push_back(server);
return true;
}
@@ -448,7 +447,7 @@ bool InitModule(ServerConfig* conf, const char* tag)
new_module_names.clear();
added_modules.clear();
removed_modules.clear();
- for (std::vector<std::string>::iterator t = ServerInstance->Config->module_names.begin(); t != ServerInstance->Config->module_names.end(); t++)
+ for (std::vector<std::string>::iterator t = conf->module_names.begin(); t != conf->module_names.end(); t++)
{
old_module_names.push_back(*t);
}
@@ -503,7 +502,7 @@ bool DoneModule(ServerConfig* conf, const char* tag)
*/
bool InitMaxBans(ServerConfig* conf, const char* tag)
{
- ServerInstance->Config->maxbans.clear();
+ conf->maxbans.clear();
return true;
}
@@ -513,7 +512,7 @@ bool DoMaxBans(ServerConfig* conf, const char* tag, char** entries, void** value
{
char* channel = (char*)values[0];
int* limit = (int*)values[1];
- ServerInstance->Config->maxbans[channel] = *limit;
+ conf->maxbans[channel] = *limit;
return true;
}
@@ -694,11 +693,11 @@ void ServerConfig::Read(bool bail, userrec* user)
}
else
{
- WriteOpers("There were errors in the configuration file:");
+ ServerInstance->WriteOpers("There were errors in the configuration file:");
while(start < errors.length())
{
- WriteOpers(errors.substr(start, 360).c_str());
+ ServerInstance->WriteOpers(errors.substr(start, 360).c_str());
start += 360;
}
}
@@ -809,7 +808,7 @@ void ServerConfig::Read(bool bail, userrec* user)
{
if (ServerInstance->UnloadModule(removing->c_str()))
{
- WriteOpers("*** REHASH UNLOADED MODULE: %s",removing->c_str());
+ ServerInstance->WriteOpers("*** REHASH UNLOADED MODULE: %s",removing->c_str());
if (user)
user->WriteServ("973 %s %s :Module %s successfully unloaded.",user->nick, removing->c_str(), removing->c_str());
@@ -828,7 +827,7 @@ void ServerConfig::Read(bool bail, userrec* user)
{
if (ServerInstance->LoadModule(adding->c_str()))
{
- WriteOpers("*** REHASH LOADED MODULE: %s",adding->c_str());
+ ServerInstance->WriteOpers("*** REHASH LOADED MODULE: %s",adding->c_str());
if (user)
user->WriteServ("975 %s %s :Module %s successfully loaded.",user->nick, adding->c_str(), adding->c_str());
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 1f2a6646b..8bfba1ca5 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -102,7 +102,7 @@ void InspIRCd::Log(int level, const std::string &text)
}
}
-std::string GetServerDescription(const char* servername)
+std::string InspIRCd::GetServerDescription(const char* servername)
{
std::string description = "";
@@ -115,7 +115,7 @@ std::string GetServerDescription(const char* servername)
else
{
// not a remote server that can be found, it must be me.
- return ServerInstance->Config->ServerDesc;
+ return Config->ServerDesc;
}
}
@@ -126,43 +126,27 @@ std::string GetServerDescription(const char* servername)
* uses the oper list, which means if you have 2000 users but only 5 opers,
* it iterates 5 times.
*/
-void WriteOpers(const char* text, ...)
+void InspIRCd::WriteOpers(const char* text, ...)
{
char textbuffer[MAXBUF];
va_list argsPtr;
- if (!text)
- {
- log(DEFAULT,"*** BUG *** WriteOpers was given an invalid parameter");
- return;
- }
-
va_start(argsPtr, text);
vsnprintf(textbuffer, MAXBUF, text, argsPtr);
va_end(argsPtr);
- WriteOpers_NoFormat(textbuffer);
+ this->WriteOpers(std::string(textbuffer));
}
-void WriteOpers_NoFormat(const char* text)
+void InspIRCd::WriteOpers(const std::string &text)
{
- if (!text)
- {
- log(DEFAULT,"*** BUG *** WriteOpers_NoFormat was given an invalid parameter");
- return;
- }
-
for (std::vector<userrec*>::iterator i = all_opers.begin(); i != all_opers.end(); i++)
{
userrec* a = *i;
-
- if (IS_LOCAL(a))
+ if (IS_LOCAL(a) && a->modes[UM_SERVERNOTICE])
{
- if (a->modes[UM_SERVERNOTICE])
- {
- // send server notices to all with +s
- a->WriteServ("NOTICE %s :%s",a->nick,text);
- }
+ // send server notices to all with +s
+ a->WriteServ("NOTICE %s :%s",a->nick,text.c_str());
}
}
}
@@ -285,27 +269,27 @@ void strlower(char *n)
/* Find a user record by nickname and return a pointer to it */
-userrec* Find(const std::string &nick)
+userrec* InspIRCd::FindNick(const std::string &nick)
{
- user_hash::iterator iter = ServerInstance->clientlist.find(nick);
+ user_hash::iterator iter = clientlist.find(nick);
- if (iter == ServerInstance->clientlist.end())
+ if (iter == clientlist.end())
/* Couldn't find it */
return NULL;
return iter->second;
}
-userrec* Find(const char* nick)
+userrec* InspIRCd::FindNick(const char* nick)
{
user_hash::iterator iter;
if (!nick)
return NULL;
- iter = ServerInstance->clientlist.find(nick);
+ iter = clientlist.find(nick);
- if (iter == ServerInstance->clientlist.end())
+ if (iter == clientlist.end())
return NULL;
return iter->second;
@@ -313,239 +297,33 @@ userrec* Find(const char* nick)
/* find a channel record by channel name and return a pointer to it */
-chanrec* FindChan(const char* chan)
+chanrec* InspIRCd::FindChan(const char* chan)
{
chan_hash::iterator iter;
if (!chan)
- {
- log(DEFAULT,"*** BUG *** Findchan was given an invalid parameter");
return NULL;
- }
- iter = ServerInstance->chanlist.find(chan);
+ iter = chanlist.find(chan);
- if (iter == ServerInstance->chanlist.end())
+ if (iter == chanlist.end())
/* Couldn't find it */
return NULL;
return iter->second;
}
-
-long GetMaxBans(char* name)
-{
- std::string x;
- for (std::map<std::string,int>::iterator n = ServerInstance->Config->maxbans.begin(); n != ServerInstance->Config->maxbans.end(); n++)
- {
- x = n->first;
- if (match(name,x.c_str()))
- {
- return n->second;
- }
- }
- return 64;
-}
-
-void purge_empty_chans(userrec* u)
-{
- std::vector<chanrec*> to_delete;
-
- // firstly decrement the count on each channel
- for (std::vector<ucrec*>::iterator f = u->chans.begin(); f != u->chans.end(); f++)
- {
- ucrec* uc = (ucrec*)(*f);
- if (uc->channel)
- {
- if (uc->channel->DelUser(u) == 0)
- {
- /* No users left in here, mark it for deletion */
- to_delete.push_back(uc->channel);
- uc->channel = NULL;
- }
- }
- }
-
- log(DEBUG,"purge_empty_chans: %d channels to delete",to_delete.size());
-
- for (std::vector<chanrec*>::iterator n = to_delete.begin(); n != to_delete.end(); n++)
- {
- chanrec* thischan = (chanrec*)*n;
- chan_hash::iterator i2 = ServerInstance->chanlist.find(thischan->name);
- if (i2 != ServerInstance->chanlist.end())
- {
- FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(i2->second));
- DELETE(i2->second);
- ServerInstance->chanlist.erase(i2);
- }
- }
-
- u->UnOper();
-}
-
-
-char* chanmodes(chanrec *chan, bool showkey)
-{
- static char scratch[MAXBUF];
- static char sparam[MAXBUF];
- char* offset = scratch;
- std::string extparam = "";
-
- if (!chan)
- {
- log(DEFAULT,"*** BUG *** chanmodes was given an invalid parameter");
- *scratch = '\0';
- return scratch;
- }
-
- *scratch = '\0';
- *sparam = '\0';
-
- /* This was still iterating up to 190, chanrec::custom_modes is only 64 elements -- Om */
- for(int n = 0; n < 64; n++)
- {
- if(chan->modes[n])
- {
- *offset++ = n+65;
- extparam = "";
- switch (n)
- {
- case CM_KEY:
- extparam = (showkey ? chan->key : "<key>");
- break;
- case CM_LIMIT:
- extparam = ConvToStr(chan->limit);
- break;
- case CM_NOEXTERNAL:
- case CM_TOPICLOCK:
- case CM_INVITEONLY:
- case CM_MODERATED:
- case CM_SECRET:
- case CM_PRIVATE:
- /* We know these have no parameters */
- break;
- default:
- extparam = chan->GetModeParameter(n+65);
- break;
- }
- if (extparam != "")
- {
- charlcat(sparam,' ',MAXBUF);
- strlcat(sparam,extparam.c_str(),MAXBUF);
- }
- }
- }
-
- /* Null terminate scratch */
- *offset = '\0';
- strlcat(scratch,sparam,MAXBUF);
- return scratch;
-}
-
-
-/* compile a userlist of a channel into a string, each nick seperated by
- * spaces and op, voice etc status shown as @ and + */
-
-void userlist(userrec *user,chanrec *c)
-{
- if ((!c) || (!user))
- {
- log(DEFAULT,"*** BUG *** userlist was given an invalid parameter");
- return;
- }
-
- char list[MAXBUF];
- size_t dlen, curlen;
-
- dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
-
- int numusers = 0;
- char* ptr = list + dlen;
-
- CUList *ulist= c->GetUsers();
-
- /* Improvement by Brain - this doesnt change in value, so why was it inside
- * the loop?
- */
- bool has_user = c->HasUser(user);
-
- for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- if ((!has_user) && (i->second->modes[UM_INVISIBLE]))
- {
- /*
- * user is +i, and source not on the channel, does not show
- * nick in NAMES list
- */
- continue;
- }
-
- size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", cmode(i->second, c), i->second->nick);
-
- curlen += ptrlen;
- ptr += ptrlen;
-
- numusers++;
-
- if (curlen > (480-NICKMAX))
- {
- /* list overflowed into multiple numerics */
- user->WriteServ(list);
-
- /* reset our lengths */
- dlen = curlen = snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name);
- ptr = list + dlen;
-
- ptrlen = 0;
- numusers = 0;
- }
- }
-
- /* if whats left in the list isnt empty, send it */
- if (numusers)
- {
- user->WriteServ(list);
- }
-}
-
-/*
- * return a count of the users on a specific channel accounting for
- * invisible users who won't increase the count. e.g. for /LIST
- */
-int usercount_i(chanrec *c)
+chanrec* InspIRCd::FindChan(const std::string &chan)
{
- int count = 0;
-
- if (!c)
- return 0;
+ chan_hash::iterator iter = chanlist.find(chan);
- CUList *ulist= c->GetUsers();
- for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- if (!(i->second->modes[UM_INVISIBLE]))
- count++;
- }
+ if (iter == chanlist.end())
+ /* Couldn't find it */
+ return NULL;
- return count;
+ return iter->second;
}
-/* looks up a users password for their connection class (<ALLOW>/<DENY> tags)
- * NOTE: If the <ALLOW> or <DENY> tag specifies an ip, and this user resolves,
- * then their ip will be taken as 'priority' anyway, so for example,
- * <connect allow="127.0.0.1"> will match joe!bloggs@localhost
- */
-ConnectClass GetClass(userrec *user)
-{
- for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
- {
- if ((match(user->GetIPString(),i->host.c_str(),true)) || (match(user->host,i->host.c_str())))
- {
- return *i;
- }
- }
-
- return *(ServerInstance->Config->Classes.begin());
-}
/*
* sends out an error notice to all connected clients (not to be used
@@ -590,7 +368,7 @@ void Error(int status)
log(DEFAULT,"[%d] %s", i, strings[i]);
}
free(strings);
- WriteOpers("*** SIGSEGV: Please see the ircd.log for backtrace and report the error to http://www.inspircd.org/bugtrack/");
+ ServerInstance->WriteOpers("*** SIGSEGV: Please see the ircd.log for backtrace and report the error to http://www.inspircd.org/bugtrack/");
#else
log(DEFAULT,"You do not have execinfo.h so i could not backtrace -- on FreeBSD, please install the libexecinfo port.");
#endif
@@ -902,42 +680,6 @@ bool IsValidChannelName(const char *chname)
return true;
}
-inline int charlcat(char* x,char y,int z)
-{
- char* x__n = x;
- int v = 0;
-
- while(*x__n++)
- v++;
-
- if (v < z - 1)
- {
- *--x__n = y;
- *++x__n = 0;
- }
-
- return v;
-}
-
-bool charremove(char* mp, char remove)
-{
- char* mptr = mp;
- bool shift_down = false;
-
- while (*mptr)
- {
- if (*mptr == remove)
- shift_down = true;
-
- if (shift_down)
- *mptr = *(mptr+1);
-
- mptr++;
- }
-
- return shift_down;
-}
-
void OpenLog(char** argv, int argc)
{
if (!*LOG_FILE)
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 9f38eec7e..7d5cf6dc5 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -142,7 +142,7 @@ void Killed(int status)
void Rehash(int status)
{
- WriteOpers("Rehashing config file %s due to SIGHUP",CleanFilename(CONFIG_FILE));
+ ServerInstance->WriteOpers("Rehashing config file %s due to SIGHUP",CleanFilename(CONFIG_FILE));
fclose(ServerInstance->Config->log_file);
OpenLog(NULL,0);
ServerInstance->Config->Read(false,NULL);
@@ -228,8 +228,8 @@ void InspIRCd::MakeLowerMap()
InspIRCd::InspIRCd(int argc, char** argv)
{
bool SEGVHandler = false;
- this->Config = new ServerConfig;
ServerInstance = this;
+ this->Config = new ServerConfig(this);
this->Start();
this->module_sockets.clear();
this->startup_time = time(NULL);
@@ -304,7 +304,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
Config->Read(true, NULL);
CheckRoot();
this->ModeGrok = new ModeParser();
- AddServerName(Config->ServerName);
+ this->AddServerName(Config->ServerName);
CheckDie();
InitializeDisabledCommands(Config->DisabledCommands, this);
stats->BoundPortCount = BindPorts(true);
diff --git a/src/inspstring.cpp b/src/inspstring.cpp
index 4f1875b8c..71aed43ba 100644
--- a/src/inspstring.cpp
+++ b/src/inspstring.cpp
@@ -74,7 +74,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz)
do
{
if ((*d++ = *s++) == 0)
- break;
+ break;
} while (--n != 0);
}
@@ -90,3 +90,40 @@ size_t strlcpy(char *dst, const char *src, size_t siz)
return(s - src - 1); /* count does not include NUL */
}
#endif
+
+int charlcat(char* x,char y,int z)
+{
+ char* x__n = x;
+ int v = 0;
+
+ while(*x__n++)
+ v++;
+
+ if (v < z - 1)
+ {
+ *--x__n = y;
+ *++x__n = 0;
+ }
+
+ return v;
+}
+
+bool charremove(char* mp, char remove)
+{
+ char* mptr = mp;
+ bool shift_down = false;
+
+ while (*mptr)
+ {
+ if (*mptr == remove)
+ shift_down = true;
+
+ if (shift_down)
+ *mptr = *(mptr+1);
+
+ mptr++;
+ }
+
+ return shift_down;
+}
+
diff --git a/src/mode.cpp b/src/mode.cpp
index 7747664ac..266d06350 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -168,7 +168,7 @@ userrec* ModeParser::SanityChecks(userrec *user,const char *dest,chanrec *chan,i
{
return NULL;
}
- d = Find(dest);
+ d = ServerInstance->FindNick(dest);
if (!d)
{
user->WriteServ("401 %s %s :No such nick/channel",user->nick, dest);
@@ -250,7 +250,7 @@ void ModeParser::DisplayCurrentModes(userrec *user, userrec* targetuser, chanrec
if (targetchannel)
{
/* Display channel's current mode string */
- user->WriteServ("324 %s %s +%s",user->nick, targetchannel->name, chanmodes(targetchannel, targetchannel->HasUser(user)));
+ user->WriteServ("324 %s %s +%s",user->nick, targetchannel->name, targetchannel->ChanModes(targetchannel->HasUser(user)));
user->WriteServ("329 %s %s %d", user->nick, targetchannel->name, targetchannel->created);
return;
}
@@ -272,8 +272,8 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
std::string target = parameters[0];
ModeType type = MODETYPE_USER;
unsigned char mask = 0;
- chanrec* targetchannel = FindChan(parameters[0]);
- userrec* targetuser = Find(parameters[0]);
+ chanrec* targetchannel = ServerInstance->FindChan(parameters[0]);
+ userrec* targetuser = ServerInstance->FindNick(parameters[0]);
log(DEBUG,"ModeParser::Process start");
diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp
index 47913bdc0..d0c783ad9 100644
--- a/src/modes/cmode_b.cpp
+++ b/src/modes/cmode_b.cpp
@@ -71,7 +71,7 @@ std::string& ModeChannelBan::AddBan(userrec *user,std::string &dest,chanrec *cha
if (dest == "")
return dest;
- long maxbans = GetMaxBans(chan->name);
+ long maxbans = chan->GetMaxBans();
if ((unsigned)chan->bans.size() > (unsigned)maxbans)
{
user->WriteServ("478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %d)",user->nick, chan->name,chan->name,maxbans);
diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp
index 5137bfd4a..49bf08288 100644
--- a/src/modes/cmode_h.cpp
+++ b/src/modes/cmode_h.cpp
@@ -16,7 +16,7 @@
#include "modes/cmode_h.h"
extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
+
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
extern int MODCOUNT;
@@ -28,17 +28,17 @@ ModeChannelHalfOp::ModeChannelHalfOp() : ModeHandler('h', 1, 1, true, MODETYPE_C
ModePair ModeChannelHalfOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
- userrec* x = Find(parameter);
+ userrec* x = ServerInstance->FindNick(parameter);
if (x)
{
- if (cstatus(x, channel) == STATUS_HOP)
- {
- return std::make_pair(true, x->nick);
- }
- else
- {
- return std::make_pair(false, parameter);
- }
+ if (cstatus(x, channel) == STATUS_HOP)
+ {
+ return std::make_pair(true, x->nick);
+ }
+ else
+ {
+ return std::make_pair(false, parameter);
+ }
}
return std::make_pair(false, parameter);
}
diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp
index e8c3cbed7..580fcc636 100644
--- a/src/modes/cmode_o.cpp
+++ b/src/modes/cmode_o.cpp
@@ -16,7 +16,7 @@
#include "modes/cmode_o.h"
extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
+
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
extern int MODCOUNT;
@@ -28,18 +28,18 @@ ModeChannelOp::ModeChannelOp() : ModeHandler('o', 1, 1, true, MODETYPE_CHANNEL,
ModePair ModeChannelOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
- userrec* x = Find(parameter);
- if (x)
- {
- if (cstatus(x, channel) == STATUS_OP)
- {
- return std::make_pair(true, x->nick);
- }
- else
- {
- return std::make_pair(false, parameter);
- }
- }
+ userrec* x = ServerInstance->FindNick(parameter);
+ if (x)
+ {
+ if (cstatus(x, channel) == STATUS_OP)
+ {
+ return std::make_pair(true, x->nick);
+ }
+ else
+ {
+ return std::make_pair(false, parameter);
+ }
+ }
return std::make_pair(false, parameter);
}
diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp
index ddac844ec..b93a04f49 100644
--- a/src/modes/cmode_v.cpp
+++ b/src/modes/cmode_v.cpp
@@ -16,7 +16,7 @@
#include "modes/cmode_v.h"
extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
+
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
extern int MODCOUNT;
@@ -28,18 +28,18 @@ ModeChannelVoice::ModeChannelVoice() : ModeHandler('v', 1, 1, true, MODETYPE_CHA
ModePair ModeChannelVoice::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
- userrec* x = Find(parameter);
- if (x)
- {
- if (cstatus(x, channel) == STATUS_VOICE)
- {
- return std::make_pair(true, x->nick);
- }
- else
- {
- return std::make_pair(false, parameter);
- }
- }
+ userrec* x = ServerInstance->FindNick(parameter);
+ if (x)
+ {
+ if (cstatus(x, channel) == STATUS_VOICE)
+ {
+ return std::make_pair(true, x->nick);
+ }
+ else
+ {
+ return std::make_pair(false, parameter);
+ }
+ }
return std::make_pair(false, parameter);
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 1566ac5d7..da4a7e152 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -326,7 +326,7 @@ const std::string& Server::GetModuleName(Module* m)
void Server::RehashServer()
{
- WriteOpers("*** Rehashing config file");
+ ServerInstance->WriteOpers("*** Rehashing config file");
ServerInstance->Config->Read(false,NULL);
}
@@ -375,11 +375,6 @@ chanrec* Server::GetChannelIndex(long index)
return NULL;
}
-void Server::SendOpers(const std::string &s)
-{
- WriteOpers("%s",s.c_str());
-}
-
bool Server::MatchText(const std::string &sliteral, const std::string &spattern)
{
return match(sliteral.c_str(),spattern.c_str());
@@ -440,21 +435,11 @@ bool Server::IsNick(const std::string &nick)
return (isnick(nick.c_str()) != 0);
}
-userrec* Server::FindNick(const std::string &nick)
-{
- return Find(nick);
-}
-
userrec* Server::FindDescriptor(int socket)
{
return (socket < 65536 ? ServerInstance->fd_ref_table[socket] : NULL);
}
-chanrec* Server::FindChannel(const std::string &channel)
-{
- return FindChan(channel.c_str());
-}
-
std::string Server::ChanMode(userrec* User, chanrec* Chan)
{
return cmode(User,Chan);
@@ -553,7 +538,7 @@ bool InspIRCd::PseudoToUser(userrec* alive, userrec* zombie, const std::string &
zombie->WriteServ("332 %s %s :%s", zombie->nick, Ptr->name, Ptr->topic);
zombie->WriteServ("333 %s %s %s %d", zombie->nick, Ptr->name, Ptr->setby, Ptr->topicset);
}
- userlist(zombie,Ptr);
+ Ptr->UserList(zombie);
zombie->WriteServ("366 %s %s :End of /NAMES list.", zombie->nick, Ptr->name);
}
}
@@ -786,11 +771,11 @@ void ConfigReader::DumpErrors(bool bail, userrec* user)
}
else
{
- WriteOpers("There were errors in the configuration file:");
+ ServerInstance->WriteOpers("There were errors in the configuration file:");
while(start < errors.length())
{
- WriteOpers(errors.substr(start, 360).c_str());
+ ServerInstance->WriteOpers(errors.substr(start, 360).c_str());
start += 360;
}
}
diff --git a/src/modules/extra/m_sqlauth.cpp b/src/modules/extra/m_sqlauth.cpp
index 93d763cb5..bc72e0e0c 100644
--- a/src/modules/extra/m_sqlauth.cpp
+++ b/src/modules/extra/m_sqlauth.cpp
@@ -130,7 +130,7 @@ public:
log(DEBUG, "SQLrequest failed: %s", req.error.Str());
if (verbose)
- WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, req.error.Str());
+ ServerInstance->WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, req.error.Str());
return false;
}
@@ -170,14 +170,14 @@ public:
else if (verbose)
{
/* No rows in result, this means there was no record matching the user */
- WriteOpers("Forbidden connection from %s!%s@%s (SQL query returned no matches)", user->nick, user->ident, user->host);
+ ServerInstance->WriteOpers("Forbidden connection from %s!%s@%s (SQL query returned no matches)", user->nick, user->ident, user->host);
user->Extend("sqlauth_failed");
}
}
else if (verbose)
{
log(DEBUG, "Query failed: %s", res->error.Str());
- WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, res->error.Str());
+ ServerInstance->WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, res->error.Str());
user->Extend("sqlauth_failed");
}
}
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index 2ec6085fc..9d48b1034 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -25,6 +25,8 @@ using namespace std;
/* $ModDesc: Provides aliases of commands. */
+extern InspIRCd* ServerInstance;
+
class Alias : public classbase
{
public:
@@ -106,7 +108,7 @@ class ModuleAlias : public Module
{
if (Aliases[i].requires != "")
{
- u = Srv->FindNick(Aliases[i].requires);
+ u = ServerInstance->FindNick(Aliases[i].requires);
if (!u)
{
user->WriteServ("401 "+std::string(user->nick)+" "+Aliases[i].requires+" :is currently unavailable. Please try again later.");
@@ -117,7 +119,7 @@ class ModuleAlias : public Module
{
if (!Srv->IsUlined(u->server))
{
- Srv->SendOpers("*** NOTICE -- Service "+Aliases[i].requires+" required by alias "+std::string(Aliases[i].text.c_str())+" is not on a u-lined server, possibly underhanded antics detected!");
+ ServerInstance->WriteOpers("*** NOTICE -- Service "+Aliases[i].requires+" required by alias "+std::string(Aliases[i].text.c_str())+" is not on a u-lined server, possibly underhanded antics detected!");
user->WriteServ("401 "+std::string(user->nick)+" "+Aliases[i].requires+" :is an imposter! Please inform an IRC operator as soon as possible.");
return 1;
}
diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp
index 9567f2de7..b22b5b327 100644
--- a/src/modules/m_blockamsg.cpp
+++ b/src/modules/m_blockamsg.cpp
@@ -140,7 +140,7 @@ public:
{
// Block it...
if(action == IBLOCK_KILLOPERS || action == IBLOCK_NOTICEOPERS)
- WriteOpers("*** %s had an /amsg or /ame denied", user->nick);
+ ServerInstance->WriteOpers("*** %s had an /amsg or /ame denied", user->nick);
if(action == IBLOCK_KILL || action == IBLOCK_KILLOPERS)
userrec::QuitUser(ServerInstance, user, "Global message (/amsg or /ame) detected");
diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp
index eb971864b..e4fa5d91b 100644
--- a/src/modules/m_cban.cpp
+++ b/src/modules/m_cban.cpp
@@ -28,6 +28,8 @@
/* $ModDesc: Gives /cban, aka C:lines. Think Q:lines, for channels. */
+extern InspIRCd* ServerInstance;
+
class CBan : public classbase
{
public:
@@ -109,12 +111,12 @@ class cmd_cban : public command_t
if(length > 0)
{
user->WriteServ( "385 %s %s :Added %lu second channel ban (%s)", user->nick, parameters[0], length, reason.c_str());
- WriteOpers("*** %s added %lu second channel ban on %s (%s)", user->nick, length, parameters[0], reason.c_str());
+ ServerInstance->WriteOpers("*** %s added %lu second channel ban on %s (%s)", user->nick, length, parameters[0], reason.c_str());
}
else
{
user->WriteServ( "385 %s %s :Added permenant channel ban (%s)", user->nick, parameters[0], reason.c_str());
- WriteOpers("*** %s added permenant channel ban on %s (%s)", user->nick, parameters[0], reason.c_str());
+ ServerInstance->WriteOpers("*** %s added permenant channel ban on %s (%s)", user->nick, parameters[0], reason.c_str());
}
}
else
@@ -170,7 +172,7 @@ class ModuleCBan : public Module
{
// Channel is banned.
user->WriteServ( "384 %s %s :Cannot join channel, CBANed (%s)", user->nick, cname, iter->reason.c_str());
- WriteOpers("*** %s tried to join %s which is CBANed (%s)", user->nick, cname, iter->reason.c_str());
+ ServerInstance->WriteOpers("*** %s tried to join %s which is CBANed (%s)", user->nick, cname, iter->reason.c_str());
return 1;
}
}
@@ -245,7 +247,7 @@ void ExpireBans()
if (iter->set_on + iter->length <= TIME)
{
log(DEBUG, "m_cban.so: Ban on %s expired, removing...", iter->chname.c_str());
- WriteOpers("*** %li second CBAN on %s (%s) set %u seconds ago expired", iter->length, iter->chname.c_str(), iter->reason.c_str(), TIME - iter->set_on);
+ ServerInstance->WriteOpers("*** %li second CBAN on %s (%s) set %u seconds ago expired", iter->length, iter->chname.c_str(), iter->reason.c_str(), TIME - iter->set_on);
cbans.erase(iter);
go_again = true;
}
diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp
index 31b5dc092..7bb46b753 100644
--- a/src/modules/m_cgiirc.cpp
+++ b/src/modules/m_cgiirc.cpp
@@ -63,7 +63,7 @@ class CGIResolver : public Resolver
if ((them) && (them == ServerInstance->fd_ref_table[theirfd]))
{
if (notify)
- WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", them->nick, them->host, result.c_str(), typ.c_str());
+ ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", them->nick, them->host, result.c_str(), typ.c_str());
strlcpy(them->host, result.c_str(), 63);
strlcpy(them->dhost, result.c_str(), 63);
@@ -76,7 +76,7 @@ class CGIResolver : public Resolver
if ((them) && (them == ServerInstance->fd_ref_table[theirfd]))
{
if (notify)
- WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but their host can't be resolved from their %s!", them->nick, them->host,typ.c_str());
+ ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but their host can't be resolved from their %s!", them->nick, them->host,typ.c_str());
}
}
@@ -253,7 +253,7 @@ public:
log(DEBUG, "m_cgiirc.so: Got an IP in the user's password");
if(NotifyOpers)
- WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from PASS", user->nick, user->host, user->password);
+ ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from PASS", user->nick, user->host, user->password);
}
else
{
@@ -268,14 +268,14 @@ public:
catch (ModuleException& e)
{
if (NotifyOpers)
- WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but i could not resolve their hostname!", user->nick, user->host);
+ ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but i could not resolve their hostname!", user->nick, user->host);
}
}
*user->password = 0;
/*if(NotifyOpers)
- WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from PASS", user->nick, user->host, user->password);*/
+ ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from PASS", user->nick, user->host, user->password);*/
return true;
}
@@ -328,7 +328,7 @@ public:
strlcpy(user->ident, "~cgiirc", 8);
if(NotifyOpers)
- WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but i could not resolve their hostname!", user->nick, user->host);
+ ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but i could not resolve their hostname!", user->nick, user->host);
}
/*strlcpy(user->host, newip, 16);
strlcpy(user->dhost, newip, 16);
diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp
index 53e725504..41b78f98b 100644
--- a/src/modules/m_chanprotect.cpp
+++ b/src/modules/m_chanprotect.cpp
@@ -22,6 +22,8 @@
/* $ModDesc: Provides channel modes +a and +q */
+extern InspIRCd* ServerInstance;
+
const char* fakevalue = "on";
class ChanFounder : public ModeHandler
@@ -34,7 +36,7 @@ class ChanFounder : public ModeHandler
ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
- userrec* x = Find(parameter);
+ userrec* x = ServerInstance->FindNick(parameter);
if (x)
{
if (!channel->HasUser(x))
@@ -60,7 +62,7 @@ class ChanFounder : public ModeHandler
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
- userrec* theuser = Srv->FindNick(parameter);
+ userrec* theuser = ServerInstance->FindNick(parameter);
log(DEBUG,"ChanFounder::OnModeChange");
@@ -149,7 +151,7 @@ class ChanProtect : public ModeHandler
ModePair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter)
{
- userrec* x = Find(parameter);
+ userrec* x = ServerInstance->FindNick(parameter);
if (x)
{
if (!channel->HasUser(x))
@@ -174,7 +176,7 @@ class ChanProtect : public ModeHandler
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
- userrec* theuser = Srv->FindNick(parameter);
+ userrec* theuser = ServerInstance->FindNick(parameter);
// cant find the user given as the parameter, eat the mode change.
if (!theuser)
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp
index 7dcb86d38..f8d84154e 100644
--- a/src/modules/m_check.cpp
+++ b/src/modules/m_check.cpp
@@ -53,8 +53,8 @@ class cmd_check : public command_t
checkstr = "304 " + std::string(user->nick) + " :CHECK";
- targuser = Srv->FindNick(std::string(parameters[0]));
- targchan = Srv->FindChannel(std::string(parameters[0]));
+ targuser = ServerInstance->FindNick(parameters[0]);
+ targchan = ServerInstance->FindChan(parameters[0]);
/*
* Syntax of a /check reply:
@@ -114,7 +114,7 @@ class cmd_check : public command_t
user->WriteServ(checkstr + " topic_setat " + timebuf);
}
- user->WriteServ(checkstr + " modes " + chanmodes(targchan, true));
+ user->WriteServ(checkstr + " modes " + targchan->ChanModes(true));
user->WriteServ(checkstr + " membercount " + ConvToStr(targchan->GetUserCounter()));
/* now the ugly bit, spool current members of a channel. :| */
diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp
index 23a482a65..fc5507822 100644
--- a/src/modules/m_chghost.cpp
+++ b/src/modules/m_chghost.cpp
@@ -22,10 +22,12 @@ using namespace std;
#include "channels.h"
#include "modules.h"
#include "helperfuncs.h"
+#include "inspircd.h"
/* $ModDesc: Provides support for the CHGHOST command */
static Server *Srv;
+extern InspIRCd* ServerInstance;
class cmd_chghost : public command_t
{
@@ -56,13 +58,13 @@ class cmd_chghost : public command_t
user->WriteServ("NOTICE %s :*** CHGHOST: Host too long",user->nick);
return;
}
- userrec* dest = Srv->FindNick(std::string(parameters[0]));
+ userrec* dest = ServerInstance->FindNick(parameters[0]);
if (dest)
{
if ((dest->ChangeDisplayedHost(parameters[1])) && (!Srv->IsUlined(user->server)))
{
// fix by brain - ulines set hosts silently
- Srv->SendOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+std::string(dest->nick)+" become "+std::string(parameters[1]));
+ ServerInstance->WriteOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+dest->nick+" become "+parameters[1]);
}
}
}
diff --git a/src/modules/m_chgident.cpp b/src/modules/m_chgident.cpp
index 7cb09127a..391f4b20b 100644
--- a/src/modules/m_chgident.cpp
+++ b/src/modules/m_chgident.cpp
@@ -3,9 +3,12 @@
#include "modules.h"
#include "message.h"
#include "helperfuncs.h"
+#include "inspircd.h"
/* $ModDesc: Provides support for the CHGIDENT command */
+extern InspIRCd* ServerInstance;
+
class cmd_chgident : public command_t
{
Server* Srv;
@@ -19,8 +22,8 @@ class cmd_chgident : public command_t
void Handle(const char** parameters, int pcnt, userrec *user)
{
- userrec* dest = Srv->FindNick(std::string(parameters[0]));
-
+ userrec* dest = ServerInstance->FindNick(parameters[0]);
+
if(dest)
{
if(!isident(parameters[1]))
@@ -29,7 +32,7 @@ class cmd_chgident : public command_t
return;
}
- WriteOpers("%s used CHGIDENT to change %s's ident from '%s' to '%s'", user->nick, dest->nick, dest->ident, parameters[1]);
+ ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident from '%s' to '%s'", user->nick, dest->nick, dest->ident, parameters[1]);
strlcpy(dest->ident, parameters[1], IDENTMAX+2);
}
else
diff --git a/src/modules/m_connflood.cpp b/src/modules/m_connflood.cpp
index b1a9d8c7c..85ea0a84d 100644
--- a/src/modules/m_connflood.cpp
+++ b/src/modules/m_connflood.cpp
@@ -95,7 +95,7 @@ public:
{
/* expire throttle */
throttled = 0;
- Srv->SendOpers("*** Connection throttle deactivated");
+ ServerInstance->WriteOpers("*** Connection throttle deactivated");
return;
}
userrec::QuitUser(ServerInstance, user, quitmsg);
@@ -107,7 +107,7 @@ public:
if (conns >= maxconns)
{
throttled = 1;
- Srv->SendOpers("*** Connection throttle activated");
+ ServerInstance->WriteOpers("*** Connection throttle activated");
userrec::QuitUser(ServerInstance, user, quitmsg);
return;
}
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 0f9477921..13e68f943 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -107,11 +107,8 @@ class ModuleFilter : public Module
if (f->action == "block")
{
- Srv->SendOpers(std::string("FILTER: ")+std::string(user->nick)+
- std::string(" had their notice filtered, target was ")+
- target+": "+f->reason);
- user->WriteServ("NOTICE "+std::string(user->nick)+
- " :Your notice has been filtered and opers notified: "+f->reason);
+ ServerInstance->WriteOpers(std::string("FILTER: ")+user->nick+" had their notice filtered, target was "+target+": "+f->reason);
+ user->WriteServ("NOTICE "+std::string(user->nick)+" :Your notice has been filtered and opers notified: "+f->reason);
}
Srv->Log(DEFAULT,std::string("FILTER: ")+std::string(user->nick)+
std::string(" had their notice filtered, target was ")+
diff --git a/src/modules/m_globalload.cpp b/src/modules/m_globalload.cpp
index ca5bdda7e..8e68d48a6 100644
--- a/src/modules/m_globalload.cpp
+++ b/src/modules/m_globalload.cpp
@@ -40,7 +40,7 @@ class cmd_gloadmodule : public command_t
{
if (ServerInstance->LoadModule(parameters[0]))
{
- WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
+ ServerInstance->WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
}
else
@@ -63,7 +63,7 @@ class cmd_gunloadmodule : public command_t
{
if (ServerInstance->UnloadModule(parameters[0]))
{
- WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
+ ServerInstance->WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
user->WriteServ("973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
}
else
diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp
index fa4f27f04..a8f66b6a7 100644
--- a/src/modules/m_httpd_stats.cpp
+++ b/src/modules/m_httpd_stats.cpp
@@ -145,7 +145,7 @@ class ModuleHttpStats : public Module
int n = 0;
for (SortedIter a = so->begin(); ((a != so->end()) && (n < 25)); a++, n++)
{
- chanrec* c = Srv->FindChannel(a->second.c_str());
+ chanrec* c = ServerInstance->FindChan(a->second.c_str());
if (c)
{
data << "<tr><td>" << a->first << "</td><td>" << a->second << "</td>";
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index 8f040cd38..e681f02d6 100644
--- a/src/modules/m_knock.cpp
+++ b/src/modules/m_knock.cpp
@@ -27,6 +27,7 @@ using namespace std;
/* $ModDesc: Provides support for /KNOCK and mode +K */
static Server *Srv;
+extern InspIRCd* ServerInstance;
class cmd_knock : public command_t
{
@@ -39,7 +40,7 @@ class cmd_knock : public command_t
void Handle (const char** parameters, int pcnt, userrec *user)
{
- chanrec* c = Srv->FindChannel(parameters[0]);
+ chanrec* c = ServerInstance->FindChan(parameters[0]);
if (!c)
{
diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp
index e46b56901..58a4c2686 100644
--- a/src/modules/m_nicklock.cpp
+++ b/src/modules/m_nicklock.cpp
@@ -23,6 +23,7 @@ using namespace std;
#include "modules.h"
#include "helperfuncs.h"
#include "hashcomp.h"
+#include "inspircd.h"
/* $ModDesc: Provides the NICKLOCK command, allows an oper to chage a users nick and lock them to it until they quit */
@@ -41,7 +42,7 @@ class cmd_nicklock : public command_t
void Handle(const char** parameters, int pcnt, userrec *user)
{
- userrec* source = Srv->FindNick(std::string(parameters[0]));
+ userrec* source = ServerInstance->FindNick(parameters[0]);
irc::string server;
irc::string me;
@@ -55,7 +56,7 @@ class cmd_nicklock : public command_t
if (Srv->IsNick(std::string(parameters[1])))
{
// give them a lock flag
- Srv->SendOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+std::string(parameters[0])+" to "+parameters[1]);
+ ServerInstance->WriteOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+parameters[0]+" to "+parameters[1]);
if (!source->ForceNickChange(parameters[1]))
{
userrec::QuitUser(ServerInstance, source, "Nickname collision");
@@ -78,12 +79,12 @@ class cmd_nickunlock : public command_t
void Handle (const char** parameters, int pcnt, userrec *user)
{
- userrec* source = Srv->FindNick(std::string(parameters[0]));
+ userrec* source = ServerInstance->FindNick(parameters[0]);
if (source)
{
source->Shrink("nick_locked");
user->WriteServ("945 %s %s :Nickname now unlocked.",user->nick,source->nick);
- Srv->SendOpers(std::string(user->nick)+" used NICKUNLOCK on "+std::string(parameters[0]));
+ ServerInstance->WriteOpers(std::string(user->nick)+" used NICKUNLOCK on "+parameters[0]);
}
}
};
diff --git a/src/modules/m_operlevels.cpp b/src/modules/m_operlevels.cpp
index cc248718f..0c97765b9 100644
--- a/src/modules/m_operlevels.cpp
+++ b/src/modules/m_operlevels.cpp
@@ -9,6 +9,8 @@ using namespace std;
/* $ModDesc: Gives each oper type a 'level', cannot kill opers 'above' your level. */
+extern InspIRCd* ServerInstance;
+
class ModuleOperLevels : public Module
{
@@ -74,7 +76,7 @@ class ModuleOperLevels : public Module
}
if (dest_level > source_level)
{
- WriteOpers("Oper %s (level %d) attempted to /kill a higher oper: %s (level %d): Reason: %s",source->nick,source_level,dest->nick,dest_level,reason.c_str());
+ ServerInstance->WriteOpers("Oper %s (level %d) attempted to /kill a higher oper: %s (level %d): Reason: %s",source->nick,source_level,dest->nick,dest_level,reason.c_str());
dest->WriteServ("NOTICE %s :Oper %s attempted to /kill you!",dest->nick,source->nick);
source->WriteServ("481 %s :Permission Denied- Oper %s is a higher level than you",source->nick,dest->nick);
return 1;
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index c16a2125f..4f188b0cb 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -22,6 +22,8 @@
/* $ModDesc: Provides support for unreal-style oper-override */
+extern InspIRCd* ServerInstance;
+
typedef std::map<std::string,std::string> override_t;
class ModuleOverride : public Module
@@ -93,7 +95,7 @@ class ModuleOverride : public Module
{
if (((Srv->ChanMode(source,chan) == "%") && (Srv->ChanMode(user,chan) == "@")) || (Srv->ChanMode(source,chan) == ""))
{
- Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Kicked "+std::string(user->nick)+" on "+std::string(chan->name)+" ("+reason+")");
+ ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Kicked "+std::string(user->nick)+" on "+std::string(chan->name)+" ("+reason+")");
}
/* Returning -1 explicitly allows the kick */
return -1;
@@ -117,7 +119,7 @@ class ModuleOverride : public Module
case AC_DEOP:
if (CanOverride(source,"MODEDEOP"))
{
- Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Deopped "+std::string(dest->nick)+" on "+std::string(channel->name));
+ ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Deopped "+std::string(dest->nick)+" on "+std::string(channel->name));
return ACR_ALLOW;
}
else
@@ -128,7 +130,7 @@ class ModuleOverride : public Module
case AC_OP:
if (CanOverride(source,"MODEOP"))
{
- Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Opped "+std::string(dest->nick)+" on "+std::string(channel->name));
+ ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Opped "+std::string(dest->nick)+" on "+std::string(channel->name));
return ACR_ALLOW;
}
else
@@ -139,7 +141,7 @@ class ModuleOverride : public Module
case AC_VOICE:
if (CanOverride(source,"MODEVOICE"))
{
- Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Voiced "+std::string(dest->nick)+" on "+std::string(channel->name));
+ ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Voiced "+std::string(dest->nick)+" on "+std::string(channel->name));
return ACR_ALLOW;
}
else
@@ -150,7 +152,7 @@ class ModuleOverride : public Module
case AC_DEVOICE:
if (CanOverride(source,"MODEDEVOICE"))
{
- Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Devoiced "+std::string(dest->nick)+" on "+std::string(channel->name));
+ ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Devoiced "+std::string(dest->nick)+" on "+std::string(channel->name));
return ACR_ALLOW;
}
else
@@ -161,7 +163,7 @@ class ModuleOverride : public Module
case AC_HALFOP:
if (CanOverride(source,"MODEHALFOP"))
{
- Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Halfopped "+std::string(dest->nick)+" on "+std::string(channel->name));
+ ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Halfopped "+std::string(dest->nick)+" on "+std::string(channel->name));
return ACR_ALLOW;
}
else
@@ -172,7 +174,7 @@ class ModuleOverride : public Module
case AC_DEHALFOP:
if (CanOverride(source,"MODEDEHALFOP"))
{
- Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Dehalfopped "+std::string(dest->nick)+" on "+std::string(channel->name));
+ ServerInstance->WriteOpers("*** NOTICE: "+std::string(source->nick)+" Override-Dehalfopped "+std::string(dest->nick)+" on "+std::string(channel->name));
return ACR_ALLOW;
}
else
@@ -213,7 +215,7 @@ class ModuleOverride : public Module
chan->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :%s invited himself into the channel", cname, user->nick);
}
}
- Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +i on "+std::string(cname));
+ ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used operoverride to bypass +i on "+std::string(cname));
return -1;
}
@@ -221,7 +223,7 @@ class ModuleOverride : public Module
{
if (NoisyOverride)
chan->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :%s bypassed the channel key", cname, user->nick);
- Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +k on "+std::string(cname));
+ ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used operoverride to bypass +k on "+std::string(cname));
return -1;
}
@@ -229,7 +231,7 @@ class ModuleOverride : public Module
{
if (NoisyOverride)
chan->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :%s passed through your channel limit", cname, user->nick);
- Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +l on "+std::string(cname));
+ ServerInstance->WriteOpers("*** "+std::string(user->nick)+" used operoverride to bypass +l on "+std::string(cname));
return -1;
}
diff --git a/src/modules/m_park.cpp b/src/modules/m_park.cpp
index 8502fbfdb..3629e9b48 100644
--- a/src/modules/m_park.cpp
+++ b/src/modules/m_park.cpp
@@ -146,7 +146,7 @@ class cmd_unpark : public command_t
*
* And there you have it, easy huh (NOT)...
*/
- userrec* unpark = Srv->FindNick(std::string(parameters[0]));
+ userrec* unpark = ServerInstance->FindNick(parameters[0]);
if (!unpark)
{
user->WriteServ("942 %s %s :Invalid user specified.",user->nick, parameters[0]);
@@ -322,7 +322,7 @@ class ModulePark : public Module
{
if (time(NULL) >= (j->parktime+ParkMaxTime))
{
- userrec* thisnick = Srv->FindNick(j->nick);
+ userrec* thisnick = ServerInstance->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!
diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp
index 4d8d717ab..c143cab52 100644
--- a/src/modules/m_redirect.cpp
+++ b/src/modules/m_redirect.cpp
@@ -60,7 +60,7 @@ class Redirect : public ModeHandler
return MODEACTION_DENY;
}
- c = Srv->FindChannel(parameter);
+ c = ServerInstance->FindChan(parameter);
if (c)
{
/* Fix by brain: Dont let a channel be linked to *itself* either */
diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp
index a5657f604..587edac86 100644
--- a/src/modules/m_remove.cpp
+++ b/src/modules/m_remove.cpp
@@ -17,6 +17,8 @@
* eg: +h can remove +hv and users with no modes. +a can remove +aohv and users with no modes.
*/
+extern InspIRCd* ServerInstance;
+
class RemoveBase
{
private:
@@ -85,10 +87,10 @@ class RemoveBase
username = parameters[ neworder ? 1 : 0];
/* Look up the user we're meant to be removing from the channel */
- target = Srv->FindNick(username);
+ target = ServerInstance->FindNick(username);
/* And the channel we're meant to be removing them from */
- channel = Srv->FindChannel(channame);
+ channel = ServerInstance->FindChan(channame);
/* Fix by brain - someone needs to learn to validate their input! */
if (!target || !channel)
diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp
index 000d1e7d6..2aa5a02f6 100644
--- a/src/modules/m_safelist.cpp
+++ b/src/modules/m_safelist.cpp
@@ -107,7 +107,7 @@ class ListTimer : public InspTimer
long users = chan->GetUserCounter();
if (users)
{
- int counter = snprintf(buffer,MAXBUF,"322 %s %s %ld :[+%s] %s",u->nick,chan->name,users,chanmodes(chan,has_user),chan->topic);
+ int counter = snprintf(buffer,MAXBUF,"322 %s %s %ld :[+%s] %s",u->nick,chan->name,users,chan->ChanModes(has_user),chan->topic);
/* Increment total plus linefeed */
amount_sent += counter + 4 + Srv->GetServerName().length();
log(DEBUG,"m_safelist.so: Sent %ld of safe %ld / 4",amount_sent,u->sendqmax);
diff --git a/src/modules/m_sajoin.cpp b/src/modules/m_sajoin.cpp
index af03f47d7..65babdfa4 100644
--- a/src/modules/m_sajoin.cpp
+++ b/src/modules/m_sajoin.cpp
@@ -40,7 +40,7 @@ class cmd_sajoin : public command_t
void Handle (const char** parameters, int pcnt, userrec *user)
{
- userrec* dest = Srv->FindNick(std::string(parameters[0]));
+ userrec* dest = ServerInstance->FindNick(parameters[0]);
if (dest)
{
if (Srv->IsUlined(dest->server))
@@ -55,7 +55,7 @@ class cmd_sajoin : public command_t
return;
}
- Srv->SendOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
+ ServerInstance->WriteOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]);
chanrec::JoinUser(ServerInstance, dest, parameters[1], true);
}
}
diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp
index 012bfed89..104e5da33 100644
--- a/src/modules/m_samode.cpp
+++ b/src/modules/m_samode.cpp
@@ -68,7 +68,7 @@ class cmd_samode : public command_t
result.append(" ");
result.append(parameters[n]);
}
- Srv->SendOpers(result);
+ ServerInstance->WriteOpers(result);
}
};
diff --git a/src/modules/m_sanick.cpp b/src/modules/m_sanick.cpp
index db35b9ba5..a323844d5 100644
--- a/src/modules/m_sanick.cpp
+++ b/src/modules/m_sanick.cpp
@@ -39,7 +39,7 @@ class cmd_sanick : public command_t
void Handle (const char** parameters, int pcnt, userrec *user)
{
- userrec* source = Srv->FindNick(std::string(parameters[0]));
+ userrec* source = ServerInstance->FindNick(parameters[0]);
if (source)
{
if (Srv->IsUlined(source->server))
@@ -51,7 +51,7 @@ class cmd_sanick : public command_t
{
// FIX by brain: Cant use source->nick here because if it traverses a server link then
// source->nick becomes invalid as the object data moves in memory.
- Srv->SendOpers(std::string(user->nick)+" used SANICK to change "+std::string(parameters[0])+" to "+parameters[1]);
+ ServerInstance->WriteOpers(std::string(user->nick)+" used SANICK to change "+std::string(parameters[0])+" to "+parameters[1]);
if (!source->ForceNickChange(parameters[1]))
{
/* We couldnt change the nick */
diff --git a/src/modules/m_sapart.cpp b/src/modules/m_sapart.cpp
index 4493a178f..fb4117b42 100644
--- a/src/modules/m_sapart.cpp
+++ b/src/modules/m_sapart.cpp
@@ -27,6 +27,7 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style SAPART command */
static Server *Srv;
+extern InspIRCd* ServerInstance;
class cmd_sapart : public command_t
{
@@ -39,8 +40,8 @@ class cmd_sapart : public command_t
void Handle (const char** parameters, int pcnt, userrec *user)
{
- userrec* dest = Srv->FindNick(parameters[0]);
- chanrec* channel = Srv->FindChannel(parameters[1]);
+ userrec* dest = ServerInstance->FindNick(parameters[0]);
+ chanrec* channel = ServerInstance->FindChan(parameters[1]);
if (dest && channel)
{
if (Srv->IsUlined(dest->server))
@@ -48,7 +49,7 @@ class cmd_sapart : public command_t
user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
return;
}
- Srv->SendOpers(std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
+ ServerInstance->WriteOpers(std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]);
if (!channel->PartUser(dest, dest->nick))
delete channel;
}
diff --git a/src/modules/m_saquit.cpp b/src/modules/m_saquit.cpp
index dd02d4e41..4900a3db8 100644
--- a/src/modules/m_saquit.cpp
+++ b/src/modules/m_saquit.cpp
@@ -49,7 +49,7 @@ class cmd_saquit : public command_t
void Handle (const char** parameters, int pcnt, userrec *user)
{
- userrec* dest = Srv->FindNick(std::string(parameters[0]));
+ userrec* dest = ServerInstance->FindNick(parameters[0]);
if (dest)
{
if (Srv->IsUlined(dest->server))
@@ -64,7 +64,7 @@ class cmd_saquit : public command_t
}
line = line + std::string(parameters[pcnt-1]);
- Srv->SendOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
+ ServerInstance->WriteOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
userrec::QuitUser(ServerInstance, dest, line);
}
}
diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp
index 631bd13a1..697ba1dfd 100644
--- a/src/modules/m_sethost.cpp
+++ b/src/modules/m_sethost.cpp
@@ -22,10 +22,12 @@ using namespace std;
#include "channels.h"
#include "modules.h"
#include "helperfuncs.h"
+#include "inspircd.h"
/* $ModDesc: Provides support for the SETHOST command */
static Server *Srv;
+extern InspIRCd* ServerInstance;
class cmd_sethost : public command_t
{
@@ -55,7 +57,7 @@ class cmd_sethost : public command_t
}
}
if (user->ChangeDisplayedHost(parameters[0]))
- Srv->SendOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+std::string(parameters[0]));
+ ServerInstance->WriteOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+std::string(parameters[0]));
}
};
diff --git a/src/modules/m_setident.cpp b/src/modules/m_setident.cpp
index a5eb27a9b..b3bcef53b 100644
--- a/src/modules/m_setident.cpp
+++ b/src/modules/m_setident.cpp
@@ -1,10 +1,12 @@
#include "users.h"
#include "modules.h"
#include "helperfuncs.h"
+#include "inspircd.h"
/* $ModDesc: Provides support for the SETIDENT command */
static Server *Srv;
+extern InspIRCd* ServerInstance;
class cmd_setident : public command_t
{
@@ -26,7 +28,7 @@ class cmd_setident : public command_t
return;
}
- WriteOpers("%s used SETIDENT to change their ident from '%s' to '%s'", user->nick, user->ident, parameters[0]);
+ ServerInstance->WriteOpers("%s used SETIDENT to change their ident from '%s' to '%s'", user->nick, user->ident, parameters[0]);
strlcpy(user->ident, parameters[0], IDENTMAX+2);
}
};
diff --git a/src/modules/m_setidle.cpp b/src/modules/m_setidle.cpp
index f17f69e09..c83c7e7e0 100644
--- a/src/modules/m_setidle.cpp
+++ b/src/modules/m_setidle.cpp
@@ -22,10 +22,12 @@ using namespace std;
#include "channels.h"
#include "modules.h"
#include "helperfuncs.h"
+#include "inspircd.h"
/* $ModDesc: Allows opers to set their idle time */
static Server *Srv = NULL;
+extern InspIRCd* ServerInstance;
class cmd_setidle : public command_t
{
@@ -47,7 +49,7 @@ class cmd_setidle : public command_t
// minor tweak - we cant have signon time shorter than our idle time!
if (user->signon > user->idle_lastmsg)
user->signon = user->idle_lastmsg;
- Srv->SendOpers(std::string(user->nick)+" used SETIDLE to set their idle time to "+std::string(parameters[0])+" seconds");
+ ServerInstance->WriteOpers(std::string(user->nick)+" used SETIDLE to set their idle time to "+std::string(parameters[0])+" seconds");
user->WriteServ("944 %s :Idle time set.",user->nick);
}
};
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 72ae322f6..21209ab6a 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -617,7 +617,7 @@ class cmd_rconnect : public command_t
if (Srv->MatchText(Srv->GetServerName(),parameters[0]))
{
/* Yes, initiate the given connect */
- WriteOpers("*** Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick,parameters[0],parameters[1]);
+ ServerInstance->WriteOpers("*** Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick,parameters[0],parameters[1]);
const char* para[1];
para[0] = parameters[1];
Creator->OnPreCommand("CONNECT", para, 1, user, true);
@@ -713,12 +713,12 @@ class TreeSocket : public InspSocket
keylength = key.length();
if (!(keylength == 16 || keylength == 24 || keylength == 32))
{
- WriteOpers("*** \2ERROR\2: Key length for encryptionkey is not 16, 24 or 32 bytes in length!");
+ ServerInstance->WriteOpers("*** \2ERROR\2: Key length for encryptionkey is not 16, 24 or 32 bytes in length!");
log(DEBUG,"Key length not 16, 24 or 32 characters!");
}
else
{
- WriteOpers("*** \2AES\2: Initialized %d bit encryption to server %s",keylength*8,SName.c_str());
+ ServerInstance->WriteOpers("*** \2AES\2: Initialized %d bit encryption to server %s",keylength*8,SName.c_str());
ctx_in->MakeKey(key.c_str(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", keylength, keylength);
ctx_out->MakeKey(key.c_str(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
@@ -741,13 +741,13 @@ class TreeSocket : public InspSocket
{
if (x->Name == this->myhost)
{
- Srv->SendOpers("*** Connection to \2"+myhost+"\2["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] established.");
+ ServerInstance->WriteOpers("*** Connection to \2"+myhost+"\2["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] established.");
this->SendCapabilities();
if (x->EncryptionKey != "")
{
if (!(x->EncryptionKey.length() == 16 || x->EncryptionKey.length() == 24 || x->EncryptionKey.length() == 32))
{
- WriteOpers("\2WARNING\2: Your encryption key is NOT 16, 24 or 32 characters in length, encryption will \2NOT\2 be enabled.");
+ ServerInstance->WriteOpers("\2WARNING\2: Your encryption key is NOT 16, 24 or 32 characters in length, encryption will \2NOT\2 be enabled.");
}
else
{
@@ -766,7 +766,7 @@ class TreeSocket : public InspSocket
* If that happens the connection hangs here until it's closed. Unlikely
* and rather harmless.
*/
- Srv->SendOpers("*** Connection to \2"+myhost+"\2 lost link tag(!)");
+ ServerInstance->WriteOpers("*** Connection to \2"+myhost+"\2 lost link tag(!)");
return true;
}
@@ -778,7 +778,7 @@ class TreeSocket : public InspSocket
*/
if (e == I_ERR_CONNECT)
{
- Srv->SendOpers("*** Connection failed: Connection refused");
+ ServerInstance->WriteOpers("*** Connection failed: Connection refused");
}
}
@@ -857,10 +857,10 @@ class TreeSocket : public InspSocket
quitserver = this->InboundServerName;
}
- WriteOpers("*** \2ERROR\2: Server '%s' does not have the same set of modules loaded, cannot link!",quitserver.c_str());
- WriteOpers("*** Our networked module set is: '%s'",this->MyCapabilities().c_str());
- WriteOpers("*** Other server's networked module set is: '%s'",params[0].c_str());
- WriteOpers("*** These lists must match exactly on both servers. Please correct these errors, and try again.");
+ ServerInstance->WriteOpers("*** \2ERROR\2: Server '%s' does not have the same set of modules loaded, cannot link!",quitserver.c_str());
+ ServerInstance->WriteOpers("*** Our networked module set is: '%s'",this->MyCapabilities().c_str());
+ ServerInstance->WriteOpers("*** Other server's networked module set is: '%s'",params[0].c_str());
+ ServerInstance->WriteOpers("*** These lists must match exactly on both servers. Please correct these errors, and try again.");
this->WriteLine("ERROR :CAPAB mismatch; My capabilities: '"+this->MyCapabilities()+"'");
return false;
}
@@ -904,11 +904,11 @@ class TreeSocket : public InspSocket
DoOneToAllButSender(Current->GetParent()->GetName(),"SQUIT",params,Current->GetName());
if (Current->GetParent() == TreeRoot)
{
- Srv->SendOpers("Server \002"+Current->GetName()+"\002 split: "+reason);
+ ServerInstance->WriteOpers("Server \002"+Current->GetName()+"\002 split: "+reason);
}
else
{
- Srv->SendOpers("Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
+ ServerInstance->WriteOpers("Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
}
num_lost_servers = 0;
num_lost_users = 0;
@@ -917,7 +917,7 @@ class TreeSocket : public InspSocket
Current->Tidy();
Current->GetParent()->DelChild(Current);
DELETE(Current);
- WriteOpers("Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
+ ServerInstance->WriteOpers("Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
}
else
{
@@ -939,7 +939,7 @@ class TreeSocket : public InspSocket
std::string sourceserv;
/* Are we dealing with an FMODE from a user, or from a server? */
- userrec* who = Srv->FindNick(source);
+ userrec* who = ServerInstance->FindNick(source);
if (who)
{
/* FMODE from a user, set sourceserv to the users server name */
@@ -975,7 +975,7 @@ class TreeSocket : public InspSocket
}
/* Extract the TS value of the object, either userrec or chanrec */
- userrec* dst = Srv->FindNick(params[0]);
+ userrec* dst = ServerInstance->FindNick(params[0]);
chanrec* chan = NULL;
time_t ourTS = 0;
if (dst)
@@ -984,7 +984,7 @@ class TreeSocket : public InspSocket
}
else
{
- chan = Srv->FindChannel(params[0]);
+ chan = ServerInstance->FindChan(params[0]);
if (chan)
{
ourTS = chan->age;
@@ -1291,7 +1291,7 @@ class TreeSocket : public InspSocket
*/
if ((Srv->IsUlined(sourceserv)) && (TS > ourTS))
{
- WriteOpers("\2WARNING!\2 U-Lined server '%s' has bad TS for '%s' (accepted change): \2SYNC YOUR CLOCKS\2 to avoid this notice",sourceserv.c_str(),params[0].c_str());
+ ServerInstance->WriteOpers("\2WARNING!\2 U-Lined server '%s' has bad TS for '%s' (accepted change): \2SYNC YOUR CLOCKS\2 to avoid this notice",sourceserv.c_str(),params[0].c_str());
}
/* Allow the mode, route it to either server or user command handling */
if (smode)
@@ -1317,7 +1317,7 @@ class TreeSocket : public InspSocket
time_t ts = atoi(params[1].c_str());
std::string nsource = source;
- chanrec* c = Srv->FindChannel(params[0]);
+ chanrec* c = ServerInstance->FindChan(params[0]);
if (c)
{
if ((ts >= c->topicset) || (!*c->topic))
@@ -1332,7 +1332,7 @@ class TreeSocket : public InspSocket
*/
if (oldtopic != params[3])
{
- userrec* user = Srv->FindNick(source);
+ userrec* user = ServerInstance->FindNick(source);
if (!user)
{
c->WriteChannelWithServ(source.c_str(), "TOPIC %s :%s", c->name, c->topic);
@@ -1373,7 +1373,7 @@ class TreeSocket : public InspSocket
time_t TS = atoi(params[1].c_str());
char* key = "";
- chanrec* chan = Srv->FindChannel(channel);
+ chanrec* chan = ServerInstance->FindChan(channel);
if (chan)
{
key = chan->key;
@@ -1384,7 +1384,7 @@ class TreeSocket : public InspSocket
* channel will let the other side apply their modes.
*/
time_t ourTS = time(NULL)+600;
- chanrec* us = Srv->FindChannel(channel);
+ chanrec* us = ServerInstance->FindChan(channel);
if (us)
{
ourTS = us->age;
@@ -1424,7 +1424,7 @@ class TreeSocket : public InspSocket
strlcat(modestring,"v",MAXBUF);
break;
}
- who = Srv->FindNick(usr);
+ who = ServerInstance->FindNick(usr);
if (who)
{
chanrec::JoinUser(this->Instance, who, channel.c_str(), true, key);
@@ -1509,7 +1509,7 @@ class TreeSocket : public InspSocket
{
if (params.size() >= 2)
{
- chanrec* c = Srv->FindChannel(params[0]);
+ chanrec* c = ServerInstance->FindChan(params[0]);
if (c)
{
time_t theirTS = atoi(params[1].c_str());
@@ -1577,7 +1577,7 @@ class TreeSocket : public InspSocket
else
_new->SetSockAddr(AF_INET, params[6].c_str(), 0);
- WriteOpers("*** Client connecting at %s: %s!%s@%s [%s]",_new->server,_new->nick,_new->ident,_new->host, _new->GetIPString());
+ ServerInstance->WriteOpers("*** Client connecting at %s: %s!%s@%s [%s]",_new->server,_new->nick,_new->ident,_new->host, _new->GetIPString());
params[7] = ":" + params[7];
DoOneToAllButSender(source,"NICK",params,source);
@@ -1693,7 +1693,7 @@ class TreeSocket : public InspSocket
}
/* XXX: Send each channel mode and its params -- we'll need a method for this in ModeHandler? */
//FOREACH_MOD(I_OnSyncChannel,OnSyncChannel(c->second,(Module*)TreeProtocolModule,(void*)this));
- this->WriteLine(":"+Srv->GetServerName()+" FMODE "+c->name+" "+ConvToStr(c->age)+" +"+chanmodes(c,true)+modes+" "+params);
+ this->WriteLine(":"+Srv->GetServerName()+" FMODE "+c->name+" "+ConvToStr(c->age)+" +"+c->ChanModes(true)+modes+" "+params);
}
/* Send G, Q, Z and E lines */
@@ -1814,7 +1814,7 @@ class TreeSocket : public InspSocket
std::string endburst = "ENDBURST";
// Because by the end of the netburst, it could be gone!
std::string name = s->GetName();
- Srv->SendOpers("*** Bursting to \2"+name+"\2.");
+ ServerInstance->WriteOpers("*** Bursting to \2"+name+"\2.");
this->WriteLine(burst);
/* send our version string */
this->WriteLine(":"+Srv->GetServerName()+" VERSION :"+Srv->GetVersion());
@@ -1827,7 +1827,7 @@ class TreeSocket : public InspSocket
this->SendXLines(s);
FOREACH_MOD(I_OnSyncOtherMetaData,OnSyncOtherMetaData((Module*)TreeProtocolModule,(void*)this));
this->WriteLine(endburst);
- Srv->SendOpers("*** Finished bursting to \2"+name+"\2.");
+ ServerInstance->WriteOpers("*** Finished bursting to \2"+name+"\2.");
}
/* This function is called when we receive data from a remote
@@ -1923,7 +1923,7 @@ class TreeSocket : public InspSocket
{
if (params.size() < 1)
return false;
- WriteOpers("*** ERROR from %s: %s",(InboundServerName != "" ? InboundServerName.c_str() : myhost.c_str()),params[0].c_str());
+ ServerInstance->WriteOpers("*** ERROR from %s: %s",(InboundServerName != "" ? InboundServerName.c_str() : myhost.c_str()),params[0].c_str());
/* we will return false to cause the socket to close. */
return false;
}
@@ -1939,7 +1939,7 @@ class TreeSocket : public InspSocket
{
/* It's for our server */
string_list results;
- userrec* source = Srv->FindNick(prefix);
+ userrec* source = ServerInstance->FindNick(prefix);
if (source)
{
std::deque<std::string> par;
@@ -1956,7 +1956,7 @@ class TreeSocket : public InspSocket
else
{
/* Pass it on */
- userrec* source = Srv->FindNick(prefix);
+ userrec* source = ServerInstance->FindNick(prefix);
if (source)
DoOneToOne(prefix, "STATS", params, params[1]);
}
@@ -1976,7 +1976,7 @@ class TreeSocket : public InspSocket
return true;
}
std::string opertype = params[0];
- userrec* u = Srv->FindNick(prefix);
+ userrec* u = ServerInstance->FindNick(prefix);
if (u)
{
u->modes[UM_OPERATOR] = 1;
@@ -1994,7 +1994,7 @@ class TreeSocket : public InspSocket
if (params.size() < 3)
return true;
- userrec* u = Srv->FindNick(params[0]);
+ userrec* u = ServerInstance->FindNick(params[0]);
if (u)
{
@@ -2022,7 +2022,7 @@ class TreeSocket : public InspSocket
if (params.size() < 2)
return true;
- userrec* u = Srv->FindNick(params[0]);
+ userrec* u = ServerInstance->FindNick(params[0]);
if (u)
{
@@ -2041,7 +2041,7 @@ class TreeSocket : public InspSocket
if (Srv->MatchText(Srv->GetServerName(),servermask))
{
- Srv->SendOpers("*** Remote rehash initiated from server \002"+prefix+"\002.");
+ ServerInstance->WriteOpers("*** Remote rehash initiated from server \002"+prefix+"\002.");
Srv->RehashServer();
ReadConfiguration(false);
}
@@ -2055,8 +2055,8 @@ class TreeSocket : public InspSocket
return true;
std::string nick = params[0];
- userrec* u = Srv->FindNick(prefix);
- userrec* who = Srv->FindNick(nick);
+ userrec* u = ServerInstance->FindNick(prefix);
+ userrec* who = ServerInstance->FindNick(nick);
if (who)
{
@@ -2103,7 +2103,7 @@ class TreeSocket : public InspSocket
* dump the PONG reply back to their fd. If its a server, do nowt.
* Services might want to send these s->s, but we dont need to yet.
*/
- userrec* u = Srv->FindNick(prefix);
+ userrec* u = ServerInstance->FindNick(prefix);
if (u)
{
@@ -2135,7 +2135,7 @@ class TreeSocket : public InspSocket
}
else if (*(params[0].c_str()) == '#')
{
- chanrec* c = Srv->FindChannel(params[0]);
+ chanrec* c = ServerInstance->FindChan(params[0]);
if (c)
{
FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(TYPE_CHANNEL,c,params[1],params[2]));
@@ -2143,7 +2143,7 @@ class TreeSocket : public InspSocket
}
else if (*(params[0].c_str()) != '#')
{
- userrec* u = Srv->FindNick(params[0]);
+ userrec* u = ServerInstance->FindNick(params[0]);
if (u)
{
FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(TYPE_USER,u,params[1],params[2]));
@@ -2177,7 +2177,7 @@ class TreeSocket : public InspSocket
if (params.size() < 1)
return true;
- userrec* u = Srv->FindNick(prefix);
+ userrec* u = ServerInstance->FindNick(prefix);
if (u)
{
@@ -2217,7 +2217,7 @@ class TreeSocket : public InspSocket
break;
default:
/* Just in case... */
- Srv->SendOpers("*** \2WARNING\2: Invalid xline type '"+params[0]+"' sent by server "+prefix+", ignored!");
+ ServerInstance->WriteOpers("*** \2WARNING\2: Invalid xline type '"+params[0]+"' sent by server "+prefix+", ignored!");
propogate = false;
break;
}
@@ -2227,11 +2227,11 @@ class TreeSocket : public InspSocket
{
if (atoi(params[4].c_str()))
{
- WriteOpers("*** %s Added %cLINE on %s to expire in %lu seconds (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),atoi(params[4].c_str()),params[5].c_str());
+ ServerInstance->WriteOpers("*** %s Added %cLINE on %s to expire in %lu seconds (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),atoi(params[4].c_str()),params[5].c_str());
}
else
{
- WriteOpers("*** %s Added permenant %cLINE on %s (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),params[5].c_str());
+ ServerInstance->WriteOpers("*** %s Added permenant %cLINE on %s (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),params[5].c_str());
}
params[5] = ":" + params[5];
DoOneToAllButSender(prefix,"ADDLINE",params,prefix);
@@ -2249,7 +2249,7 @@ class TreeSocket : public InspSocket
if (params.size() < 1)
return true;
- userrec* u = Srv->FindNick(prefix);
+ userrec* u = ServerInstance->FindNick(prefix);
if (u)
{
@@ -2266,7 +2266,7 @@ class TreeSocket : public InspSocket
return true;
log(DEBUG,"In IDLE command");
- userrec* u = Srv->FindNick(prefix);
+ userrec* u = ServerInstance->FindNick(prefix);
if (u)
{
@@ -2274,10 +2274,10 @@ class TreeSocket : public InspSocket
// an incoming request
if (params.size() == 1)
{
- userrec* x = Srv->FindNick(params[0]);
+ userrec* x = ServerInstance->FindNick(params[0]);
if ((x) && (IS_LOCAL(x)))
{
- userrec* x = Srv->FindNick(params[0]);
+ userrec* x = ServerInstance->FindNick(params[0]);
log(DEBUG,"Got IDLE");
char signon[MAXBUF];
char idle[MAXBUF];
@@ -2300,7 +2300,7 @@ class TreeSocket : public InspSocket
else if (params.size() == 3)
{
std::string who_did_the_whois = params[0];
- userrec* who_to_send_to = Srv->FindNick(who_did_the_whois);
+ userrec* who_to_send_to = ServerInstance->FindNick(who_did_the_whois);
if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
{
log(DEBUG,"Got final IDLE");
@@ -2326,7 +2326,7 @@ class TreeSocket : public InspSocket
if (params.size() < 2)
return true;
- userrec* u = Srv->FindNick(params[0]);
+ userrec* u = ServerInstance->FindNick(params[0]);
if (!u)
return true;
@@ -2353,7 +2353,7 @@ class TreeSocket : public InspSocket
// someone querying our time?
if (Srv->GetServerName() == params[0])
{
- userrec* u = Srv->FindNick(params[1]);
+ userrec* u = ServerInstance->FindNick(params[1]);
if (u)
{
char curtime[256];
@@ -2366,7 +2366,7 @@ class TreeSocket : public InspSocket
else
{
// not us, pass it on
- userrec* u = Srv->FindNick(params[1]);
+ userrec* u = ServerInstance->FindNick(params[1]);
if (u)
DoOneToOne(prefix,"TIME",params,params[0]);
}
@@ -2374,7 +2374,7 @@ class TreeSocket : public InspSocket
else if (params.size() == 3)
{
// a response to a previous TIME
- userrec* u = Srv->FindNick(params[1]);
+ userrec* u = ServerInstance->FindNick(params[1]);
if ((u) && (IS_LOCAL(u)))
{
time_t rawtime = atol(params[2].c_str());
@@ -2444,14 +2444,14 @@ class TreeSocket : public InspSocket
if (CheckDupe)
{
this->WriteLine("ERROR :Server "+servername+" already exists!");
- Srv->SendOpers("*** Server connection from \2"+servername+"\2 denied, already exists");
+ ServerInstance->WriteOpers("*** Server connection from \2"+servername+"\2 denied, already exists");
return false;
}
TreeServer* Node = new TreeServer(servername,description,ParentOfThis,NULL);
ParentOfThis->AddChild(Node);
params[3] = ":" + params[3];
DoOneToAllButSender(prefix,"SERVER",params,prefix);
- Srv->SendOpers("*** Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
+ ServerInstance->WriteOpers("*** Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
return true;
}
@@ -2468,7 +2468,7 @@ class TreeSocket : public InspSocket
if (hops)
{
this->WriteLine("ERROR :Server too far away for authentication");
- Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
+ ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
return false;
}
std::string description = params[3];
@@ -2480,7 +2480,7 @@ class TreeSocket : public InspSocket
if (CheckDupe)
{
this->WriteLine("ERROR :Server "+sname+" already exists on server "+CheckDupe->GetParent()->GetName()+"!");
- Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
+ ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
return false;
}
// Begin the sync here. this kickstarts the
@@ -2501,7 +2501,7 @@ class TreeSocket : public InspSocket
}
}
this->WriteLine("ERROR :Invalid credentials");
- Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, invalid link credentials");
+ ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, invalid link credentials");
return false;
}
@@ -2518,7 +2518,7 @@ class TreeSocket : public InspSocket
if (hops)
{
this->WriteLine("ERROR :Server too far away for authentication");
- Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
+ ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
return false;
}
std::string description = params[3];
@@ -2530,7 +2530,7 @@ class TreeSocket : public InspSocket
if (CheckDupe)
{
this->WriteLine("ERROR :Server "+sname+" already exists on server "+CheckDupe->GetParent()->GetName()+"!");
- Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
+ ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
return false;
}
/* If the config says this link is encrypted, but the remote side
@@ -2540,10 +2540,10 @@ class TreeSocket : public InspSocket
if ((x->EncryptionKey != "") && (!this->ctx_in))
{
this->WriteLine("ERROR :This link requires AES encryption to be enabled. Plaintext connection refused.");
- Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, remote server did not enable AES.");
+ ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, remote server did not enable AES.");
return false;
}
- Srv->SendOpers("*** Verified incoming server connection from \002"+sname+"\002["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] ("+description+")");
+ ServerInstance->WriteOpers("*** Verified incoming server connection from \002"+sname+"\002["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] ("+description+")");
this->InboundServerName = sname;
this->InboundDescription = description;
// this is good. Send our details: Our server name and description and hopcount of 0,
@@ -2555,7 +2555,7 @@ class TreeSocket : public InspSocket
}
}
this->WriteLine("ERROR :Invalid credentials");
- Srv->SendOpers("*** Server connection from \2"+sname+"\2 denied, invalid link credentials");
+ ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, invalid link credentials");
return false;
}
@@ -2608,7 +2608,7 @@ class TreeSocket : public InspSocket
}
else if ((this->ctx_in) && (command == "AES"))
{
- WriteOpers("*** \2AES\2: Encryption already enabled on this connection yet %s is trying to enable it twice!",params[0].c_str());
+ ServerInstance->WriteOpers("*** \2AES\2: Encryption already enabled on this connection yet %s is trying to enable it twice!",params[0].c_str());
}
switch (this->LinkState)
@@ -2676,13 +2676,13 @@ class TreeSocket : public InspSocket
long delta = THEM-time(NULL);
if ((delta < -600) || (delta > 600))
{
- WriteOpers("*** \2ERROR\2: Your clocks are out by %d seconds (this is more than ten minutes). Link aborted, \2PLEASE SYNC YOUR CLOCKS!\2",abs(delta));
+ ServerInstance->WriteOpers("*** \2ERROR\2: Your clocks are out by %d seconds (this is more than ten minutes). Link aborted, \2PLEASE SYNC YOUR CLOCKS!\2",abs(delta));
this->WriteLine("ERROR :Your clocks are out by "+ConvToStr(abs(delta))+" seconds (this is more than ten minutes). Link aborted, PLEASE SYNC YOUR CLOCKS!");
return false;
}
else if ((delta < -60) || (delta > 60))
{
- WriteOpers("*** \2WARNING\2: Your clocks are out by %d seconds, please consider synching your clocks.",abs(delta));
+ ServerInstance->WriteOpers("*** \2WARNING\2: Your clocks are out by %d seconds, please consider synching your clocks.",abs(delta));
}
}
this->LinkState = CONNECTED;
@@ -2734,7 +2734,7 @@ class TreeSocket : public InspSocket
if (prefix != "")
{
std::string direction = prefix;
- userrec* t = Srv->FindNick(prefix);
+ userrec* t = ServerInstance->FindNick(prefix);
if (t)
{
direction = t->server;
@@ -2888,8 +2888,8 @@ class TreeSocket : public InspSocket
std::string sourceserv = this->myhost;
if (params.size() == 3)
{
- userrec* user = Srv->FindNick(params[1]);
- chanrec* chan = Srv->FindChannel(params[0]);
+ userrec* user = ServerInstance->FindNick(params[1]);
+ chanrec* chan = ServerInstance->FindChan(params[0]);
if (user && chan)
{
if (!chan->ServerKickUser(user, params[2].c_str(), false))
@@ -2928,7 +2928,7 @@ class TreeSocket : public InspSocket
{
sourceserv = this->InboundServerName;
}
- WriteOpers("*** Received end of netburst from \2%s\2",sourceserv.c_str());
+ ServerInstance->WriteOpers("*** Received end of netburst from \2%s\2",sourceserv.c_str());
return true;
}
else
@@ -2936,7 +2936,7 @@ class TreeSocket : public InspSocket
// not a special inter-server command.
// Emulate the actual user doing the command,
// this saves us having a huge ugly parser.
- userrec* who = Srv->FindNick(prefix);
+ userrec* who = ServerInstance->FindNick(prefix);
std::string sourceserv = this->myhost;
if (this->InboundServerName != "")
{
@@ -2950,7 +2950,7 @@ class TreeSocket : public InspSocket
* already exist here. If it does, kill their copy,
* and our copy.
*/
- userrec* x = Srv->FindNick(params[0]);
+ userrec* x = ServerInstance->FindNick(params[0]);
if ((x) && (x != who))
{
std::deque<std::string> p;
@@ -2962,7 +2962,7 @@ class TreeSocket : public InspSocket
p.push_back("Nickname collision");
DoOneToMany(Srv->GetServerName(),"KILL",p);
userrec::QuitUser(this->Instance,x,"Nickname collision ("+prefix+" -> "+params[0]+")");
- userrec* y = Srv->FindNick(prefix);
+ userrec* y = ServerInstance->FindNick(prefix);
if (y)
{
userrec::QuitUser(this->Instance,y,"Nickname collision");
@@ -3019,7 +3019,7 @@ class TreeSocket : public InspSocket
{
if (this->LinkState == CONNECTING)
{
- Srv->SendOpers("*** CONNECT: Connection to \002"+myhost+"\002 timed out.");
+ ServerInstance->WriteOpers("*** CONNECT: Connection to \002"+myhost+"\002 timed out.");
}
}
@@ -3038,7 +3038,7 @@ class TreeSocket : public InspSocket
{
Squit(s,"Remote host closed the connection");
}
- WriteOpers("Server '\2%s\2' closed the connection.",quitserver.c_str());
+ ServerInstance->WriteOpers("Server '\2%s\2' closed the connection.",quitserver.c_str());
}
virtual int OnIncomingConnection(int newsock, char* ip)
@@ -3058,7 +3058,7 @@ class TreeSocket : public InspSocket
if (!found)
{
- WriteOpers("Server connection from %s denied (no link blocks with that IP address)", ip);
+ ServerInstance->WriteOpers("Server connection from %s denied (no link blocks with that IP address)", ip);
close(newsock);
return false;
}
@@ -3107,7 +3107,7 @@ class ServernameResolver : public Resolver
else
{
/* Something barfed, show the opers */
- WriteOpers("*** CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno));
+ ServerInstance->WriteOpers("*** CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno));
delete newsocket;
}
}
@@ -3116,7 +3116,7 @@ class ServernameResolver : public Resolver
void OnError(ResolverError e, const std::string &errormessage)
{
/* Ooops! */
- WriteOpers("*** CONNECT: Error connecting \002%s\002: Unable to resolve hostname - %s",MyLink.Name.c_str(),errormessage.c_str());
+ ServerInstance->WriteOpers("*** CONNECT: Error connecting \002%s\002: Unable to resolve hostname - %s",MyLink.Name.c_str(),errormessage.c_str());
}
};
@@ -3184,7 +3184,7 @@ bool DoOneToAllButSenderRaw(std::string data, std::string omit, std::string pref
if ((*(params[0].c_str()) != '#') && (*(params[0].c_str()) != '$'))
{
// special routing for private messages/notices
- userrec* d = Srv->FindNick(params[0]);
+ userrec* d = ServerInstance->FindNick(params[0]);
if (d)
{
std::deque<std::string> par;
@@ -3205,7 +3205,7 @@ bool DoOneToAllButSenderRaw(std::string data, std::string omit, std::string pref
else
{
log(DEBUG,"Channel privmsg going to chan %s",params[0].c_str());
- chanrec* c = Srv->FindChannel(params[0]);
+ chanrec* c = ServerInstance->FindChan(params[0]);
if (c)
{
std::deque<TreeServer*> list;
@@ -3666,7 +3666,7 @@ class ModuleSpanningTree : public Module
if (sock)
{
log(DEBUG,"Splitting server %s",s->GetName().c_str());
- WriteOpers("*** SQUIT: Server \002%s\002 removed from network by %s",parameters[0],user->nick);
+ ServerInstance->WriteOpers("*** SQUIT: Server \002%s\002 removed from network by %s",parameters[0],user->nick);
sock->Squit(s,"Server quit by "+std::string(user->nick)+"!"+std::string(user->ident)+"@"+std::string(user->host));
Srv->RemoveSocket(sock);
}
@@ -3710,7 +3710,7 @@ class ModuleSpanningTree : public Module
{
if ((IS_LOCAL(user)) && (pcnt > 1))
{
- userrec* remote = Srv->FindNick(parameters[1]);
+ userrec* remote = ServerInstance->FindNick(parameters[1]);
if ((remote) && (remote->fd < 0))
{
std::deque<std::string> params;
@@ -3746,7 +3746,7 @@ class ModuleSpanningTree : public Module
else
{
// they didnt answer, boot them
- WriteOpers("*** Server \002%s\002 pinged out",serv->GetName().c_str());
+ ServerInstance->WriteOpers("*** Server \002%s\002 pinged out",serv->GetName().c_str());
sock->Squit(serv,"Ping timeout");
Srv->RemoveSocket(sock);
return;
@@ -3768,7 +3768,7 @@ class ModuleSpanningTree : public Module
if (!CheckDupe)
{
// an autoconnected server is not connected. Check if its time to connect it
- WriteOpers("*** AUTOCONNECT: Auto-connecting server \002%s\002 (%lu seconds until next attempt)",x->Name.c_str(),x->AutoConnect);
+ ServerInstance->WriteOpers("*** AUTOCONNECT: Auto-connecting server \002%s\002 (%lu seconds until next attempt)",x->Name.c_str(),x->AutoConnect);
insp_inaddr binip;
@@ -3782,7 +3782,7 @@ class ModuleSpanningTree : public Module
}
else
{
- WriteOpers("*** AUTOCONNECT: Error autoconnecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
+ ServerInstance->WriteOpers("*** AUTOCONNECT: Error autoconnecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
delete newsocket;
}
}
@@ -3863,7 +3863,7 @@ class ModuleSpanningTree : public Module
}
else
{
- WriteOpers("*** CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
+ ServerInstance->WriteOpers("*** CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
delete newsocket;
}
}
@@ -3902,7 +3902,7 @@ class ModuleSpanningTree : public Module
results.push_back(Srv->GetServerName()+" 244 "+user->nick+" H * * "+LinkBlocks[i].Name.c_str());
}
results.push_back(Srv->GetServerName()+" 219 "+user->nick+" "+statschar+" :End of /STATS report");
- WriteOpers("*** Notice: %s '%c' requested by %s (%s@%s)",(!strcmp(user->server,ServerInstance->Config->ServerName) ? "Stats" : "Remote stats"),statschar,user->nick,user->ident,user->host);
+ ServerInstance->WriteOpers("*** Notice: %s '%c' requested by %s (%s@%s)",(!strcmp(user->server,ServerInstance->Config->ServerName) ? "Stats" : "Remote stats"),statschar,user->nick,user->ident,user->host);
return 1;
}
return 0;
@@ -4275,7 +4275,7 @@ class ModuleSpanningTree : public Module
// check for self
if (Srv->MatchText(Srv->GetServerName(),parameter))
{
- Srv->SendOpers("*** Remote rehash initiated from server \002"+Srv->GetServerName()+"\002.");
+ ServerInstance->WriteOpers("*** Remote rehash initiated from server \002"+Srv->GetServerName()+"\002.");
Srv->RehashServer();
}
}
@@ -4461,14 +4461,14 @@ class ModuleSpanningTree : public Module
return;
// Insert the TS value of the object, either userrec or chanrec
time_t ourTS = 0;
- userrec* a = Srv->FindNick((*params)[0]);
+ userrec* a = ServerInstance->FindNick((*params)[0]);
if (a)
{
ourTS = a->age;
}
else
{
- chanrec* a = Srv->FindChannel((*params)[0]);
+ chanrec* a = ServerInstance->FindChan((*params)[0]);
if (a)
{
ourTS = a->age;
diff --git a/src/modules/m_spy.cpp b/src/modules/m_spy.cpp
index 40be036ab..041814f9b 100644
--- a/src/modules/m_spy.cpp
+++ b/src/modules/m_spy.cpp
@@ -94,11 +94,11 @@ class cmd_spylist : public command_t
void Handle (const char** parameters, int pcnt, userrec *user)
{
- WriteOpers("*** Oper %s used SPYLIST to list +s/+p channels and keys.",user->nick);
+ ServerInstance->WriteOpers("*** Oper %s used SPYLIST to list +s/+p channels and keys.",user->nick);
user->WriteServ("321 %s Channel :Users Name",user->nick);
for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++)
{
- user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,i->second->GetUserCounter(),chanmodes(i->second,true),i->second->topic);
+ user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,i->second->GetUserCounter(),i->second->ChanModes(true),i->second->topic);
}
user->WriteServ("323 %s :End of channel list.",user->nick);
}
@@ -126,9 +126,9 @@ class cmd_spynames : public command_t
if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 1))
return;
- WriteOpers("*** Oper %s used SPYNAMES to view the users on %s",user->nick,parameters[0]);
+ ServerInstance->WriteOpers("*** Oper %s used SPYNAMES to view the users on %s",user->nick,parameters[0]);
- c = FindChan(parameters[0]);
+ c = ServerInstance->FindChan(parameters[0]);
if (c)
{
spy_userlist(user,c);
diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp
index cb400a0bf..35ffd6d8f 100644
--- a/src/modules/m_swhois.cpp
+++ b/src/modules/m_swhois.cpp
@@ -22,6 +22,8 @@
/* $ModDesc: Provides the SWHOIS command which allows setting of arbitary WHOIS lines */
+extern InspIRCd* ServerInstance;
+
class cmd_swhois : public command_t
{
Server* Srv;
@@ -35,7 +37,7 @@ class cmd_swhois : public command_t
void Handle(const char** parameters, int pcnt, userrec* user)
{
- userrec* dest = Srv->FindNick(std::string(parameters[0]));
+ userrec* dest = ServerInstance->FindNick(parameters[0]);
if(dest)
{
std::string line;
@@ -56,7 +58,7 @@ class cmd_swhois : public command_t
if (!Srv->IsUlined(user->server))
// Ulines set SWHOISes silently
- WriteOpers("*** %s used SWHOIS to set %s's extra whois from '%s' to '%s'", user->nick, dest->nick, text->c_str(), line.c_str());
+ ServerInstance->WriteOpers("*** %s used SWHOIS to set %s's extra whois from '%s' to '%s'", user->nick, dest->nick, text->c_str(), line.c_str());
dest->Shrink("swhois");
DELETE(text);
@@ -64,7 +66,7 @@ class cmd_swhois : public command_t
else if(!Srv->IsUlined(user->server))
{
// Ulines set SWHOISes silently
- WriteOpers("*** %s used SWHOIS to set %s's extra whois to '%s'", user->nick, dest->nick, line.c_str());
+ ServerInstance->WriteOpers("*** %s used SWHOIS to set %s's extra whois to '%s'", user->nick, dest->nick, line.c_str());
}
text = new std::string(line);
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index 426859390..14e68dfda 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -52,7 +52,7 @@ class cmd_tban : public command_t
void Handle (const char** parameters, int pcnt, userrec *user)
{
- chanrec* channel = Srv->FindChannel(parameters[0]);
+ chanrec* channel = ServerInstance->FindChan(parameters[0]);
if (channel)
{
std::string cm = Srv->ChanMode(user,channel);
@@ -159,7 +159,7 @@ class ModuleTimedBans : public Module
{
if (curtime > i->expire)
{
- chanrec* cr = Srv->FindChannel(i->channel);
+ chanrec* cr = ServerInstance->FindChan(i->channel);
again = true;
if (cr)
{
diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp
index bde81011d..8d8d46c47 100644
--- a/src/modules/m_uninvite.cpp
+++ b/src/modules/m_uninvite.cpp
@@ -24,8 +24,10 @@ using namespace std;
#include "modules.h"
#include "helperfuncs.h"
#include "message.h"
+#include "inspircd.h"
static Server *Srv;
+extern InspIRCd* ServerInstance;
class cmd_uninvite : public command_t
{
@@ -38,8 +40,8 @@ class cmd_uninvite : public command_t
void Handle (const char** parameters, int pcnt, userrec *user)
{
- userrec* u = Find(parameters[0]);
- chanrec* c = FindChan(parameters[1]);
+ userrec* u = ServerInstance->FindNick(parameters[0]);
+ chanrec* c = ServerInstance->FindChan(parameters[1]);
if ((!c) || (!u))
{
diff --git a/src/modules/m_userip.cpp b/src/modules/m_userip.cpp
index 1ad0e1c58..80ab67be1 100644
--- a/src/modules/m_userip.cpp
+++ b/src/modules/m_userip.cpp
@@ -22,10 +22,12 @@ using namespace std;
#include "channels.h"
#include "modules.h"
#include "helperfuncs.h"
+#include "inspircd.h"
/* $ModDesc: Provides support for USERIP command */
static Server *Srv;
+extern InspIRCd* ServerInstance;
class cmd_userip : public command_t
{
@@ -42,7 +44,7 @@ class cmd_userip : public command_t
snprintf(Return,MAXBUF,"340 %s :",user->nick);
for (int i = 0; i < pcnt; i++)
{
- userrec *u = Find(parameters[i]);
+ userrec *u = ServerInstance->FindNick(parameters[i]);
if (u)
{
snprintf(junk,MAXBUF,"%s%s=+%s@%s ",u->nick,*u->oper ? "*" : "",u->ident,u->GetIPString());
diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp
index 2ba9c9afb..8e6b2c50c 100644
--- a/src/modules/m_watch.cpp
+++ b/src/modules/m_watch.cpp
@@ -29,6 +29,7 @@ using namespace std;
/* $ModDesc: Provides support for the /watch command */
static Server *Srv;
+extern InspIRCd* ServerInstance;
class watchentry : public classbase
{
@@ -58,7 +59,7 @@ class cmd_watch : public command_t
watchentry* a = (watchentry*)(*q);
if (a->watcher == user)
{
- userrec* targ = Srv->FindNick(a->target);
+ userrec* targ = ServerInstance->FindNick(a->target);
if (targ)
{
user->WriteServ("604 %s %s %s %s %lu :is online",user->nick,targ->nick,targ->ident,targ->dhost,targ->age);
@@ -99,7 +100,7 @@ class cmd_watch : public command_t
watchentry* a = (watchentry*)(*q);
if (a->watcher == user)
{
- userrec* targ = Srv->FindNick(a->target);
+ userrec* targ = ServerInstance->FindNick(a->target);
if (targ)
{
user->WriteServ("604 %s %s %s %s %lu :is online",user->nick,targ->nick,targ->ident,targ->dhost,targ->age);
@@ -136,7 +137,7 @@ class cmd_watch : public command_t
if (b->watcher == user)
{
irc::string n2 = b->target.c_str();
- userrec* a = Srv->FindNick(b->target);
+ userrec* a = ServerInstance->FindNick(b->target);
if (a)
{
user->WriteServ("602 %s %s %s %s %lu :stopped watching",user->nick,a->nick,a->ident,a->dhost,a->age);
@@ -180,7 +181,7 @@ 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);
+ userrec* a = ServerInstance->FindNick(nick);
if (a)
{
user->WriteServ("604 %s %s %s %s %lu :is online",user->nick,a->nick,a->ident,a->dhost,a->age);
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index 42c3bd3db..51235b882 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -19,7 +19,6 @@
using namespace std;
#include "inspircd_config.h"
-#include "inspircd.h"
#include "configreader.h"
#include <unistd.h>
#include <fcntl.h>
@@ -48,6 +47,7 @@ using namespace std;
#include "hashcomp.h"
#include "socketengine.h"
#include "userprocess.h"
+#include "inspircd.h"
#include "typedefs.h"
#include "command_parse.h"
#include "cull_list.h"
@@ -146,7 +146,7 @@ void InspIRCd::ProcessUser(userrec* cu)
if (current->lines_in > current->flood)
{
log(DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
- WriteOpers("*** Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
+ this->WriteOpers("*** Excess flood from: %s!%s@%s",current->nick,current->ident,current->host);
userrec::QuitUser(this, current,"Excess flood");
return;
}
@@ -158,7 +158,7 @@ void InspIRCd::ProcessUser(userrec* cu)
}
else
{
- WriteOpers("*** Excess flood from %s",current->GetIPString());
+ this->WriteOpers("*** Excess flood from %s",current->GetIPString());
log(DEFAULT,"Excess flood from: %s",current->GetIPString());
add_zline(120,this->Config->ServerName,"Flood from unregistered connection",current->GetIPString());
apply_lines(APPLY_ZLINES);
@@ -175,7 +175,7 @@ void InspIRCd::ProcessUser(userrec* cu)
}
else
{
- WriteOpers("*** Excess flood from %s",current->GetIPString());
+ this->WriteOpers("*** Excess flood from %s",current->GetIPString());
log(DEFAULT,"Excess flood from: %s",current->GetIPString());
add_zline(120,this->Config->ServerName,"Flood from unregistered connection",current->GetIPString());
apply_lines(APPLY_ZLINES);
diff --git a/src/users.cpp b/src/users.cpp
index 7fcda61a9..baef05e28 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -497,7 +497,7 @@ bool userrec::AddBuffer(const std::string &a)
if (recvq.length() > (unsigned)this->recvqmax)
{
this->SetWriteError("RecvQ exceeded");
- WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax);
+ ServerInstance->WriteOpers("*** User %s RecvQ of %d exceeds connect class maximum of %d",this->nick,recvq.length(),this->recvqmax);
return false;
}
@@ -554,7 +554,7 @@ void userrec::AddWriteBuf(const std::string &data)
* to repeatedly add the text to the sendq!
*/
this->SetWriteError("SendQ exceeded");
- WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
+ ServerInstance->WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
return;
}
@@ -664,7 +664,7 @@ void userrec::QuitUser(InspIRCd* Instance, userrec *user,const std::string &quit
if (user->registered == REG_ALL)
{
- purge_empty_chans(user);
+ user->PurgeEmptyChannels();
FOREACH_MOD_I(Instance,I_OnUserQuit,OnUserQuit(user,reason));
user->WriteCommonExcept("QUIT :%s",reason.c_str());
}
@@ -693,7 +693,7 @@ void userrec::QuitUser(InspIRCd* Instance, userrec *user,const std::string &quit
}
/*
- * this must come before the WriteOpers so that it doesnt try to fill their buffer with anything
+ * this must come before the ServerInstance->WriteOpers so that it doesnt try to fill their buffer with anything
* if they were an oper with +s.
*
* XXX -
@@ -703,7 +703,7 @@ void userrec::QuitUser(InspIRCd* Instance, userrec *user,const std::string &quit
if (user->registered == REG_ALL)
{
if (IS_LOCAL(user))
- WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str());
+ Instance->WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason.c_str());
user->AddToWhoWas();
}
@@ -970,7 +970,7 @@ void userrec::FullConnect(CullList* Goners)
ServerInstance->stats->statsConnects++;
this->idle_lastmsg = TIME;
- ConnectClass a = GetClass(this);
+ ConnectClass a = this->GetClass();
if (a.type == CC_DENY)
{
@@ -987,13 +987,13 @@ void userrec::FullConnect(CullList* Goners)
if (this->LocalCloneCount() > a.maxlocal)
{
Goners->AddItem(this, "No more connections allowed from your host via this connect class (local)");
- WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a.maxlocal, this->GetIPString());
+ ServerInstance->WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a.maxlocal, this->GetIPString());
return;
}
else if (this->GlobalCloneCount() > a.maxglobal)
{
Goners->AddItem(this, "No more connections allowed from your host via this connect class (global)");
- WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s",a.maxglobal, this->GetIPString());
+ ServerInstance->WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s",a.maxglobal, this->GetIPString());
return;
}
@@ -1061,7 +1061,7 @@ void userrec::FullConnect(CullList* Goners)
FOREACH_MOD(I_OnUserConnect,OnUserConnect(this));
FOREACH_MOD(I_OnGlobalConnect,OnGlobalConnect(this));
this->registered = REG_ALL;
- WriteOpers("*** Client connecting on port %d: %s!%s@%s [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString());
+ ServerInstance->WriteOpers("*** Client connecting on port %d: %s!%s@%s [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString());
}
/** userrec::UpdateNick()
@@ -1713,3 +1713,53 @@ void userrec::SplitChanList(userrec* dest, const std::string &cl)
}
+/* looks up a users password for their connection class (<ALLOW>/<DENY> tags)
+ * NOTE: If the <ALLOW> or <DENY> tag specifies an ip, and this user resolves,
+ * then their ip will be taken as 'priority' anyway, so for example,
+ * <connect allow="127.0.0.1"> will match joe!bloggs@localhost
+ */
+ConnectClass& userrec::GetClass()
+{
+ for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
+ {
+ if ((match(this->GetIPString(),i->host.c_str(),true)) || (match(this->host,i->host.c_str())))
+ return *i;
+ }
+
+ return *(ServerInstance->Config->Classes.begin());
+}
+
+void userrec::PurgeEmptyChannels()
+{
+ std::vector<chanrec*> to_delete;
+
+ // firstly decrement the count on each channel
+ for (std::vector<ucrec*>::iterator f = this->chans.begin(); f != this->chans.end(); f++)
+ {
+ ucrec* uc = *f;
+ if (uc->channel)
+ {
+ if (uc->channel->DelUser(this) == 0)
+ {
+ /* No users left in here, mark it for deletion */
+ to_delete.push_back(uc->channel);
+ uc->channel = NULL;
+ }
+ }
+ }
+
+ for (std::vector<chanrec*>::iterator n = to_delete.begin(); n != to_delete.end(); n++)
+ {
+ chanrec* thischan = *n;
+ chan_hash::iterator i2 = ServerInstance->chanlist.find(thischan->name);
+ if (i2 != ServerInstance->chanlist.end())
+ {
+ FOREACH_MOD(I_OnChannelDelete,OnChannelDelete(i2->second));
+ DELETE(i2->second);
+ ServerInstance->chanlist.erase(i2);
+ }
+ }
+
+ this->UnOper();
+}
+
diff --git a/src/xline.cpp b/src/xline.cpp
index d3821b528..551e98458 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -617,35 +617,35 @@ void expire_lines()
while ((glines.size()) && (current > (glines.begin()->duration + glines.begin()->set_time)))
{
std::vector<GLine>::iterator i = glines.begin();
- WriteOpers("*** Expiring timed G-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
+ ServerInstance->WriteOpers("*** Expiring timed G-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
glines.erase(i);
}
while ((elines.size()) && (current > (elines.begin()->duration + elines.begin()->set_time)))
{
std::vector<ELine>::iterator i = elines.begin();
- WriteOpers("*** Expiring timed E-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
+ ServerInstance->WriteOpers("*** Expiring timed E-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
elines.erase(i);
}
while ((zlines.size()) && (current > (zlines.begin()->duration + zlines.begin()->set_time)))
{
std::vector<ZLine>::iterator i = zlines.begin();
- WriteOpers("*** Expiring timed Z-Line %s (set by %s %d seconds ago)",i->ipaddr,i->source,i->duration);
+ ServerInstance->WriteOpers("*** Expiring timed Z-Line %s (set by %s %d seconds ago)",i->ipaddr,i->source,i->duration);
zlines.erase(i);
}
while ((klines.size()) && (current > (klines.begin()->duration + klines.begin()->set_time)))
{
std::vector<KLine>::iterator i = klines.begin();
- WriteOpers("*** Expiring timed K-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
+ ServerInstance->WriteOpers("*** Expiring timed K-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
klines.erase(i);
}
while ((qlines.size()) && (current > (qlines.begin()->duration + qlines.begin()->set_time)))
{
std::vector<QLine>::iterator i = qlines.begin();
- WriteOpers("*** Expiring timed Q-Line %s (set by %s %d seconds ago)",i->nick,i->source,i->duration);
+ ServerInstance->WriteOpers("*** Expiring timed Q-Line %s (set by %s %d seconds ago)",i->nick,i->source,i->duration);
qlines.erase(i);
}