summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command_parse.cpp1
-rw-r--r--src/helperfuncs.cpp17
-rw-r--r--src/inspircd.cpp5
-rw-r--r--src/inspircd_io.cpp26
-rw-r--r--src/modules.cpp2
-rw-r--r--src/modules/m_spanningtree.cpp2
-rw-r--r--src/userprocess.cpp6
-rw-r--r--src/users.cpp9
8 files changed, 43 insertions, 25 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 02414039d..6f927e89a 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -68,7 +68,6 @@ extern std::vector<InspSocket*> module_sockets;
extern std::vector<userrec*> local_users;
extern int MODCOUNT;
-extern Module* IOHookModule;
extern InspSocket* socket_ref[65535];
extern time_t TIME;
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index e1ade25c9..037a7a3af 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -61,7 +61,6 @@ static char already_sent[65536];
extern std::vector<userrec*> all_opers;
extern user_hash clientlist;
extern chan_hash chanlist;
-extern Module* IOHookModule;
void log(int level,char *text, ...)
{
@@ -140,9 +139,9 @@ void Write(int sock,char *text, ...)
chop(tb);
if (fd_ref_table[sock])
{
- if (IOHookModule)
+ if (Config->GetIOHook(fd_ref_table[sock]->port))
{
- IOHookModule->OnRawSocketWrite(sock,tb,bytes);
+ Config->GetIOHook(fd_ref_table[sock]->port)->OnRawSocketWrite(sock,tb,bytes);
}
else
{
@@ -173,9 +172,9 @@ void WriteServ(int sock, char* text, ...)
chop(tb);
if (fd_ref_table[sock])
{
- if (IOHookModule)
+ if (Config->GetIOHook(fd_ref_table[sock]->port))
{
- IOHookModule->OnRawSocketWrite(sock,tb,bytes);
+ Config->GetIOHook(fd_ref_table[sock]->port)->OnRawSocketWrite(sock,tb,bytes);
}
else
{
@@ -206,9 +205,9 @@ void WriteFrom(int sock, userrec *user,char* text, ...)
chop(tb);
if (fd_ref_table[sock])
{
- if (IOHookModule)
+ if (Config->GetIOHook(fd_ref_table[sock]->port))
{
- IOHookModule->OnRawSocketWrite(sock,tb,bytes);
+ Config->GetIOHook(fd_ref_table[sock]->port)->OnRawSocketWrite(sock,tb,bytes);
}
else
{
@@ -1065,9 +1064,9 @@ void ShowMOTD(userrec *user)
snprintf(mbuf,MAXBUF,":%s 376 %s :End of message of the day.\r\n", Config->ServerName, user->nick);
WholeMOTD = WholeMOTD + mbuf;
// only one write operation
- if (IOHookModule)
+ if (Config->GetIOHook(user->port))
{
- IOHookModule->OnRawSocketWrite(user->fd,(char*)WholeMOTD.c_str(),WholeMOTD.length());
+ Config->GetIOHook(user->port)->OnRawSocketWrite(user->fd,(char*)WholeMOTD.c_str(),WholeMOTD.length());
}
else
{
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 4055f2a38..c370c7f84 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -74,7 +74,6 @@ extern int MODCOUNT;
int openSockfd[MAXSOCKS];
sockaddr_in client,server;
socklen_t length;
-extern Module* IOHookModule;
extern InspSocket* socket_ref[65535];
@@ -528,9 +527,9 @@ int InspIRCd::Run()
*/
if (incomingSockfd >= 0)
{
- if (IOHookModule)
+ if (Config->GetIOHook(in_port))
{
- IOHookModule->OnRawSocketAccept(incomingSockfd, target, in_port);
+ Config->GetIOHook(in_port)->OnRawSocketAccept(incomingSockfd, target, in_port);
}
stats->statsAccept++;
AddClient(incomingSockfd, target, in_port, false, target);
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index b1e90bfd0..aa6c8e33a 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -63,6 +63,32 @@ void ServerConfig::ClearStack()
include_stack.clear();
}
+Module* ServerConfig::GetIOHook(int port)
+{
+ std::map<int,Module*>::iterator x = IOHookModule.find(port);
+ return (x != IOHookModule.end() ? x->second : NULL);
+}
+
+bool ServerConfig::AddIOHook(int port, Module* iomod)
+{
+ if (!GetIOHook(port))
+ {
+ IOHookModule[port] = iomod;
+ return true;
+ }
+ return false;
+}
+
+bool ServerConfig::DelIOHook(int port)
+{
+ std::map<int,Module*>::iterator x = IOHookModule.find(port);
+ if (x != IOHookModule.end())
+ {
+ IOHookModule.erase(x);
+ return true;
+ }
+ return false;
+}
void ServerConfig::Read(bool bail, userrec* user)
{
diff --git a/src/modules.cpp b/src/modules.cpp
index 71f8f672e..e39821a62 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -66,8 +66,6 @@ extern chan_hash chanlist;
extern command_table cmdlist;
ExtModeList EMode;
-Module* IOHookModule = NULL;
-
// returns true if an extended mode character is in use
bool ModeDefined(char modechar, int type)
{
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 0f10b2de0..33c481391 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -2140,7 +2140,7 @@ void ReadConfiguration(bool rebind)
L.AutoConnect = Conf->ReadInteger("link","autoconnect",j,true);
L.NextConnectTime = time(NULL) + L.AutoConnect;
/* Bugfix by brain, do not allow people to enter bad configurations */
- if ((recvpass != "") && (sendpass != "") && (Name != "") && (Port))
+ if ((L.RecvPass != "") && (L.SendPass != "") && (L.Name != "") && (L.Port))
{
LinkBlocks.push_back(L);
log(DEBUG,"m_spanningtree: Read server %s with host %s:%d",L.Name.c_str(),L.IPAddr.c_str(),L.Port);
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index a73eb7d25..31cb6b68e 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -77,17 +77,15 @@ char data[65536];
extern user_hash clientlist;
extern chan_hash chanlist;
-extern Module* IOHookModule;
-
void ProcessUser(userrec* cu)
{
int result = EAGAIN;
log(DEBUG,"Processing user with fd %d",cu->fd);
- if (IOHookModule)
+ if (Config->GetIOHook(cu->port))
{
int MOD_RESULT = 0;
int result2 = 0;
- IOHookModule->OnRawSocketRead(cu->fd,data,65535,result2);
+ Config->GetIOHook(cu->port)->OnRawSocketRead(cu->fd,data,65535,result2);
if (!MOD_RESULT)
{
result = cu->ReadData(data, 65535);
diff --git a/src/users.cpp b/src/users.cpp
index 18ec1c318..6388b456b 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -49,7 +49,6 @@ extern userrec* fd_ref_table[65536];
extern ServerConfig *Config;
extern user_hash clientlist;
extern whowas_hash whowas;
-extern Module* IOHookModule;
std::vector<userrec*> local_users;
std::vector<userrec*> all_opers;
@@ -375,9 +374,9 @@ void kill_link(userrec *user,const char* r)
if (user->fd > -1)
{
- if (IOHookModule)
+ if (Config->GetIOHook(user->port))
{
- IOHookModule->OnRawSocketClose(user->fd);
+ Config->GetIOHook(user->port)->OnRawSocketClose(user->fd);
}
ServerInstance->SE->DelFd(user->fd);
user->CloseSocket();
@@ -438,9 +437,9 @@ void kill_link_silent(userrec *user,const char* r)
if (user->fd > -1)
{
- if (IOHookModule)
+ if (Config->GetIOHook(user->port))
{
- IOHookModule->OnRawSocketClose(user->fd);
+ Config->GetIOHook(user->port)->OnRawSocketClose(user->fd);
}
ServerInstance->SE->DelFd(user->fd);
user->CloseSocket();