#include "socket.h"
#include "helperfuncs.h"
#include "inspircd.h"
+#include "wildcard.h"
#include "inspstring.h"
#include "hashcomp.h"
#include "xline.h"
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
class TreeServer : public classbase
{
+ InspIRCd* ServerInstance; /* Creator */
TreeServer* Parent; /* Parent entry */
TreeServer* Route; /* Route entry */
std::vector<TreeServer*> Children; /* List of child objects */
/* 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 = "";
{
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;
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\
{
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;
}
}
* 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;
}
*/
if (e == I_ERR_CONNECT)
{
- ServerInstance->WriteOpers("*** Connection failed: Connection refused");
+ this->Instance->WriteOpers("*** Connection failed: Connection refused");
}
}
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++)
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;
}
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;
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
{
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 */
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 */
}
/* 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)
}
else
{
- chan = ServerInstance->FindChan(params[0]);
+ chan = this->Instance->FindChan(params[0]);
if (chan)
{
ourTS = chan->age;
/* 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()))
{
}
else
{
- mh = ServerInstance->ModeGrok->FindMode(*x, chan ? MODETYPE_CHANNEL : MODETYPE_USER);
+ mh = this->Instance->ModeGrok->FindMode(*x, chan ? MODETYPE_CHANNEL : MODETYPE_USER);
if (mh)
{
}
else
{
- mh = ServerInstance->ModeGrok->FindMode(*x, chan ? MODETYPE_CHANNEL : MODETYPE_USER);
+ mh = this->Instance->ModeGrok->FindMode(*x, chan ? MODETYPE_CHANNEL : MODETYPE_USER);
if (mh)
{
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())
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! */
}
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.
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.
/* 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
/* 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);
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))
*/
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);
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;
* 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;
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);
/* 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);
}
// 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;
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);
}
params.push_back(mode_users[x]);
}
- DoOneToMany(ServerInstance->Config->ServerName,"FMODE",params);
+ DoOneToMany(this->Instance->Config->ServerName,"FMODE",params);
}
}
return true;
{
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());
}
}
}
- DoOneToAllButSender(ServerInstance->Config->ServerName,"SYNCTS",params,source);
+ DoOneToAllButSender(this->Instance->Config->ServerName,"SYNCTS",params,source);
return true;
}
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
{
// 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;
}
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);
{
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;
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;
{
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);
}
}
}
{
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 */
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++)
{
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]));
}
}
}
{
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]));
}
}
}
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 */
/* 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
{
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;
}
*/
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;
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]);
}
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;
if (params.size() < 3)
return true;
- userrec* u = ServerInstance->FindNick(params[0]);
+ userrec* u = this->Instance->FindNick(params[0]);
if (u)
{
if (params.size() < 2)
return true;
- userrec* u = ServerInstance->FindNick(params[0]);
+ userrec* u = this->Instance->FindNick(params[0]);
if (u)
{
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);
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)
{
else
{
std::string forwardto = params[1];
- if (forwardto == ServerInstance->Config->ServerName)
+ if (forwardto == this->Instance->Config->ServerName)
{
/*
* this is a PONG for us
* 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)
{
{
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]));
}
}
}
if (params.size() < 1)
return true;
- userrec* u = ServerInstance->FindNick(prefix);
+ userrec* u = this->Instance->FindNick(prefix);
if (u)
{
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;
}
{
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);
if (params.size() < 1)
return true;
- userrec* u = ServerInstance->FindNick(prefix);
+ userrec* u = this->Instance->FindNick(prefix);
if (u)
{
return true;
log(DEBUG,"In IDLE command");
- userrec* u = ServerInstance->FindNick(prefix);
+ userrec* u = this->Instance->FindNick(prefix);
if (u)
{
// 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];
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");
if (params.size() < 2)
return true;
- userrec* u = ServerInstance->FindNick(params[0]);
+ userrec* u = this->Instance->FindNick(params[0]);
if (!u)
return true;
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]);
}
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());
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];
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;
}
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];
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
}
}
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;
}
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];
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
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;
}
}
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)
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;
if (prefix != "")
{
std::string direction = prefix;
- userrec* t = ServerInstance->FindNick(prefix);
+ userrec* t = this->Instance->FindNick(prefix);
if (t)
{
direction = t->server;
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))
{
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
// 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 != "")
{
* 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");
{
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;
// 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
{
{
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.");
}
}
{
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)
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;
}
};
Bindings.clear();
+ ::ServerInstance = this->ServerInstance;
+
// Create the root of the tree
TreeRoot = new TreeServer(ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc);