None of the modules use an extern InspIRCd* any more

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4863 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2006-08-11 00:46:41 +00:00
parent 66098d307c
commit fd6ee21f2f
68 changed files with 299 additions and 306 deletions

View File

@ -26,7 +26,7 @@ using namespace std;
/* $ModDesc: Provides aliases of commands. */
extern InspIRCd* ServerInstance;
class Alias : public classbase
{

View File

@ -18,7 +18,7 @@
// The +e channel mode takes a nick!ident@host, glob patterns allowed,
// and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
extern InspIRCd* ServerInstance;
class BanException : public ListModeBase
{

View File

@ -30,7 +30,7 @@
/* $ModDesc: Attempt to block /amsg, at least some of the irritating mIRC scripts. */
extern time_t TIME;
extern InspIRCd* ServerInstance;
enum BlockAction { IBLOCK_KILL, IBLOCK_KILLOPERS, IBLOCK_NOTICE, IBLOCK_NOTICEOPERS, IBLOCK_SILENT };

View File

@ -24,7 +24,7 @@
/* $ModDesc: Provides support for channel mode +P to block all-CAPS channel messages and notices */
extern InspIRCd* ServerInstance;
class BlockCaps : public ModeHandler
{

View File

@ -26,7 +26,7 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style channel mode +c */
extern InspIRCd* ServerInstance;
class BlockColor : public ModeHandler
{

View File

@ -27,7 +27,7 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style umode +B */
extern InspIRCd* ServerInstance;
class BotMode : public ModeHandler
{

View File

@ -30,7 +30,7 @@
/* $ModDesc: Gives /cban, aka C:lines. Think Q:lines, for channels. */
extern InspIRCd* ServerInstance;
class CBan : public classbase
{
@ -126,6 +126,11 @@ class cmd_cban : public command_t
}
};
bool CBanComp(const CBan &ban1, const CBan &ban2)
{
return ((ban1.set_on + ban1.length) < (ban2.set_on + ban2.length));
}
class ModuleCBan : public Module
{
cmd_cban* mycommand;
@ -203,60 +208,55 @@ class ModuleCBan : public Module
{
return Version(1,0,0,1,VF_VENDOR);
}
};
std::string EncodeCBan(const CBan &ban)
{
std::ostringstream stream;
stream << ban.chname << " " << ban.set_by << " " << ban.set_on << " " << ban.length << " " << ban.reason;
return stream.str();
}
CBan DecodeCBan(const std::string &data)
{
CBan res;
std::istringstream stream(data);
stream >> res.chname;
stream >> res.set_by;
stream >> res.set_on;
stream >> res.length;
res.reason = stream.str();
return res;
}
bool CBanComp(const CBan &ban1, const CBan &ban2)
{
return ((ban1.set_on + ban1.length) < (ban2.set_on + ban2.length));
}
void ExpireBans()
{
bool go_again = true;
while (go_again)
std::string EncodeCBan(const CBan &ban)
{
go_again = false;
std::ostringstream stream;
stream << ban.chname << " " << ban.set_by << " " << ban.set_on << " " << ban.length << " " << ban.reason;
return stream.str();
}
for (cbanlist::iterator iter = cbans.begin(); iter != cbans.end(); iter++)
CBan DecodeCBan(const std::string &data)
{
CBan res;
std::istringstream stream(data);
stream >> res.chname;
stream >> res.set_by;
stream >> res.set_on;
stream >> res.length;
res.reason = stream.str();
return res;
}
void ExpireBans()
{
bool go_again = true;
while (go_again)
{
/* 0 == permanent, don't mess with them! -- w00t */
if (iter->length != 0)
go_again = false;
for (cbanlist::iterator iter = cbans.begin(); iter != cbans.end(); iter++)
{
if (iter->set_on + iter->length <= TIME)
/* 0 == permanent, don't mess with them! -- w00t */
if (iter->length != 0)
{
log(DEBUG, "m_cban.so: Ban on %s expired, removing...", iter->chname.c_str());
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;
if (iter->set_on + iter->length <= TIME)
{
log(DEBUG, "m_cban.so: Ban on %s expired, removing...", iter->chname.c_str());
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;
}
}
if (go_again == true)
break;
}
if (go_again == true)
break;
}
}
}
};
class ModuleCBanFactory : public ModuleFactory
{

View File

@ -28,7 +28,7 @@ typedef std::map<irc::string,irc::string> censor_t;
/* $ModDesc: Provides user and channel +G mode */
extern InspIRCd* ServerInstance;
class CensorException : public ModuleException
{

View File

@ -29,7 +29,7 @@
/* $ModDesc: Change user's hosts connecting from known CGI:IRC hosts */
extern InspIRCd* ServerInstance;
enum CGItype { PASS, IDENT, PASSFIRST, IDENTFIRST };

View File

@ -29,7 +29,7 @@ using namespace std;
/* $ModDesc: Provides channel-specific censor lists (like mode +G but varies from channel to channel) */
extern InspIRCd* ServerInstance;
class ChanFilter : public ListModeBase
{

View File

@ -23,7 +23,7 @@
/* $ModDesc: Provides channel modes +a and +q */
extern InspIRCd* ServerInstance;
const char* fakevalue = "on";

View File

@ -26,7 +26,7 @@ using namespace std;
/* $ModDesc: Provides the /check command to retrieve information on a user, channel, or IP address */
extern InspIRCd* ServerInstance;
class cmd_check : public command_t
{

View File

@ -26,7 +26,7 @@ using namespace std;
/* $ModDesc: Provides support for the CHGHOST command */
extern InspIRCd* ServerInstance;
class cmd_chghost : public command_t
{

View File

@ -6,7 +6,7 @@
/* $ModDesc: Provides support for the CHGIDENT command */
extern InspIRCd* ServerInstance;
class cmd_chgident : public command_t
{

View File

@ -43,7 +43,7 @@
/* $ModDesc: Provides masking of user hostnames */
extern InspIRCd* ServerInstance;
/* The four core functions - F1 is optimized somewhat */

View File

@ -23,7 +23,7 @@ using namespace std;
/* $ModDesc: Sends the /LUSERS on connect */
extern InspIRCd* ServerInstance;
// This has to be the simplest module ever.
// The RFC doesnt specify that you should send the /LUSERS numerics

View File

@ -9,7 +9,7 @@
/* $ModDesc: Forces connecting clients to send a PONG message back to the server before they can complete their connection */
extern InspIRCd* ServerInstance;
char* RandString(unsigned int length)
{

View File

@ -28,7 +28,7 @@ using namespace std;
int conns = 0, throttled = 0;
extern time_t TIME;
extern InspIRCd* ServerInstance;
class ModuleConnFlood : public Module
{

View File

@ -29,7 +29,7 @@ using namespace std;
#include "modules.h"
#include "inspircd.h"
extern InspIRCd* ServerInstance;
class cmd_devoice : public command_t
{

View File

@ -30,7 +30,7 @@ using namespace std;
/* $ModDesc: An enhanced version of the unreal m_filter.so used by chatspike.net */
extern InspIRCd* ServerInstance;
class Filter : public classbase
{

View File

@ -27,7 +27,7 @@ using namespace std;
/* $ModDesc: Provides support for GLOBOPS and user mode +g */
extern InspIRCd* ServerInstance;
class cmd_globops : public command_t
{

View File

@ -25,7 +25,7 @@ using namespace std;
// Global Vars
static ConfigReader *helpop;
extern InspIRCd* ServerInstance;
bool do_helpop(const char**, int, userrec*);
void sendtohelpop(userrec*, int, const char**);
@ -127,60 +127,58 @@ class cmd_helpop : public command_t
}
}
}
};
bool do_helpop(const char** parameters, int pcnt, userrec *src)
{
char search[MAXBUF];
std::string output = " "; // a fix bought to you by brain :p
char a[MAXBUF];
int nlines = 0;
if (!pcnt)
bool do_helpop(const char** parameters, int pcnt, userrec *src)
{
strcpy(search,"start");
}
else
{
if (*parameters[0] == '?')
parameters[0]++;
strlcpy(search,parameters[0],MAXBUF);
}
char search[MAXBUF];
std::string output = " "; // a fix bought to you by brain :p
char a[MAXBUF];
int nlines = 0;
for (char* n = search; *n; n++)
*n = tolower(*n);
for (int i = 1; output != ""; i++)
{
snprintf(a,MAXBUF,"line%d",i);
output = helpop->ReadValue(search, a, 0);
if (output != "")
if (!pcnt)
{
src->WriteServ("290 "+std::string(src->nick)+" :"+output);
nlines++;
strcpy(search,"start");
}
else
{
if (*parameters[0] == '?')
parameters[0]++;
strlcpy(search,parameters[0],MAXBUF);
}
for (char* n = search; *n; n++)
*n = tolower(*n);
for (int i = 1; output != ""; i++)
{
snprintf(a,MAXBUF,"line%d",i);
output = helpop->ReadValue(search, a, 0);
if (output != "")
{
src->WriteServ("290 "+std::string(src->nick)+" :"+output);
nlines++;
}
}
return (nlines>0);
}
return (nlines>0);
}
void sendtohelpop(userrec *src, int pcnt, const char **params)
{
const char* first = params[0];
if (*first == '!')
void sendtohelpop(userrec *src, int pcnt, const char **params)
{
first++;
}
const char* first = params[0];
if (*first == '!')
{
first++;
}
std::string line = "*** HELPOPS - From "+std::string(src->nick)+": "+std::string(first)+" ";
for (int i = 1; i < pcnt; i++)
{
line = line + std::string(params[i]) + " ";
std::string line = "*** HELPOPS - From "+std::string(src->nick)+": "+std::string(first)+" ";
for (int i = 1; i < pcnt; i++)
{
line = line + std::string(params[i]) + " ";
}
ServerInstance->WriteMode("oh",WM_AND,line.c_str());
}
ServerInstance->WriteMode("oh",WM_AND,line.c_str());
}
};
class HelpopException : public ModuleException
{

View File

@ -24,7 +24,7 @@ using namespace std;
/* $ModDesc: Provides masking of user hostnames in a different way to m_cloaking */
extern InspIRCd* ServerInstance;
class Host : public classbase
{

View File

@ -29,7 +29,7 @@ using namespace std;
class ModuleHttp;
extern InspIRCd* ServerInstance;
static ModuleHttp* HttpModule;
extern time_t TIME;
@ -66,7 +66,7 @@ class HttpSocket : public InspSocket
if (InternalState == HTTP_LISTEN)
{
HttpSocket* s = new HttpSocket(this->Instance, newsock, ip, index);
ServerInstance->AddSocket(s);
this->Instance->AddSocket(s);
}
return true;
}

View File

@ -28,7 +28,7 @@ using namespace std;
/* $ModDesc: Provides statistics over HTTP via m_httpd.so */
extern InspIRCd* ServerInstance;
typedef std::map<irc::string,int> StatsHash;
typedef StatsHash::iterator StatsIter;

View File

@ -23,7 +23,7 @@ using namespace std;
#include "modules.h"
#include "inspircd.h"
extern InspIRCd* ServerInstance;
extern userrec* fd_ref_table[MAX_DESCRIPTORS];
@ -87,7 +87,7 @@ class RFC1413 : public InspSocket
{
if (u && (fd_ref_table[ufd] == u))
{
if (ServerInstance->IsIdent(section))
if (this->Instance->IsIdent(section))
{
strlcpy(u->ident,section,IDENTMAX);
log(DEBUG,"IDENT SET: "+std::string(u->ident));

View File

@ -27,7 +27,7 @@ using namespace std;
/* $ModDesc: Provides channel mode +j (join flood protection) */
extern InspIRCd* ServerInstance;
class joinfloodsettings : public classbase
{

View File

@ -10,7 +10,7 @@
/* $ModDesc: Provides channel mode +J (delay rejoin after kick) */
extern InspIRCd* ServerInstance;
inline int strtoint(const std::string &str)
{

View File

@ -27,7 +27,7 @@ using namespace std;
/* $ModDesc: Provides support for /KNOCK and mode +K */
extern InspIRCd* ServerInstance;
class cmd_knock : public command_t
{

View File

@ -26,7 +26,7 @@ using namespace std;
/* $ModDesc: Provides channel mode +f (message flood protection) */
extern InspIRCd* ServerInstance;
class floodsettings : public classbase
{

View File

@ -27,7 +27,7 @@ using namespace std;
/* $ModDesc: Provides the NICKLOCK command, allows an oper to chage a users nick and lock them to it until they quit */
extern InspIRCd* ServerInstance;
class cmd_nicklock : public command_t
{

View File

@ -25,7 +25,7 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style channel mode +c */
extern InspIRCd* ServerInstance;
class NoCTCP : public ModeHandler
{

View File

@ -25,7 +25,7 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style channel mode +V */
extern InspIRCd* ServerInstance;
class NoInvite : public ModeHandler
{

View File

@ -25,7 +25,7 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style channel mode +Q */
extern InspIRCd* ServerInstance;
class NoKicks : public ModeHandler
{

View File

@ -28,7 +28,7 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style GLOBOPS and umode +g */
extern InspIRCd* ServerInstance;
class NoNicks : public ModeHandler
{

View File

@ -25,7 +25,7 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style channel mode +T */
extern InspIRCd* ServerInstance;
class NoNotice : public ModeHandler
{

View File

@ -25,7 +25,7 @@ using namespace std;
/* $ModDesc: Provides support for oper-only chans via the +O channel mode */
extern InspIRCd* ServerInstance;
class OperChans : public ModeHandler
{

View File

@ -10,7 +10,7 @@ using namespace std;
/* $ModDesc: Forces opers to join the specified channel(s) on oper-up */
extern InspIRCd* ServerInstance;
class ModuleOperjoin : public Module
{

View File

@ -9,7 +9,7 @@ using namespace std;
/* $ModDesc: Gives each oper type a 'level', cannot kill opers 'above' your level. */
extern InspIRCd* ServerInstance;
class ModuleOperLevels : public Module
{

View File

@ -23,7 +23,7 @@
/* $ModDesc: Provides support for unreal-style oper-override */
extern InspIRCd* ServerInstance;
typedef std::map<std::string,std::string> override_t;

View File

@ -25,7 +25,7 @@ using namespace std;
#include "modules.h"
#include "inspircd.h"
extern InspIRCd* ServerInstance;
/* $ModDesc: Provides support for user parking/unparking */

View File

@ -25,7 +25,7 @@ using namespace std;
/* $ModDesc: Provides channel mode +L (limit redirection) */
extern InspIRCd* ServerInstance;
class Redirect : public ModeHandler
{

View File

@ -19,15 +19,14 @@
* 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:
bool& supportnokicks;
InspIRCd* ServerInstance;
protected:
RemoveBase(bool& snk) : supportnokicks(snk)
RemoveBase(InspIRCd* Instance, bool& snk) : supportnokicks(snk), ServerInstance(Instance)
{
}
@ -207,7 +206,7 @@ class RemoveBase
class cmd_remove : public command_t, public RemoveBase
{
public:
cmd_remove(InspIRCd* Instance, bool& snk) : command_t(Instance, "REMOVE", 0, 2), RemoveBase(snk)
cmd_remove(InspIRCd* Instance, bool& snk) : command_t(Instance, "REMOVE", 0, 2), RemoveBase(Instance, snk)
{
this->source = "m_remove.so";
syntax = "<nick> <channel> [<reason>]";
@ -222,7 +221,7 @@ class cmd_remove : public command_t, public RemoveBase
class cmd_fpart : public command_t, public RemoveBase
{
public:
cmd_fpart(InspIRCd* Instance, bool& snk) : command_t(Instance, "FPART", 0, 2), RemoveBase(snk)
cmd_fpart(InspIRCd* Instance, bool& snk) : command_t(Instance, "FPART", 0, 2), RemoveBase(Instance, snk)
{
this->source = "m_remove.so";
syntax = "<channel> <nick> [<reason>]";

View File

@ -26,7 +26,7 @@ using namespace std;
extern time_t TIME;
extern InspIRCd* ServerInstance;
class ListData : public classbase
{
@ -55,11 +55,11 @@ class ListTimer : public InspTimer
char buffer[MAXBUF];
chanrec *chan;
InspIRCd* ServerInstance;
public:
ListTimer(long interval) : InspTimer(interval,TIME)
ListTimer(InspIRCd* Instance, long interval) : InspTimer(interval,TIME), ServerInstance(Instance)
{
}
@ -133,7 +133,7 @@ class ListTimer : public InspTimer
}
}
ListTimer* MyTimer = new ListTimer(1);
ListTimer* MyTimer = new ListTimer(ServerInstance,1);
ServerInstance->Timers->AddTimer(MyTimer);
}
};
@ -146,7 +146,7 @@ class ModuleSafeList : public Module
public:
ModuleSafeList(InspIRCd* Me) : Module::Module(Me)
{
MyTimer = new ListTimer(1);
MyTimer = new ListTimer(ServerInstance,1);
ServerInstance->Timers->AddTimer(MyTimer);
}

View File

@ -27,7 +27,7 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style SAJOIN command */
extern InspIRCd* ServerInstance;
class cmd_sajoin : public command_t
{

View File

@ -38,7 +38,7 @@ using namespace std;
#include "inspircd.h"
extern InspIRCd* ServerInstance;
class cmd_samode : public command_t
{

View File

@ -25,7 +25,7 @@ using namespace std;
/* $ModDesc: Provides support for SANICK command */
extern InspIRCd* ServerInstance;
class cmd_sanick : public command_t

View File

@ -27,7 +27,7 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style SAPART command */
extern InspIRCd* ServerInstance;
class cmd_sapart : public command_t
{

View File

@ -36,7 +36,7 @@ using namespace std;
/* $ModDesc: Provides support for an SAQUIT command, exits user with a reason */
extern InspIRCd* ServerInstance;
class cmd_saquit : public command_t
{

View File

@ -27,7 +27,7 @@ extern time_t TIME;
/* $ModDesc: A module overriding /list, and making it safe - stop those sendq problems. */
extern InspIRCd* ServerInstance;
class ModuleSecureList : public Module
{

View File

@ -30,7 +30,7 @@ static bool kludgeme = false;
/* $ModDesc: Povides support for services +r user/chan modes and more */
extern InspIRCd* ServerInstance;
class Channel_r : public ModeHandler
{

View File

@ -27,7 +27,7 @@ using namespace std;
/* $ModDesc: Povides support for ircu-style services accounts, including chmode +R, etc. */
extern InspIRCd* ServerInstance;
class AChannel_R : public ModeHandler
{

View File

@ -27,7 +27,7 @@ using namespace std;
/* $ModDesc: Provides support for the SETHOST command */
extern InspIRCd* ServerInstance;
class cmd_sethost : public command_t
{

View File

@ -6,7 +6,7 @@
/* $ModDesc: Provides support for the SETIDENT command */
extern InspIRCd* ServerInstance;
class cmd_setident : public command_t
{

View File

@ -26,7 +26,7 @@ using namespace std;
/* $ModDesc: Allows opers to set their idle time */
extern InspIRCd* ServerInstance;
class cmd_setidle : public command_t
{

View File

@ -26,7 +26,7 @@ using namespace std;
/* $ModDesc: Provides support for the SETNAME command */
extern InspIRCd* ServerInstance;
class cmd_setname : public command_t
{

View File

@ -11,7 +11,7 @@ using namespace std;
/* $ModDesc: Allows opers to set +W to see when a user uses WHOIS on them */
extern InspIRCd* ServerInstance;
class SeeWhois : public ModeHandler
{

View File

@ -34,6 +34,7 @@ using namespace std;
#include "socket.h"
#include "helperfuncs.h"
#include "inspircd.h"
#include "wildcard.h"
#include "inspstring.h"
#include "hashcomp.h"
#include "xline.h"
@ -68,8 +69,7 @@ using irc::sockets::MatchCIDR;
class ModuleSpanningTree;
static ModuleSpanningTree* TreeProtocolModule;
extern InspIRCd* ServerInstance;
static InspIRCd* ServerInstance;
/* Any socket can have one of five states at any one time.
* The LISTENER state indicates a socket which is listening
@ -199,6 +199,7 @@ class UserManager : public classbase
class TreeServer : public classbase
{
InspIRCd* ServerInstance; /* Creator */
TreeServer* Parent; /* Parent entry */
TreeServer* Route; /* Route entry */
std::vector<TreeServer*> Children; /* List of child objects */
@ -216,7 +217,7 @@ class TreeServer : public classbase
/* We don't use this constructor. Its a dummy, and won't cause any insertion
* of the TreeServer into the hash_map. See below for the two we DO use.
*/
TreeServer()
TreeServer(InspIRCd* Instance) : ServerInstance(Instance)
{
Parent = NULL;
ServerName = "";
@ -582,7 +583,7 @@ TreeServer* FindServerMask(std::string ServerName)
{
for (server_hash::iterator i = serverlist.begin(); i != serverlist.end(); i++)
{
if (ServerInstance->MatchText(i->first.c_str(),ServerName))
if (match(i->first.c_str(),ServerName.c_str()))
return i->second;
}
return NULL;
@ -708,12 +709,12 @@ class TreeSocket : public InspSocket
keylength = key.length();
if (!(keylength == 16 || keylength == 24 || keylength == 32))
{
ServerInstance->WriteOpers("*** \2ERROR\2: Key length for encryptionkey is not 16, 24 or 32 bytes in length!");
this->Instance->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
{
ServerInstance->WriteOpers("*** \2AES\2: Initialized %d bit encryption to server %s",keylength*8,SName.c_str());
this->Instance->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\
@ -736,22 +737,22 @@ class TreeSocket : public InspSocket
{
if (x->Name == this->myhost)
{
ServerInstance->WriteOpers("*** Connection to \2"+myhost+"\2["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] established.");
this->Instance->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))
{
ServerInstance->WriteOpers("\2WARNING\2: Your encryption key is NOT 16, 24 or 32 characters in length, encryption will \2NOT\2 be enabled.");
this->Instance->WriteOpers("\2WARNING\2: Your encryption key is NOT 16, 24 or 32 characters in length, encryption will \2NOT\2 be enabled.");
}
else
{
this->WriteLine(std::string("AES ")+ServerInstance->Config->ServerName);
this->WriteLine(std::string("AES ")+this->Instance->Config->ServerName);
this->InitAES(x->EncryptionKey,x->Name.c_str());
}
}
/* found who we're supposed to be connecting to, send the neccessary gubbins. */
this->WriteLine(std::string("SERVER ")+ServerInstance->Config->ServerName+" "+x->SendPass+" 0 :"+ServerInstance->Config->ServerDesc);
this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+x->SendPass+" 0 :"+this->Instance->Config->ServerDesc);
return true;
}
}
@ -761,7 +762,7 @@ class TreeSocket : public InspSocket
* If that happens the connection hangs here until it's closed. Unlikely
* and rather harmless.
*/
ServerInstance->WriteOpers("*** Connection to \2"+myhost+"\2 lost link tag(!)");
this->Instance->WriteOpers("*** Connection to \2"+myhost+"\2 lost link tag(!)");
return true;
}
@ -773,7 +774,7 @@ class TreeSocket : public InspSocket
*/
if (e == I_ERR_CONNECT)
{
ServerInstance->WriteOpers("*** Connection failed: Connection refused");
this->Instance->WriteOpers("*** Connection failed: Connection refused");
}
}
@ -816,10 +817,10 @@ class TreeSocket : public InspSocket
std::vector<std::string> modlist;
std::string capabilities = "";
for (int i = 0; i <= ServerInstance->GetModuleCount(); i++)
for (int i = 0; i <= this->Instance->GetModuleCount(); i++)
{
if ((ServerInstance->modules[i]->GetVersion().Flags & VF_STATIC) || (ServerInstance->modules[i]->GetVersion().Flags & VF_COMMON))
modlist.push_back(ServerInstance->Config->module_names[i]);
if ((this->Instance->modules[i]->GetVersion().Flags & VF_STATIC) || (this->Instance->modules[i]->GetVersion().Flags & VF_COMMON))
modlist.push_back(this->Instance->Config->module_names[i]);
}
sort(modlist.begin(),modlist.end());
for (unsigned int i = 0; i < modlist.size(); i++)
@ -852,10 +853,10 @@ class TreeSocket : public InspSocket
quitserver = this->InboundServerName;
}
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->Instance->WriteOpers("*** \2ERROR\2: Server '%s' does not have the same set of modules loaded, cannot link!",quitserver.c_str());
this->Instance->WriteOpers("*** Our networked module set is: '%s'",this->MyCapabilities().c_str());
this->Instance->WriteOpers("*** Other server's networked module set is: '%s'",params[0].c_str());
this->Instance->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;
}
@ -899,11 +900,11 @@ class TreeSocket : public InspSocket
DoOneToAllButSender(Current->GetParent()->GetName(),"SQUIT",params,Current->GetName());
if (Current->GetParent() == TreeRoot)
{
ServerInstance->WriteOpers("Server \002"+Current->GetName()+"\002 split: "+reason);
this->Instance->WriteOpers("Server \002"+Current->GetName()+"\002 split: "+reason);
}
else
{
ServerInstance->WriteOpers("Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
this->Instance->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;
@ -912,7 +913,7 @@ class TreeSocket : public InspSocket
Current->Tidy();
Current->GetParent()->DelChild(Current);
DELETE(Current);
ServerInstance->WriteOpers("Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
this->Instance->WriteOpers("Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
}
else
{
@ -934,7 +935,7 @@ class TreeSocket : public InspSocket
std::string sourceserv;
/* Are we dealing with an FMODE from a user, or from a server? */
userrec* who = ServerInstance->FindNick(source);
userrec* who = this->Instance->FindNick(source);
if (who)
{
/* FMODE from a user, set sourceserv to the users server name */
@ -943,7 +944,7 @@ class TreeSocket : public InspSocket
else
{
/* FMODE from a server, create a fake user to receive mode feedback */
who = new userrec(ServerInstance);
who = new userrec(this->Instance);
who->fd = FD_MAGIC_NUMBER;
smode = true; /* Setting this flag tells us we should free the userrec later */
sourceserv = source; /* Set sourceserv to the actual source string */
@ -970,7 +971,7 @@ class TreeSocket : public InspSocket
}
/* Extract the TS value of the object, either userrec or chanrec */
userrec* dst = ServerInstance->FindNick(params[0]);
userrec* dst = this->Instance->FindNick(params[0]);
chanrec* chan = NULL;
time_t ourTS = 0;
if (dst)
@ -979,7 +980,7 @@ class TreeSocket : public InspSocket
}
else
{
chan = ServerInstance->FindChan(params[0]);
chan = this->Instance->FindChan(params[0]);
if (chan)
{
ourTS = chan->age;
@ -1019,7 +1020,7 @@ class TreeSocket : public InspSocket
/* We only care about whats being set,
* not whats being unset
*/
mh = ServerInstance->ModeGrok->FindMode(*x, chan ? MODETYPE_CHANNEL : MODETYPE_USER);
mh = this->Instance->ModeGrok->FindMode(*x, chan ? MODETYPE_CHANNEL : MODETYPE_USER);
if ((mh) && (mh->GetNumParams(adding) > 0) && (!mh->IsListMode()))
{
@ -1084,7 +1085,7 @@ class TreeSocket : public InspSocket
}
else
{
mh = ServerInstance->ModeGrok->FindMode(*x, chan ? MODETYPE_CHANNEL : MODETYPE_USER);
mh = this->Instance->ModeGrok->FindMode(*x, chan ? MODETYPE_CHANNEL : MODETYPE_USER);
if (mh)
{
@ -1109,7 +1110,7 @@ class TreeSocket : public InspSocket
}
else
{
mh = ServerInstance->ModeGrok->FindMode(*x, chan ? MODETYPE_CHANNEL : MODETYPE_USER);
mh = this->Instance->ModeGrok->FindMode(*x, chan ? MODETYPE_CHANNEL : MODETYPE_USER);
if (mh)
{
@ -1135,7 +1136,7 @@ class TreeSocket : public InspSocket
newparams.push_back(params[0]);
newparams.push_back(ConvToStr(ourTS));
newparams.push_back(to_bounce+params_to_bounce);
DoOneToOne(ServerInstance->Config->ServerName,"FMODE",newparams,sourceserv);
DoOneToOne(this->Instance->Config->ServerName,"FMODE",newparams,sourceserv);
}
if (to_keep.length())
@ -1157,12 +1158,12 @@ class TreeSocket : public InspSocket
if (smode)
{
log(DEBUG,"Send mode");
ServerInstance->SendMode(modelist, n+2, who);
this->Instance->SendMode(modelist, n+2, who);
}
else
{
log(DEBUG,"Send mode client");
ServerInstance->CallCommandHandler("MODE", modelist, n+2, who);
this->Instance->CallCommandHandler("MODE", modelist, n+2, who);
}
/* HOT POTATO! PASS IT ON! */
@ -1171,7 +1172,7 @@ class TreeSocket : public InspSocket
}
else
/* U-lined servers always win regardless of their TS */
if ((TS > ourTS) && (!ServerInstance->IsUlined(source)))
if ((TS > ourTS) && (!this->Instance->IsUlined(source)))
{
/* Bounce the mode back to its sender.* We use our lower TS, so the other end
* SHOULD accept it, if its clock is right.
@ -1216,7 +1217,7 @@ class TreeSocket : public InspSocket
break;
default:
/* Find the mode handler for this mode */
mh = ServerInstance->ModeGrok->FindMode(*x, chan ? MODETYPE_CHANNEL : MODETYPE_USER);
mh = this->Instance->ModeGrok->FindMode(*x, chan ? MODETYPE_CHANNEL : MODETYPE_USER);
/* Got a mode handler?
* This also prevents us bouncing modes we have no handler for.
@ -1275,7 +1276,7 @@ class TreeSocket : public InspSocket
/* Update the parameters for FMODE with the new 'bounced' string */
newparams[2] = modebounce;
/* Only send it back the way it came, no need to send it anywhere else */
DoOneToOne(ServerInstance->Config->ServerName,"FMODE",newparams,sourceserv);
DoOneToOne(this->Instance->Config->ServerName,"FMODE",newparams,sourceserv);
log(DEBUG,"FMODE bounced intelligently, our TS less than theirs and the other server is NOT a uline.");
}
else
@ -1284,15 +1285,15 @@ class TreeSocket : public InspSocket
/* The server was ulined, but something iffy is up with the TS.
* Sound the alarm bells!
*/
if ((ServerInstance->IsUlined(sourceserv)) && (TS > ourTS))
if ((this->Instance->IsUlined(sourceserv)) && (TS > ourTS))
{
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());
this->Instance->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)
ServerInstance->SendMode(modelist,n,who);
this->Instance->SendMode(modelist,n,who);
else
ServerInstance->CallCommandHandler("MODE", modelist, n, who);
this->Instance->CallCommandHandler("MODE", modelist, n, who);
/* HOT POTATO! PASS IT ON! */
DoOneToAllButSender(source,"FMODE",params,sourceserv);
@ -1312,7 +1313,7 @@ class TreeSocket : public InspSocket
time_t ts = atoi(params[1].c_str());
std::string nsource = source;
chanrec* c = ServerInstance->FindChan(params[0]);
chanrec* c = this->Instance->FindChan(params[0]);
if (c)
{
if ((ts >= c->topicset) || (!*c->topic))
@ -1327,7 +1328,7 @@ class TreeSocket : public InspSocket
*/
if (oldtopic != params[3])
{
userrec* user = ServerInstance->FindNick(source);
userrec* user = this->Instance->FindNick(source);
if (!user)
{
c->WriteChannelWithServ(source.c_str(), "TOPIC %s :%s", c->name, c->topic);
@ -1368,7 +1369,7 @@ class TreeSocket : public InspSocket
time_t TS = atoi(params[1].c_str());
char* key = "";
chanrec* chan = ServerInstance->FindChan(channel);
chanrec* chan = this->Instance->FindChan(channel);
if (chan)
{
key = chan->key;
@ -1379,7 +1380,7 @@ class TreeSocket : public InspSocket
* channel will let the other side apply their modes.
*/
time_t ourTS = time(NULL)+600;
chanrec* us = ServerInstance->FindChan(channel);
chanrec* us = this->Instance->FindChan(channel);
if (us)
{
ourTS = us->age;
@ -1419,7 +1420,7 @@ class TreeSocket : public InspSocket
strlcat(modestring,"v",MAXBUF);
break;
}
who = ServerInstance->FindNick(usr);
who = this->Instance->FindNick(usr);
if (who)
{
chanrec::JoinUser(this->Instance, who, channel.c_str(), true, key);
@ -1428,11 +1429,11 @@ class TreeSocket : public InspSocket
/* theres a mode for this user. push them onto the mode queue, and flush it
* if there are more than MAXMODES to go.
*/
if ((ourTS >= TS) || (ServerInstance->IsUlined(who->server)))
if ((ourTS >= TS) || (this->Instance->IsUlined(who->server)))
{
/* We also always let u-lined clients win, no matter what the TS value */
log(DEBUG,"Our our channel newer than theirs, accepting their modes");
ServerInstance->SendMode((const char**)mode_users,modectr,who);
this->Instance->SendMode((const char**)mode_users,modectr,who);
if (ourTS != TS)
{
log(DEFAULT,"Channel TS for %s changed from %lu to %lu",us->name,ourTS,TS);
@ -1457,7 +1458,7 @@ class TreeSocket : public InspSocket
}
// tell everyone to bounce the modes. bad modes, bad!
DoOneToMany(ServerInstance->Config->ServerName,"FMODE",params);
DoOneToMany(this->Instance->Config->ServerName,"FMODE",params);
}
strcpy(mode_users[1],"+");
modectr = 2;
@ -1473,7 +1474,7 @@ class TreeSocket : public InspSocket
if (ourTS >= TS)
{
log(DEBUG,"Our our channel newer than theirs, accepting their modes");
ServerInstance->SendMode((const char**)mode_users,modectr,who);
this->Instance->SendMode((const char**)mode_users,modectr,who);
if (ourTS != TS)
{
log(DEFAULT,"Channel TS for %s changed from %lu to %lu",us->name,ourTS,TS);
@ -1494,7 +1495,7 @@ class TreeSocket : public InspSocket
}
params.push_back(mode_users[x]);
}
DoOneToMany(ServerInstance->Config->ServerName,"FMODE",params);
DoOneToMany(this->Instance->Config->ServerName,"FMODE",params);
}
}
return true;
@ -1504,7 +1505,7 @@ class TreeSocket : public InspSocket
{
if (params.size() >= 2)
{
chanrec* c = ServerInstance->FindChan(params[0]);
chanrec* c = this->Instance->FindChan(params[0]);
if (c)
{
time_t theirTS = atoi(params[1].c_str());
@ -1516,7 +1517,7 @@ class TreeSocket : public InspSocket
}
}
}
DoOneToAllButSender(ServerInstance->Config->ServerName,"SYNCTS",params,source);
DoOneToAllButSender(this->Instance->Config->ServerName,"SYNCTS",params,source);
return true;
}
@ -1527,7 +1528,7 @@ class TreeSocket : public InspSocket
return true;
if (params.size() > 8)
{
this->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" KILL "+params[1]+" :Invalid client introduction ("+params[1]+"?)");
this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+params[1]+" :Invalid client introduction ("+params[1]+"?)");
return true;
}
// NICK age nick host dhost ident +modes ip :gecos
@ -1548,7 +1549,7 @@ class TreeSocket : public InspSocket
{
// nick collision
log(DEBUG,"Nick collision on %s!%s@%s: %lu %lu",tempnick,params[4].c_str(),params[2].c_str(),(unsigned long)age,(unsigned long)iter->second->age);
this->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" KILL "+tempnick+" :Nickname collision");
this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" KILL "+tempnick+" :Nickname collision");
return true;
}
@ -1572,7 +1573,7 @@ class TreeSocket : public InspSocket
else
_new->SetSockAddr(AF_INET, params[6].c_str(), 0);
ServerInstance->WriteOpers("*** Client connecting at %s: %s!%s@%s [%s]",_new->server,_new->nick,_new->ident,_new->host, _new->GetIPString());
this->Instance->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);
@ -1596,10 +1597,10 @@ class TreeSocket : public InspSocket
{
log(DEBUG,"Sending FJOINs to other server for %s",c->name);
char list[MAXBUF];
std::string individual_halfops = std::string(":")+ServerInstance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age);
std::string individual_halfops = std::string(":")+this->Instance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age);
size_t dlen, curlen;
dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",ServerInstance->Config->ServerName,c->name,(unsigned long)c->age);
dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->ServerName,c->name,(unsigned long)c->age);
int numusers = 0;
char* ptr = list + dlen;
@ -1645,7 +1646,7 @@ class TreeSocket : public InspSocket
if (curlen > (480-NICKMAX))
{
this->WriteLine(list);
dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",ServerInstance->Config->ServerName,c->name,(unsigned long)c->age);
dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->ServerName,c->name,(unsigned long)c->age);
ptr = list + dlen;
ptrlen = 0;
numusers = 0;
@ -1653,13 +1654,11 @@ class TreeSocket : public InspSocket
{
modes.append("v");
params.append(specific_voice[y]->nick).append(" ");
//this->WriteLine(":"+ServerInstance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age)+" +v "+specific_voice[y]->nick);
}
for (unsigned int y = 0; y < specific_halfop.size(); y++)
{
modes.append("h");
params.append(specific_halfop[y]->nick).append(" ");
//this->WriteLine(":"+ServerInstance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age)+" +h "+specific_halfop[y]->nick);
}
}
}
@ -1670,32 +1669,27 @@ class TreeSocket : public InspSocket
{
modes.append("v");
params.append(specific_voice[y]->nick).append(" ");
//this->WriteLine(":"+ServerInstance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age)+" +v "+specific_voice[y]->nick);
}
for (unsigned int y = 0; y < specific_halfop.size(); y++)
{
modes.append("h");
params.append(specific_halfop[y]->nick).append(" ");
//this->WriteLine(":"+ServerInstance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age)+" +h "+specific_halfop[y]->nick);
}
}
//std::string modes = "";
//std::string params = "";
for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++)
{
modes.append("b");
params.append(b->data).append(" ");
}
/* 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(std::string(":")+ServerInstance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age)+" +"+c->ChanModes(true)+modes+" "+params);
this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" FMODE "+c->name+" "+ConvToStr(c->age)+" +"+c->ChanModes(true)+modes+" "+params);
}
/* Send G, Q, Z and E lines */
void SendXLines(TreeServer* Current)
{
char data[MAXBUF];
std::string n = ServerInstance->Config->ServerName;
std::string n = this->Instance->Config->ServerName;
const char* sn = n.c_str();
int iterations = 0;
/* Yes, these arent too nice looking, but they get the job done */
@ -1747,7 +1741,7 @@ class TreeSocket : public InspSocket
char data[MAXBUF];
std::deque<std::string> list;
int iterations = 0;
std::string n = ServerInstance->Config->ServerName;
std::string n = this->Instance->Config->ServerName;
const char* sn = n.c_str();
for (chan_hash::iterator c = this->Instance->chanlist.begin(); c != this->Instance->chanlist.end(); c++, iterations++)
{
@ -1757,12 +1751,12 @@ class TreeSocket : public InspSocket
snprintf(data,MAXBUF,":%s FTOPIC %s %lu %s :%s",sn,c->second->name,(unsigned long)c->second->topicset,c->second->setby,c->second->topic);
this->WriteLine(data);
}
FOREACH_MOD(I_OnSyncChannel,OnSyncChannel(c->second,(Module*)TreeProtocolModule,(void*)this));
FOREACH_MOD_I(this->Instance,I_OnSyncChannel,OnSyncChannel(c->second,(Module*)TreeProtocolModule,(void*)this));
list.clear();
c->second->GetExtList(list);
for (unsigned int j = 0; j < list.size(); j++)
{
FOREACH_MOD(I_OnSyncChannelMetaData,OnSyncChannelMetaData(c->second,(Module*)TreeProtocolModule,(void*)this,list[j]));
FOREACH_MOD_I(this->Instance,I_OnSyncChannelMetaData,OnSyncChannelMetaData(c->second,(Module*)TreeProtocolModule,(void*)this,list[j]));
}
}
}
@ -1787,12 +1781,12 @@ class TreeSocket : public InspSocket
{
this->WriteLine(":"+std::string(u->second->nick)+" AWAY :"+std::string(u->second->awaymsg));
}
FOREACH_MOD(I_OnSyncUser,OnSyncUser(u->second,(Module*)TreeProtocolModule,(void*)this));
FOREACH_MOD_I(this->Instance,I_OnSyncUser,OnSyncUser(u->second,(Module*)TreeProtocolModule,(void*)this));
list.clear();
u->second->GetExtList(list);
for (unsigned int j = 0; j < list.size(); j++)
{
FOREACH_MOD(I_OnSyncUserMetaData,OnSyncUserMetaData(u->second,(Module*)TreeProtocolModule,(void*)this,list[j]));
FOREACH_MOD_I(this->Instance,I_OnSyncUserMetaData,OnSyncUserMetaData(u->second,(Module*)TreeProtocolModule,(void*)this,list[j]));
}
}
}
@ -1809,10 +1803,10 @@ class TreeSocket : public InspSocket
std::string endburst = "ENDBURST";
// Because by the end of the netburst, it could be gone!
std::string name = s->GetName();
ServerInstance->WriteOpers("*** Bursting to \2"+name+"\2.");
this->Instance->WriteOpers("*** Bursting to \2"+name+"\2.");
this->WriteLine(burst);
/* send our version string */
this->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" VERSION :"+this->Instance->GetVersionString());
this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" VERSION :"+this->Instance->GetVersionString());
/* Send server tree */
this->SendServers(TreeRoot,s,1);
/* Send users and their oper status */
@ -1820,9 +1814,9 @@ class TreeSocket : public InspSocket
/* Send everything else (channel modes, xlines etc) */
this->SendChannelModes(s);
this->SendXLines(s);
FOREACH_MOD(I_OnSyncOtherMetaData,OnSyncOtherMetaData((Module*)TreeProtocolModule,(void*)this));
FOREACH_MOD_I(this->Instance,I_OnSyncOtherMetaData,OnSyncOtherMetaData((Module*)TreeProtocolModule,(void*)this));
this->WriteLine(endburst);
ServerInstance->WriteOpers("*** Finished bursting to \2"+name+"\2.");
this->Instance->WriteOpers("*** Finished bursting to \2"+name+"\2.");
}
/* This function is called when we receive data from a remote
@ -1918,7 +1912,7 @@ class TreeSocket : public InspSocket
{
if (params.size() < 1)
return false;
ServerInstance->WriteOpers("*** ERROR from %s: %s",(InboundServerName != "" ? InboundServerName.c_str() : myhost.c_str()),params[0].c_str());
this->Instance->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;
}
@ -1930,11 +1924,11 @@ class TreeSocket : public InspSocket
*/
if (params.size() > 1)
{
if (ServerInstance->MatchText(ServerInstance->Config->ServerName, params[1]))
if (this->Instance->MatchText(this->Instance->Config->ServerName, params[1]))
{
/* It's for our server */
string_list results;
userrec* source = ServerInstance->FindNick(prefix);
userrec* source = this->Instance->FindNick(prefix);
if (source)
{
std::deque<std::string> par;
@ -1944,14 +1938,14 @@ class TreeSocket : public InspSocket
for (size_t i = 0; i < results.size(); i++)
{
par[1] = "::" + results[i];
DoOneToOne(ServerInstance->Config->ServerName, "PUSH",par, source->server);
DoOneToOne(this->Instance->Config->ServerName, "PUSH",par, source->server);
}
}
}
else
{
/* Pass it on */
userrec* source = ServerInstance->FindNick(prefix);
userrec* source = this->Instance->FindNick(prefix);
if (source)
DoOneToOne(prefix, "STATS", params, params[1]);
}
@ -1971,7 +1965,7 @@ class TreeSocket : public InspSocket
return true;
}
std::string opertype = params[0];
userrec* u = ServerInstance->FindNick(prefix);
userrec* u = this->Instance->FindNick(prefix);
if (u)
{
u->modes[UM_OPERATOR] = 1;
@ -1989,7 +1983,7 @@ class TreeSocket : public InspSocket
if (params.size() < 3)
return true;
userrec* u = ServerInstance->FindNick(params[0]);
userrec* u = this->Instance->FindNick(params[0]);
if (u)
{
@ -2017,7 +2011,7 @@ class TreeSocket : public InspSocket
if (params.size() < 2)
return true;
userrec* u = ServerInstance->FindNick(params[0]);
userrec* u = this->Instance->FindNick(params[0]);
if (u)
{
@ -2034,10 +2028,10 @@ class TreeSocket : public InspSocket
std::string servermask = params[0];
if (ServerInstance->MatchText(ServerInstance->Config->ServerName,servermask))
if (this->Instance->MatchText(this->Instance->Config->ServerName,servermask))
{
ServerInstance->WriteOpers("*** Remote rehash initiated from server \002"+prefix+"\002.");
ServerInstance->RehashServer();
this->Instance->WriteOpers("*** Remote rehash initiated from server \002"+prefix+"\002.");
this->Instance->RehashServer();
ReadConfiguration(false);
}
DoOneToAllButSender(prefix,"REHASH",params,prefix);
@ -2050,8 +2044,8 @@ class TreeSocket : public InspSocket
return true;
std::string nick = params[0];
userrec* u = ServerInstance->FindNick(prefix);
userrec* who = ServerInstance->FindNick(nick);
userrec* u = this->Instance->FindNick(prefix);
userrec* who = this->Instance->FindNick(nick);
if (who)
{
@ -2090,7 +2084,7 @@ class TreeSocket : public InspSocket
else
{
std::string forwardto = params[1];
if (forwardto == ServerInstance->Config->ServerName)
if (forwardto == this->Instance->Config->ServerName)
{
/*
* this is a PONG for us
@ -2098,7 +2092,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 = ServerInstance->FindNick(prefix);
userrec* u = this->Instance->FindNick(prefix);
if (u)
{
@ -2126,22 +2120,22 @@ class TreeSocket : public InspSocket
{
if (params[0] == "*")
{
FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(TYPE_OTHER,NULL,params[1],params[2]));
FOREACH_MOD_I(this->Instance,I_OnDecodeMetaData,OnDecodeMetaData(TYPE_OTHER,NULL,params[1],params[2]));
}
else if (*(params[0].c_str()) == '#')
{
chanrec* c = ServerInstance->FindChan(params[0]);
chanrec* c = this->Instance->FindChan(params[0]);
if (c)
{
FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(TYPE_CHANNEL,c,params[1],params[2]));
FOREACH_MOD_I(this->Instance,I_OnDecodeMetaData,OnDecodeMetaData(TYPE_CHANNEL,c,params[1],params[2]));
}
}
else if (*(params[0].c_str()) != '#')
{
userrec* u = ServerInstance->FindNick(params[0]);
userrec* u = this->Instance->FindNick(params[0]);
if (u)
{
FOREACH_MOD(I_OnDecodeMetaData,OnDecodeMetaData(TYPE_USER,u,params[1],params[2]));
FOREACH_MOD_I(this->Instance,I_OnDecodeMetaData,OnDecodeMetaData(TYPE_USER,u,params[1],params[2]));
}
}
}
@ -2172,7 +2166,7 @@ class TreeSocket : public InspSocket
if (params.size() < 1)
return true;
userrec* u = ServerInstance->FindNick(prefix);
userrec* u = this->Instance->FindNick(prefix);
if (u)
{
@ -2212,7 +2206,7 @@ class TreeSocket : public InspSocket
break;
default:
/* Just in case... */
ServerInstance->WriteOpers("*** \2WARNING\2: Invalid xline type '"+params[0]+"' sent by server "+prefix+", ignored!");
this->Instance->WriteOpers("*** \2WARNING\2: Invalid xline type '"+params[0]+"' sent by server "+prefix+", ignored!");
propogate = false;
break;
}
@ -2222,11 +2216,11 @@ class TreeSocket : public InspSocket
{
if (atoi(params[4].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());
this->Instance->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
{
ServerInstance->WriteOpers("*** %s Added permenant %cLINE on %s (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),params[5].c_str());
this->Instance->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);
@ -2244,7 +2238,7 @@ class TreeSocket : public InspSocket
if (params.size() < 1)
return true;
userrec* u = ServerInstance->FindNick(prefix);
userrec* u = this->Instance->FindNick(prefix);
if (u)
{
@ -2261,7 +2255,7 @@ class TreeSocket : public InspSocket
return true;
log(DEBUG,"In IDLE command");
userrec* u = ServerInstance->FindNick(prefix);
userrec* u = this->Instance->FindNick(prefix);
if (u)
{
@ -2269,10 +2263,10 @@ class TreeSocket : public InspSocket
// an incoming request
if (params.size() == 1)
{
userrec* x = ServerInstance->FindNick(params[0]);
userrec* x = this->Instance->FindNick(params[0]);
if ((x) && (IS_LOCAL(x)))
{
userrec* x = ServerInstance->FindNick(params[0]);
userrec* x = this->Instance->FindNick(params[0]);
log(DEBUG,"Got IDLE");
char signon[MAXBUF];
char idle[MAXBUF];
@ -2295,7 +2289,7 @@ class TreeSocket : public InspSocket
else if (params.size() == 3)
{
std::string who_did_the_whois = params[0];
userrec* who_to_send_to = ServerInstance->FindNick(who_did_the_whois);
userrec* who_to_send_to = this->Instance->FindNick(who_did_the_whois);
if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
{
log(DEBUG,"Got final IDLE");
@ -2321,7 +2315,7 @@ class TreeSocket : public InspSocket
if (params.size() < 2)
return true;
userrec* u = ServerInstance->FindNick(params[0]);
userrec* u = this->Instance->FindNick(params[0]);
if (!u)
return true;
@ -2346,22 +2340,22 @@ class TreeSocket : public InspSocket
if (params.size() == 2)
{
// someone querying our time?
if (ServerInstance->Config->ServerName == params[0])
if (this->Instance->Config->ServerName == params[0])
{
userrec* u = ServerInstance->FindNick(params[1]);
userrec* u = this->Instance->FindNick(params[1]);
if (u)
{
char curtime[256];
snprintf(curtime,256,"%lu",(unsigned long)time(NULL));
params.push_back(curtime);
params[0] = prefix;
DoOneToOne(ServerInstance->Config->ServerName,"TIME",params,params[0]);
DoOneToOne(this->Instance->Config->ServerName,"TIME",params,params[0]);
}
}
else
{
// not us, pass it on
userrec* u = ServerInstance->FindNick(params[1]);
userrec* u = this->Instance->FindNick(params[1]);
if (u)
DoOneToOne(prefix,"TIME",params,params[0]);
}
@ -2369,7 +2363,7 @@ class TreeSocket : public InspSocket
else if (params.size() == 3)
{
// a response to a previous TIME
userrec* u = ServerInstance->FindNick(params[1]);
userrec* u = this->Instance->FindNick(params[1]);
if ((u) && (IS_LOCAL(u)))
{
time_t rawtime = atol(params[2].c_str());
@ -2397,13 +2391,13 @@ class TreeSocket : public InspSocket
if (params.size() == 1)
{
std::string stufftobounce = params[0];
this->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" PONG "+stufftobounce);
this->WriteLine(std::string(":")+this->Instance->Config->ServerName+" PONG "+stufftobounce);
return true;
}
else
{
std::string forwardto = params[1];
if (forwardto == ServerInstance->Config->ServerName)
if (forwardto == this->Instance->Config->ServerName)
{
// this is a ping for us, send back PONG to the requesting server
params[1] = params[0];
@ -2439,14 +2433,14 @@ class TreeSocket : public InspSocket
if (CheckDupe)
{
this->WriteLine("ERROR :Server "+servername+" already exists!");
ServerInstance->WriteOpers("*** Server connection from \2"+servername+"\2 denied, already exists");
this->Instance->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);
ServerInstance->WriteOpers("*** Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
this->Instance->WriteOpers("*** Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
return true;
}
@ -2463,7 +2457,7 @@ class TreeSocket : public InspSocket
if (hops)
{
this->WriteLine("ERROR :Server too far away for authentication");
ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
this->Instance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
return false;
}
std::string description = params[3];
@ -2475,7 +2469,7 @@ class TreeSocket : public InspSocket
if (CheckDupe)
{
this->WriteLine("ERROR :Server "+sname+" already exists on server "+CheckDupe->GetParent()->GetName()+"!");
ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
this->Instance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
return false;
}
// Begin the sync here. this kickstarts the
@ -2496,7 +2490,7 @@ class TreeSocket : public InspSocket
}
}
this->WriteLine("ERROR :Invalid credentials");
ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, invalid link credentials");
this->Instance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, invalid link credentials");
return false;
}
@ -2513,7 +2507,7 @@ class TreeSocket : public InspSocket
if (hops)
{
this->WriteLine("ERROR :Server too far away for authentication");
ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
this->Instance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
return false;
}
std::string description = params[3];
@ -2525,7 +2519,7 @@ class TreeSocket : public InspSocket
if (CheckDupe)
{
this->WriteLine("ERROR :Server "+sname+" already exists on server "+CheckDupe->GetParent()->GetName()+"!");
ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
this->Instance->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
@ -2535,22 +2529,22 @@ class TreeSocket : public InspSocket
if ((x->EncryptionKey != "") && (!this->ctx_in))
{
this->WriteLine("ERROR :This link requires AES encryption to be enabled. Plaintext connection refused.");
ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, remote server did not enable AES.");
this->Instance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, remote server did not enable AES.");
return false;
}
ServerInstance->WriteOpers("*** Verified incoming server connection from \002"+sname+"\002["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] ("+description+")");
this->Instance->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,
// along with the sendpass from this block.
this->WriteLine(std::string("SERVER ")+ServerInstance->Config->ServerName+" "+x->SendPass+" 0 :"+ServerInstance->Config->ServerDesc);
this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+x->SendPass+" 0 :"+this->Instance->Config->ServerDesc);
// move to the next state, we are now waiting for THEM.
this->LinkState = WAIT_AUTH_2;
return true;
}
}
this->WriteLine("ERROR :Invalid credentials");
ServerInstance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, invalid link credentials");
this->Instance->WriteOpers("*** Server connection from \2"+sname+"\2 denied, invalid link credentials");
return false;
}
@ -2603,7 +2597,7 @@ class TreeSocket : public InspSocket
}
else if ((this->ctx_in) && (command == "AES"))
{
ServerInstance->WriteOpers("*** \2AES\2: Encryption already enabled on this connection yet %s is trying to enable it twice!",params[0].c_str());
this->Instance->WriteOpers("*** \2AES\2: Encryption already enabled on this connection yet %s is trying to enable it twice!",params[0].c_str());
}
switch (this->LinkState)
@ -2671,13 +2665,13 @@ class TreeSocket : public InspSocket
long delta = THEM-time(NULL);
if ((delta < -600) || (delta > 600))
{
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->Instance->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))
{
ServerInstance->WriteOpers("*** \2WARNING\2: Your clocks are out by %d seconds, please consider synching your clocks.",abs(delta));
this->Instance->WriteOpers("*** \2WARNING\2: Your clocks are out by %d seconds, please consider synching your clocks.",abs(delta));
}
}
this->LinkState = CONNECTED;
@ -2729,7 +2723,7 @@ class TreeSocket : public InspSocket
if (prefix != "")
{
std::string direction = prefix;
userrec* t = ServerInstance->FindNick(prefix);
userrec* t = this->Instance->FindNick(prefix);
if (t)
{
direction = t->server;
@ -2883,8 +2877,8 @@ class TreeSocket : public InspSocket
std::string sourceserv = this->myhost;
if (params.size() == 3)
{
userrec* user = ServerInstance->FindNick(params[1]);
chanrec* chan = ServerInstance->FindChan(params[0]);
userrec* user = this->Instance->FindNick(params[1]);
chanrec* chan = this->Instance->FindChan(params[0]);
if (user && chan)
{
if (!chan->ServerKickUser(user, params[2].c_str(), false))
@ -2923,7 +2917,7 @@ class TreeSocket : public InspSocket
{
sourceserv = this->InboundServerName;
}
ServerInstance->WriteOpers("*** Received end of netburst from \2%s\2",sourceserv.c_str());
this->Instance->WriteOpers("*** Received end of netburst from \2%s\2",sourceserv.c_str());
return true;
}
else
@ -2931,7 +2925,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 = ServerInstance->FindNick(prefix);
userrec* who = this->Instance->FindNick(prefix);
std::string sourceserv = this->myhost;
if (this->InboundServerName != "")
{
@ -2945,19 +2939,19 @@ class TreeSocket : public InspSocket
* already exist here. If it does, kill their copy,
* and our copy.
*/
userrec* x = ServerInstance->FindNick(params[0]);
userrec* x = this->Instance->FindNick(params[0]);
if ((x) && (x != who))
{
std::deque<std::string> p;
p.push_back(params[0]);
p.push_back("Nickname collision ("+prefix+" -> "+params[0]+")");
DoOneToMany(ServerInstance->Config->ServerName,"KILL",p);
DoOneToMany(this->Instance->Config->ServerName,"KILL",p);
p.clear();
p.push_back(prefix);
p.push_back("Nickname collision");
DoOneToMany(ServerInstance->Config->ServerName,"KILL",p);
DoOneToMany(this->Instance->Config->ServerName,"KILL",p);
userrec::QuitUser(this->Instance,x,"Nickname collision ("+prefix+" -> "+params[0]+")");
userrec* y = ServerInstance->FindNick(prefix);
userrec* y = this->Instance->FindNick(prefix);
if (y)
{
userrec::QuitUser(this->Instance,y,"Nickname collision");
@ -2972,7 +2966,7 @@ class TreeSocket : public InspSocket
{
strparams[q] = params[q].c_str();
}
if (!ServerInstance->CallCommandHandler(command.c_str(), strparams, params.size(), who))
if (!this->Instance->CallCommandHandler(command.c_str(), strparams, params.size(), who))
{
this->WriteLine("ERROR :Unrecognised command '"+std::string(command.c_str())+"' -- possibly loaded mismatched modules");
return false;
@ -2983,7 +2977,7 @@ class TreeSocket : public InspSocket
// its not a user. Its either a server, or somethings screwed up.
if (IsServer(prefix))
{
target = ServerInstance->Config->ServerName;
target = this->Instance->Config->ServerName;
}
else
{
@ -3014,7 +3008,7 @@ class TreeSocket : public InspSocket
{
if (this->LinkState == CONNECTING)
{
ServerInstance->WriteOpers("*** CONNECT: Connection to \002"+myhost+"\002 timed out.");
this->Instance->WriteOpers("*** CONNECT: Connection to \002"+myhost+"\002 timed out.");
}
}
@ -3033,7 +3027,7 @@ class TreeSocket : public InspSocket
{
Squit(s,"Remote host closed the connection");
}
ServerInstance->WriteOpers("Server '\2%s\2' closed the connection.",quitserver.c_str());
this->Instance->WriteOpers("Server '\2%s\2' closed the connection.",quitserver.c_str());
}
virtual int OnIncomingConnection(int newsock, char* ip)
@ -3053,13 +3047,13 @@ class TreeSocket : public InspSocket
if (!found)
{
ServerInstance->WriteOpers("Server connection from %s denied (no link blocks with that IP address)", ip);
this->Instance->WriteOpers("Server connection from %s denied (no link blocks with that IP address)", ip);
close(newsock);
return false;
}
}
TreeSocket* s = new TreeSocket(this->Instance, newsock, ip);
ServerInstance->AddSocket(s);
this->Instance->AddSocket(s);
return true;
}
};
@ -3426,6 +3420,8 @@ class ModuleSpanningTree : public Module
Bindings.clear();
::ServerInstance = this->ServerInstance;
// Create the root of the tree
TreeRoot = new TreeServer(ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc);

View File

@ -47,7 +47,7 @@ using namespace std;
extern InspIRCd* ServerInstance;
extern chan_hash chanlist;
void spy_userlist(userrec *user,chanrec *c)

View File

@ -8,7 +8,7 @@
static char* dummy;
extern InspIRCd* ServerInstance;
class SSLMode : public ModeHandler
{

View File

@ -26,7 +26,7 @@ using namespace std;
/* $ModDesc: Provides channel +S mode (strip ansi colour) */
extern InspIRCd* ServerInstance;
class ChannelStripColor : public ModeHandler
{

View File

@ -22,7 +22,7 @@
/* $ModDesc: Provides the SWHOIS command which allows setting of arbitary WHOIS lines */
extern InspIRCd* ServerInstance;
class cmd_swhois : public command_t
{

View File

@ -26,7 +26,7 @@ using namespace std;
/* $ModDesc: Povides a proof-of-concept test /WOOT command */
extern InspIRCd* ServerInstance;
class MyV6Resolver : public Resolver
{

View File

@ -29,7 +29,7 @@ using namespace std;
#include "inspircd.h"
extern InspIRCd* ServerInstance;
class TimedBan : public classbase
{

View File

@ -28,7 +28,7 @@ using namespace std;
/* $ModDesc: Provides /tline command used to test who a mask matches */
extern InspIRCd* ServerInstance;
class cmd_tline : public command_t
{

View File

@ -27,7 +27,7 @@ using namespace std;
#include "inspircd.h"
extern InspIRCd* ServerInstance;
class cmd_uninvite : public command_t
{

View File

@ -27,7 +27,7 @@ using namespace std;
/* $ModDesc: Provides support for USERIP command */
extern InspIRCd* ServerInstance;
class cmd_userip : public command_t
{

View File

@ -29,7 +29,7 @@ using namespace std;
/* $ModDesc: Provides support for the /watch command */
extern InspIRCd* ServerInstance;
class watchentry : public classbase
{