summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/inspircd.cpp1
-rw-r--r--src/inspsocket.cpp1
-rw-r--r--src/modules.cpp105
-rw-r--r--src/modules/m_alias.cpp233
-rw-r--r--src/modules/m_antibear.cpp3
-rw-r--r--src/users.cpp5
6 files changed, 165 insertions, 183 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 83689b33c..42612fa2d 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -78,7 +78,6 @@ socklen_t length;
time_t TIME = time(NULL), OLDTIME = time(NULL);
-Server* MyServer = new Server;
char lowermap[255];
void InspIRCd::AddServerName(const std::string &servername)
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index 860b9b44c..804b00c74 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -32,7 +32,6 @@ using irc::sockets::insp_inaddr;
using irc::sockets::insp_sockaddr;
extern time_t TIME;
-extern Server* MyServer;
InspSocket::InspSocket(InspIRCd* SI)
{
diff --git a/src/modules.cpp b/src/modules.cpp
index 6e1b99c9a..03e7856f7 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -220,14 +220,14 @@ void Module::OnCancelAway(userrec* user) { };
* exports in the core
*/
-void Server::AddSocket(InspSocket* sock)
+void InspIRCd::AddSocket(InspSocket* sock)
{
- ServerInstance->module_sockets.push_back(sock);
+ this->module_sockets.push_back(sock);
}
-void Server::RemoveSocket(InspSocket* sock)
+void InspIRCd::RemoveSocket(InspSocket* sock)
{
- for (std::vector<InspSocket*>::iterator a = ServerInstance->module_sockets.begin(); a < ServerInstance->module_sockets.end(); a++)
+ for (std::vector<InspSocket*>::iterator a = this->module_sockets.begin(); a < this->module_sockets.end(); a++)
{
InspSocket* s = (InspSocket*)*a;
if (s == sock)
@@ -303,19 +303,19 @@ const std::string& InspIRCd::GetModuleName(Module* m)
return nothing; /* As above */
}
-void Server::RehashServer()
+void InspIRCd::RehashServer()
{
- ServerInstance->WriteOpers("*** Rehashing config file");
- ServerInstance->Config->Read(false,NULL);
+ this->WriteOpers("*** Rehashing config file");
+ this->Config->Read(false,NULL);
}
-void Server::DelSocket(InspSocket* sock)
+void InspIRCd::DelSocket(InspSocket* sock)
{
- for (std::vector<InspSocket*>::iterator a = ServerInstance->module_sockets.begin(); a < ServerInstance->module_sockets.end(); a++)
+ for (std::vector<InspSocket*>::iterator a = this->module_sockets.begin(); a < this->module_sockets.end(); a++)
{
if (*a == sock)
{
- ServerInstance->module_sockets.erase(a);
+ this->module_sockets.erase(a);
return;
}
}
@@ -328,10 +328,10 @@ void Server::DelSocket(InspSocket* sock)
* m_safelist possible, initially).
*/
-chanrec* Server::GetChannelIndex(long index)
+chanrec* InspIRCd::GetChannelIndex(long index)
{
int target = 0;
- for (chan_hash::iterator n = ServerInstance->chanlist.begin(); n != ServerInstance->chanlist.end(); n++, target++)
+ for (chan_hash::iterator n = this->chanlist.begin(); n != this->chanlist.end(); n++, target++)
{
if (index == target)
return n->second;
@@ -339,41 +339,41 @@ chanrec* Server::GetChannelIndex(long index)
return NULL;
}
-bool Server::MatchText(const std::string &sliteral, const std::string &spattern)
+bool InspIRCd::MatchText(const std::string &sliteral, const std::string &spattern)
{
return match(sliteral.c_str(),spattern.c_str());
}
-bool Server::IsUlined(const std::string &server)
+bool InspIRCd::IsUlined(const std::string &server)
{
return is_uline(server.c_str());
}
-bool Server::CallCommandHandler(const std::string &commandname, const char** parameters, int pcnt, userrec* user)
+bool InspIRCd::CallCommandHandler(const std::string &commandname, const char** parameters, int pcnt, userrec* user)
{
- return ServerInstance->Parser->CallHandler(commandname,parameters,pcnt,user);
+ return this->Parser->CallHandler(commandname,parameters,pcnt,user);
}
-bool Server::IsValidModuleCommand(const std::string &commandname, int pcnt, userrec* user)
+bool InspIRCd::IsValidModuleCommand(const std::string &commandname, int pcnt, userrec* user)
{
- return ServerInstance->Parser->IsValidCommand(commandname, pcnt, user);
+ return this->Parser->IsValidCommand(commandname, pcnt, user);
}
-void Server::AddCommand(command_t *f)
+void InspIRCd::AddCommand(command_t *f)
{
- if (!ServerInstance->Parser->CreateCommand(f))
+ if (!this->Parser->CreateCommand(f))
{
ModuleException err("Command "+std::string(f->command)+" already exists.");
throw (err);
}
}
-void Server::SendMode(const char** parameters, int pcnt, userrec *user)
+void InspIRCd::SendMode(const char** parameters, int pcnt, userrec *user)
{
- ServerInstance->ModeGrok->Process(parameters,pcnt,user,true);
+ this->ModeGrok->Process(parameters,pcnt,user,true);
}
-void Server::DumpText(userrec* User, const std::string &LinePrefix, stringstream &TextStream)
+void InspIRCd::DumpText(userrec* User, const std::string &LinePrefix, stringstream &TextStream)
{
std::string CompleteLine = LinePrefix;
std::string Word = "";
@@ -389,29 +389,29 @@ void Server::DumpText(userrec* User, const std::string &LinePrefix, stringstream
User->WriteServ(CompleteLine);
}
-userrec* Server::FindDescriptor(int socket)
+userrec* InspIRCd::FindDescriptor(int socket)
{
- return (socket < 65536 ? ServerInstance->fd_ref_table[socket] : NULL);
+ return ((socket < MAX_DESCRIPTORS && socket > -1) ? this->fd_ref_table[socket] : NULL);
}
-bool Server::AddMode(ModeHandler* mh, const unsigned char mode)
+bool InspIRCd::AddMode(ModeHandler* mh, const unsigned char mode)
{
- return ServerInstance->ModeGrok->AddMode(mh,mode);
+ return this->ModeGrok->AddMode(mh,mode);
}
-bool Server::AddModeWatcher(ModeWatcher* mw)
+bool InspIRCd::AddModeWatcher(ModeWatcher* mw)
{
- return ServerInstance->ModeGrok->AddModeWatcher(mw);
+ return this->ModeGrok->AddModeWatcher(mw);
}
-bool Server::DelModeWatcher(ModeWatcher* mw)
+bool InspIRCd::DelModeWatcher(ModeWatcher* mw)
{
- return ServerInstance->ModeGrok->DelModeWatcher(mw);
+ return this->ModeGrok->DelModeWatcher(mw);
}
-bool Server::AddResolver(Resolver* r)
+bool InspIRCd::AddResolver(Resolver* r)
{
- return ServerInstance->Res->AddResolverClass(r);
+ return this->Res->AddResolverClass(r);
}
bool InspIRCd::UserToPseudo(userrec* user, const std::string &message)
@@ -428,7 +428,7 @@ bool InspIRCd::UserToPseudo(userrec* user, const std::string &message)
log(DEBUG,"Delete local user");
}
- ServerInstance->SE->DelFd(old_fd);
+ this->SE->DelFd(old_fd);
shutdown(old_fd,2);
close(old_fd);
return true;
@@ -453,7 +453,7 @@ bool InspIRCd::PseudoToUser(userrec* alive, userrec* zombie, const std::string &
log(DEBUG,"Delete local user");
}
// Fix by brain - cant write the user until their fd table entry is updated
- ServerInstance->fd_ref_table[zombie->fd] = zombie;
+ this->fd_ref_table[zombie->fd] = zombie;
zombie->Write(":%s!%s@%s NICK %s",oldnick.c_str(),oldident.c_str(),oldhost.c_str(),zombie->nick);
for (std::vector<ucrec*>::const_iterator i = zombie->chans.begin(); i != zombie->chans.end(); i++)
{
@@ -476,70 +476,70 @@ bool InspIRCd::PseudoToUser(userrec* alive, userrec* zombie, const std::string &
return true;
}
-void Server::AddGLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask)
+void InspIRCd::AddGLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask)
{
add_gline(duration, source.c_str(), reason.c_str(), hostmask.c_str());
apply_lines(APPLY_GLINES);
}
-void Server::AddQLine(long duration, const std::string &source, const std::string &reason, const std::string &nickname)
+void InspIRCd::AddQLine(long duration, const std::string &source, const std::string &reason, const std::string &nickname)
{
add_qline(duration, source.c_str(), reason.c_str(), nickname.c_str());
apply_lines(APPLY_QLINES);
}
-void Server::AddZLine(long duration, const std::string &source, const std::string &reason, const std::string &ipaddr)
+void InspIRCd::AddZLine(long duration, const std::string &source, const std::string &reason, const std::string &ipaddr)
{
add_zline(duration, source.c_str(), reason.c_str(), ipaddr.c_str());
apply_lines(APPLY_ZLINES);
}
-void Server::AddKLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask)
+void InspIRCd::AddKLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask)
{
add_kline(duration, source.c_str(), reason.c_str(), hostmask.c_str());
apply_lines(APPLY_KLINES);
}
-void Server::AddELine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask)
+void InspIRCd::AddELine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask)
{
add_eline(duration, source.c_str(), reason.c_str(), hostmask.c_str());
}
-bool Server::DelGLine(const std::string &hostmask)
+bool InspIRCd::DelGLine(const std::string &hostmask)
{
return del_gline(hostmask.c_str());
}
-bool Server::DelQLine(const std::string &nickname)
+bool InspIRCd::DelQLine(const std::string &nickname)
{
return del_qline(nickname.c_str());
}
-bool Server::DelZLine(const std::string &ipaddr)
+bool InspIRCd::DelZLine(const std::string &ipaddr)
{
return del_zline(ipaddr.c_str());
}
-bool Server::DelKLine(const std::string &hostmask)
+bool InspIRCd::DelKLine(const std::string &hostmask)
{
return del_kline(hostmask.c_str());
}
-bool Server::DelELine(const std::string &hostmask)
+bool InspIRCd::DelELine(const std::string &hostmask)
{
return del_eline(hostmask.c_str());
}
-long Server::CalcDuration(const std::string &delta)
+long InspIRCd::CalcDuration(const std::string &delta)
{
return duration(delta.c_str());
}
/*
* XXX why on *earth* is this in modules.cpp...? I think
- * perhaps we need a server.cpp for Server:: stuff where possible. -- w00t
+ * perhaps we need a server.cpp for InspIRCd:: stuff where possible. -- w00t
*/
-bool Server::IsValidMask(const std::string &mask)
+bool InspIRCd::IsValidMask(const std::string &mask)
{
char* dest = (char*)mask.c_str();
if (strchr(dest,'!')==0)
@@ -582,19 +582,12 @@ Module* InspIRCd::FindModule(const std::string &name)
ConfigReader::ConfigReader()
{
- // ServerInstance->Config->ClearStack();
-
/* Is there any reason to load the entire config file again here?
* it's needed if they specify another config file, but using the
* default one we can just use the global config data - pre-parsed!
*/
- //~ this->cache = new std::stringstream(std::stringstream::in | std::stringstream::out);
this->errorlog = new std::ostringstream(std::stringstream::in | std::stringstream::out);
- //~ this->readerror = ServerInstance->Config->LoadConf(CONFIG_FILE, this->cache,this->errorlog);
- //~ if (!this->readerror)
- //~ this->error = CONF_FILE_NOT_FOUND;
-
this->data = &ServerInstance->Config->config_data;
this->privatehash = false;
}
@@ -602,8 +595,6 @@ ConfigReader::ConfigReader()
ConfigReader::~ConfigReader()
{
- //~ if (this->cache)
- //~ delete this->cache;
if (this->errorlog)
DELETE(this->errorlog);
if(this->privatehash)
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index 85791b070..399ad2ae5 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -20,6 +20,7 @@ using namespace std;
#include "channels.h"
#include "modules.h"
#include "helperfuncs.h"
+#include "commands.h"
#include "inspircd.h"
#include <vector>
@@ -29,153 +30,147 @@ extern InspIRCd* ServerInstance;
class Alias : public classbase
{
- public:
- irc::string text;
- std::string replace_with;
- std::string requires;
- bool uline;
+ public:
+ irc::string text;
+ std::string replace_with;
+ std::string requires;
+ bool uline;
};
class ModuleAlias : public Module
{
- private:
- Server *Srv;
- ConfigReader *MyConf;
- std::vector<Alias> Aliases;
+ private:
+ ConfigReader *MyConf;
+ std::vector<Alias> Aliases;
- virtual void ReadAliases()
+ virtual void ReadAliases()
+ {
+ Aliases.clear();
+
+ for (int i = 0; i < MyConf->Enumerate("alias"); i++)
{
- Aliases.clear();
+ Alias a;
+ std::string txt;
+ txt = MyConf->ReadValue("alias", "text", i);
+ a.text = txt.c_str();
+ a.replace_with = MyConf->ReadValue("alias", "replace", i);
+ a.requires = MyConf->ReadValue("alias", "requires", i);
- for (int i = 0; i < MyConf->Enumerate("alias"); i++)
- {
- Alias a;
- std::string txt;
- txt = MyConf->ReadValue("alias", "text", i);
- a.text = txt.c_str();
- a.replace_with = MyConf->ReadValue("alias", "replace", i);
- a.requires = MyConf->ReadValue("alias", "requires", i);
-
- a.uline = ((MyConf->ReadValue("alias", "uline", i) == "yes") ||
- (MyConf->ReadValue("alias", "uline", i) == "1") ||
- (MyConf->ReadValue("alias", "uline", i) == "true"));
-
- Aliases.push_back(a);
- }
-
+ a.uline = ((MyConf->ReadValue("alias", "uline", i) == "yes") ||
+ (MyConf->ReadValue("alias", "uline", i) == "1") ||
+ (MyConf->ReadValue("alias", "uline", i) == "true"));
+
+ Aliases.push_back(a);
}
- public:
-
- ModuleAlias(InspIRCd* Me)
- : Module::Module(Me)
- {
-
- MyConf = new ConfigReader;
- ReadAliases();
- }
+ }
- void Implements(char* List)
- {
- List[I_OnPreCommand] = List[I_OnRehash] = 1;
- }
-
- virtual ~ModuleAlias()
- {
- DELETE(MyConf);
- }
+ public:
- virtual Version GetVersion()
- {
- return Version(1,0,0,1,VF_VENDOR);
- }
-
- virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+ ModuleAlias(InspIRCd* Me)
+ : Module::Module(Me)
+ {
+
+ MyConf = new ConfigReader;
+ ReadAliases();
+ }
+
+ void Implements(char* List)
+ {
+ List[I_OnPreCommand] = List[I_OnRehash] = 1;
+ }
+
+ virtual ~ModuleAlias()
+ {
+ DELETE(MyConf);
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version(1,0,0,1,VF_VENDOR);
+ }
+
+ virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
+ {
+ userrec *u = NULL;
+ irc::string c = command.c_str();
+ /* If the command is valid, we dont want to know,
+ * and if theyre not registered yet, we dont want
+ * to know either
+ */
+ if ((validated) || (user->registered != REG_ALL))
+ return 0;
+
+ for (unsigned int i = 0; i < Aliases.size(); i++)
{
- userrec *u = NULL;
- irc::string c = command.c_str();
-
- /* If the command is valid, we dont want to know,
- * and if theyre not registered yet, we dont want
- * to know either
- */
- if ((validated) || (user->registered != REG_ALL))
- return 0;
-
- for (unsigned int i = 0; i < Aliases.size(); i++)
+ if (Aliases[i].text == c)
{
- if (Aliases[i].text == c)
+ if (Aliases[i].requires != "")
{
- if (Aliases[i].requires != "")
+ u = ServerInstance->FindNick(Aliases[i].requires);
+ if (!u)
{
- u = ServerInstance->FindNick(Aliases[i].requires);
- if (!u)
- {
- user->WriteServ("401 "+std::string(user->nick)+" "+Aliases[i].requires+" :is currently unavailable. Please try again later.");
- return 1;
- }
+ user->WriteServ("401 "+std::string(user->nick)+" "+Aliases[i].requires+" :is currently unavailable. Please try again later.");
+ return 1;
}
- if ((u != NULL) && (Aliases[i].requires != "") && (Aliases[i].uline))
+ }
+ if ((u != NULL) && (Aliases[i].requires != "") && (Aliases[i].uline))
+ {
+ if (!is_uline(u->server))
{
- if (!Srv->IsUlined(u->server))
- {
- ServerInstance->WriteOpers("*** NOTICE -- Service "+Aliases[i].requires+" required by alias "+std::string(Aliases[i].text.c_str())+" is not on a u-lined server, possibly underhanded antics detected!");
- user->WriteServ("401 "+std::string(user->nick)+" "+Aliases[i].requires+" :is an imposter! Please inform an IRC operator as soon as possible.");
- return 1;
- }
+ ServerInstance->WriteOpers("*** NOTICE -- Service "+Aliases[i].requires+" required by alias "+std::string(Aliases[i].text.c_str())+" is not on a u-lined server, possibly underhanded antics detected!");
+ user->WriteServ("401 "+std::string(user->nick)+" "+Aliases[i].requires+" :is an imposter! Please inform an IRC operator as soon as possible.");
+ return 1;
}
-
+ }
std::string n = "";
- for (int j = 0; j < pcnt; j++)
- {
- if (j)
- n = n + " ";
- n = n + parameters[j];
- }
- /* Final param now in n as one string */
- std::stringstream stuff(Aliases[i].replace_with);
-
+ for (int j = 0; j < pcnt; j++)
+ {
+ if (j)
+ n = n + " ";
+ n = n + parameters[j];
+ }
+ /* Final param now in n as one string */
+ std::stringstream stuff(Aliases[i].replace_with);
std::string cmd = "";
- std::string target = "";
- stuff >> cmd;
- stuff >> target;
-
+ std::string target = "";
+ stuff >> cmd;
+ stuff >> target;
const char* para[2];
- para[0] = target.c_str();
- para[1] = n.c_str();
-
- Srv->CallCommandHandler(cmd,para,2,user);
- return 1;
- }
+ para[0] = target.c_str();
+ para[1] = n.c_str();
+ ServerInstance->CallCommandHandler(cmd,para,2,user);
+ return 1;
}
- return 0;
- }
-
- virtual void OnRehash(const std::string &parameter)
- {
- DELETE(MyConf);
- MyConf = new ConfigReader;
-
- ReadAliases();
- }
+ }
+ return 0;
+ }
+
+ virtual void OnRehash(const std::string &parameter)
+ {
+ DELETE(MyConf);
+ MyConf = new ConfigReader;
+
+ ReadAliases();
+ }
};
class ModuleAliasFactory : public ModuleFactory
{
- public:
- ModuleAliasFactory()
- {
- }
-
- ~ModuleAliasFactory()
- {
- }
-
+ public:
+ ModuleAliasFactory()
+ {
+ }
+
+ ~ModuleAliasFactory()
+ {
+ }
+
virtual Module * CreateModule(InspIRCd* Me)
- {
- return new ModuleAlias(Me);
- }
+ {
+ return new ModuleAlias(Me);
+ }
};
diff --git a/src/modules/m_antibear.cpp b/src/modules/m_antibear.cpp
index f322b0b9a..7a8437935 100644
--- a/src/modules/m_antibear.cpp
+++ b/src/modules/m_antibear.cpp
@@ -26,8 +26,7 @@ using namespace std;
class ModuleAntiBear : public Module
{
private:
-
- Server *Srv;
+
public:
ModuleAntiBear(InspIRCd* Me) : Module::Module(Me)
{
diff --git a/src/users.cpp b/src/users.cpp
index 1a8e52fee..b1378260d 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -32,7 +32,6 @@
#include "cull_list.h"
extern time_t TIME;
-extern Server* MyServer;
irc::whowas::whowas_users whowas;
static unsigned long already_sent[MAX_DESCRIPTORS] = {0};
@@ -129,7 +128,7 @@ void userrec::StartDNSLookup()
{
log(DEBUG,"Passing instance: %08x",this->ServerInstance);
res_reverse = new UserResolver(this->ServerInstance, this, this->GetIPString(), false);
- MyServer->AddResolver(res_reverse);
+ this->ServerInstance->AddResolver(res_reverse);
}
catch (ModuleException& e)
{
@@ -153,7 +152,7 @@ void UserResolver::OnLookupComplete(const std::string &result)
try
{
bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, true);
- MyServer->AddResolver(bound_user->res_forward);
+ this->ServerInstance->AddResolver(bound_user->res_forward);
}
catch (ModuleException& e)
{