summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd.h58
-rw-r--r--include/modules.h212
-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
8 files changed, 226 insertions, 392 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index b1f6431ab..89c4e1c35 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -242,6 +242,64 @@ class InspIRCd : public classbase
bool IsNick(const char* n);
bool IsIdent(const char* n);
+ userrec* FindDescriptor(int socket);
+
+ bool AddMode(ModeHandler* mh, const unsigned char modechar);
+
+ bool AddModeWatcher(ModeWatcher* mw);
+
+ bool DelModeWatcher(ModeWatcher* mw);
+
+ bool AddResolver(Resolver* r);
+
+ void AddCommand(command_t *f);
+
+ void SendMode(const char **parameters, int pcnt, userrec *user);
+
+ bool MatchText(const std::string &sliteral, const std::string &spattern);
+
+ bool CallCommandHandler(const std::string &commandname, const char** parameters, int pcnt, userrec* user);
+
+ bool IsValidModuleCommand(const std::string &commandname, int pcnt, userrec* user);
+
+ bool IsUlined(const std::string &server);
+
+ void AddGLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask);
+
+ void AddQLine(long duration, const std::string &source, const std::string &reason, const std::string &nickname);
+
+ void AddZLine(long duration, const std::string &source, const std::string &reason, const std::string &ipaddr);
+
+ void AddKLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask);
+
+ void AddELine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask);
+
+ bool DelGLine(const std::string &hostmask);
+
+ bool DelQLine(const std::string &nickname);
+
+ bool DelZLine(const std::string &ipaddr);
+
+ bool DelKLine(const std::string &hostmask);
+
+ bool DelELine(const std::string &hostmask);
+
+ long CalcDuration(const std::string &duration);
+
+ bool IsValidMask(const std::string &mask);
+
+ void AddSocket(InspSocket* sock);
+
+ void RemoveSocket(InspSocket* sock);
+
+ void DelSocket(InspSocket* sock);
+
+ void RehashServer();
+
+ chanrec* GetChannelIndex(long index);
+
+ void DumpText(userrec* User, const std::string &LinePrefix, stringstream &TextStream);
+
std::string GetRevision();
std::string GetVersionString();
void WritePID(const std::string &filename);
diff --git a/include/modules.h b/include/modules.h
index b67462515..90c06361f 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -69,7 +69,6 @@ enum TargetTypeFlags {
#include "mode.h"
#include "dns.h"
-class Server;
class ServerConfig;
// Forward-delacare module for ModuleMessage etc
@@ -402,9 +401,9 @@ class Module : public Extensible
*
* PRIORITY_DONTCARE - To leave your module as it is (this is the default value, if you do not implement this function)
*
- * The result of Server::PriorityBefore() - To move your module before another named module
+ * The result of InspIRCd::PriorityBefore() - To move your module before another named module
*
- * The result of Server::PriorityLast() - To move your module after another named module
+ * The result of InspIRCd::PriorityLast() - To move your module after another named module
*
* For a good working example of this method call, please see src/modules/m_spanningtree.cpp
* and src/modules/m_hostchange.so which make use of it. It is highly recommended that unless
@@ -995,7 +994,7 @@ class Module : public Extensible
* command being executed. If you do this, no output is created by the core, and it is
* down to your module to produce any output neccessary.
* Note that unless you return 1, you should not destroy any structures (e.g. by using
- * Server::QuitUser) otherwise when the command's handler function executes after your
+ * InspIRCd::QuitUser) otherwise when the command's handler function executes after your
* method returns, it will be passed an invalid pointer to the user object and crash!)
* @param command The command being executed
* @param parameters An array of array of characters containing the parameters for the command
@@ -1244,211 +1243,6 @@ class Module : public Extensible
};
-/** Allows server output and query functions
- * This class contains methods which allow a module to query the state of the irc server, and produce
- * output to users and other servers. All modules should instantiate at least one copy of this class,
- * and use its member functions to perform their tasks.
- */
-class Server : public Extensible
-{
- public:
- /** Attempts to look up a nick using the file descriptor associated with that nick.
- * This function will return NULL if the file descriptor is not associated with a valid user.
- */
- userrec* FindDescriptor(int socket);
-
- bool AddMode(ModeHandler* mh, const unsigned char modechar);
-
- bool AddModeWatcher(ModeWatcher* mw);
-
- bool DelModeWatcher(ModeWatcher* mw);
-
- bool AddResolver(Resolver* r);
-
- /** Adds a command to the command table.
- * This allows modules to add extra commands into the command table. You must place a function within your
- * module which is is of type handlerfunc:
- *
- * typedef void (handlerfunc) (char**, int, userrec*);
- * ...
- * void handle_kill(char **parameters, int pcnt, userrec *user)
- *
- * When the command is typed, the parameters will be placed into the parameters array (similar to argv) and
- * the parameter count will be placed into pcnt (similar to argv). There will never be any less parameters
- * than the 'minparams' value you specified when creating the command. The *user parameter is the class of
- * the user which caused the command to trigger, who will always have the flag you specified in 'flags' when
- * creating the initial command. For example to create an oper only command create the commands with flags='o'.
- * The source parameter is used for resource tracking, and should contain the name of your module (with file
- * extension) e.g. "m_blarp.so". If you place the wrong identifier here, you can cause crashes if your module
- * is unloaded.
- */
- void AddCommand(command_t *f);
-
- /** Sends a servermode.
- * you must format the parameters array with the target, modes and parameters for those modes.
- *
- * For example:
- *
- * char *modes[3];
- *
- * modes[0] = ChannelName;
- *
- * modes[1] = "+o";
- *
- * modes[2] = user->nick;
- *
- * Srv->SendMode(modes,3,user);
- *
- * The modes will originate from the server where the command was issued, however responses (e.g. numerics)
- * will be sent to the user you provide as the third parameter.
- * You must be sure to get the number of parameters correct in the pcnt parameter otherwise you could leave
- * your server in an unstable state!
- */
- void SendMode(const char **parameters, int pcnt, userrec *user);
-
- /** Matches text against a glob pattern.
- * Uses the ircd's internal matching function to match string against a globbing pattern, e.g. *!*@*.com
- * Returns true if the literal successfully matches the pattern, false if otherwise.
- */
- bool MatchText(const std::string &sliteral, const std::string &spattern);
-
- /** Calls the handler for a command, either implemented by the core or by another module.
- * You can use this function to trigger other commands in the ircd, such as PRIVMSG, JOIN,
- * KICK etc, or even as a method of callback. By defining command names that are untypeable
- * for users on irc (e.g. those which contain a \r or \n) you may use them as callback identifiers.
- * The first parameter to this method is the name of the command handler you wish to call, e.g.
- * PRIVMSG. This will be a command handler previously registered by the core or wih AddCommand().
- * The second parameter is an array of parameters, and the third parameter is a count of parameters
- * in the array. If you do not pass enough parameters to meet the minimum needed by the handler, the
- * functiom will silently ignore it. The final parameter is the user executing the command handler,
- * used for privilage checks, etc.
- * @return True if the command exists
- */
- bool CallCommandHandler(const std::string &commandname, const char** parameters, int pcnt, userrec* user);
-
- /** This function returns true if the commandname exists, pcnt is equal to or greater than the number
- * of paramters the command requires, the user specified is allowed to execute the command, AND
- * if the command is implemented by a module (not the core). This has a few specific uses, usually
- * within network protocols (see src/modules/m_spanningtree.cpp)
- */
- bool IsValidModuleCommand(const std::string &commandname, int pcnt, userrec* user);
-
- /** Returns true if the servername you give is ulined.
- * ULined servers have extra privilages. They are allowed to change nicknames on remote servers,
- * change modes of clients which are on remote servers and set modes of channels where there are
- * no channel operators for that channel on the ulined server, amongst other things.
- */
- bool IsUlined(const std::string &server);
-
- /** Adds a G-line
- * The G-line is propogated to all of the servers in the mesh and enforced as soon as it is added.
- * The duration must be in seconds, however you can use the Server::CalcDuration method to convert
- * durations into the 1w2d3h3m6s format used by /GLINE etc. The source is an arbitary string used
- * to indicate who or what sent the data, usually this is the nickname of a person, or a server
- * name.
- */
- void AddGLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask);
-
- /** Adds a Q-line
- * The Q-line is propogated to all of the servers in the mesh and enforced as soon as it is added.
- * The duration must be in seconds, however you can use the Server::CalcDuration method to convert
- * durations into the 1w2d3h3m6s format used by /GLINE etc. The source is an arbitary string used
- * to indicate who or what sent the data, usually this is the nickname of a person, or a server
- * name.
- */
- void AddQLine(long duration, const std::string &source, const std::string &reason, const std::string &nickname);
-
- /** Adds a Z-line
- * The Z-line is propogated to all of the servers in the mesh and enforced as soon as it is added.
- * The duration must be in seconds, however you can use the Server::CalcDuration method to convert
- * durations into the 1w2d3h3m6s format used by /GLINE etc. The source is an arbitary string used
- * to indicate who or what sent the data, usually this is the nickname of a person, or a server
- * name.
- */
- void AddZLine(long duration, const std::string &source, const std::string &reason, const std::string &ipaddr);
-
- /** Adds a K-line
- * The K-line is enforced as soon as it is added.
- * The duration must be in seconds, however you can use the Server::CalcDuration method to convert
- * durations into the 1w2d3h3m6s format used by /GLINE etc. The source is an arbitary string used
- * to indicate who or what sent the data, usually this is the nickname of a person, or a server
- * name.
- */
- void AddKLine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask);
-
- /** Adds a E-line
- * The E-line is enforced as soon as it is added.
- * The duration must be in seconds, however you can use the Server::CalcDuration method to convert
- * durations into the 1w2d3h3m6s format used by /GLINE etc. The source is an arbitary string used
- * to indicate who or what sent the data, usually this is the nickname of a person, or a server
- * name.
- */
- void AddELine(long duration, const std::string &source, const std::string &reason, const std::string &hostmask);
-
- /** Deletes a G-Line from all servers
- */
- bool DelGLine(const std::string &hostmask);
-
- /** Deletes a Q-Line from all servers
- */
- bool DelQLine(const std::string &nickname);
-
- /** Deletes a Z-Line from all servers
- */
- bool DelZLine(const std::string &ipaddr);
-
- /** Deletes a local K-Line
- */
- bool DelKLine(const std::string &hostmask);
-
- /** Deletes a local E-Line
- */
- bool DelELine(const std::string &hostmask);
-
- /** Calculates a duration
- * This method will take a string containing a formatted duration (e.g. "1w2d") and return its value
- * as a total number of seconds. This is the same function used internally by /GLINE etc to set
- * the ban times.
- */
- long CalcDuration(const std::string &duration);
-
- /** Returns true if a nick!ident@host string is correctly formatted, false if otherwise.
- */
- bool IsValidMask(const std::string &mask);
-
- /** Adds a class derived from InspSocket to the server's socket engine.
- */
- void AddSocket(InspSocket* sock);
-
- /** Forcibly removes a class derived from InspSocket from the servers socket engine.
- */
- void RemoveSocket(InspSocket* sock);
-
- /** Deletes a class derived from InspSocket from the server's socket engine.
- */
- void DelSocket(InspSocket* sock);
-
- /** Causes the local server to rehash immediately.
- * WARNING: Do not call this method from within your rehash method, for
- * obvious reasons!
- */
- void RehashServer();
-
- /** This method returns a channel whos index is greater than or equal to 0 and less than the number returned by Server::GetChannelCount().
- * This is slower (by factors of dozens) than requesting a channel by name with Server::FindChannel(), however there are times when
- * you wish to safely iterate the channel list, saving your position, with large amounts of time in between, which is what this function
- * is useful for.
- */
- chanrec* GetChannelIndex(long index);
-
- /** Dumps text (in a stringstream) to a user. The stringstream should not contain linefeeds, as it will be split
- * automatically by the function into safe amounts. The line prefix given is prepended onto each line (e.g. a servername
- * and a numeric).
- */
- void DumpText(userrec* User, const std::string &LinePrefix, stringstream &TextStream);
-};
-
-
#define CONF_NOT_A_NUMBER 0x000010
#define CONF_NOT_UNSIGNED 0x000080
#define CONF_VALUE_NOT_FOUND 0x000100
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)
{