summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-18 20:48:54 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-18 20:48:54 +0000
commitca0889d458ab768f32f399c0afe5f4e36dcd07d9 (patch)
treeccb4caf7a361129a6dd5ecd19581f1bf108895f9
parent6b5767fdd2f372ef5648f438dc68942f39658698 (diff)
Added IOHookModule stuff to allow for different modules to hook different ports
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2564 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--conf/inspircd.conf.example57
-rw-r--r--include/inspircd_io.h8
-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
10 files changed, 68 insertions, 65 deletions
diff --git a/conf/inspircd.conf.example b/conf/inspircd.conf.example
index 95174d2ca..ac48be1ee 100644
--- a/conf/inspircd.conf.example
+++ b/conf/inspircd.conf.example
@@ -11,10 +11,9 @@
# This is an example of the config file for InspIRCd. #
# Change the options to suit your network #
# #
-# Last updated on : 18/12/2005 #
+# Last updated on : 06/06/2005 #
# Written by : CC (cc@backchat.co.za) #
# Updated by : katsklaw (katsklaw@gmail.com) #
-# Updated by: : brain (brain@inspircd.org) #
########################################################################
@@ -60,17 +59,24 @@
# a standard tcp based socket, the servers type is a #
# also a TCP based connection but of a different #
# format. #
-# #
+# default - if the port type is 'servers' then this can be #
+# specified. If set to 'yes', it indicates that this #
+# port is the default route for all /connect commands.#
+# if you do not bind your default route to an #
+# external ip, or all ip's, you may have connection #
+# problems. #
+# #
# Leaving address empty binds to all available interfaces #
# #
# Syntax is as follows: #
# #
# <bind address="ip number" port="port" type="clients"> #
# <bind address="ip number" port="port" type="servers"> #
+# <bind address="ip number" port="port" type="servers" default="yes"> #
# #
<bind address="" port="6660" type="clients">
-<bind address="" port="7000" type="servers">
+<bind address="" port="7000" type="servers" default="yes">
<bind address="" port="7001" type="servers">
@@ -157,7 +163,7 @@
# #
<connect allow="196.12.*" password="secret">
-<connect allow="*" timeout="60" flood="20" threshold="5" pingfreq="120" sendq="262144" recvq="16384">
+<connect allow="*" timeout="60" flood="10" threshold="60" pingfreq="120" sendq="262144" recvq="4096">
<connect deny="69.254.*">
@@ -167,10 +173,6 @@
# Classes are a group of commands which are grouped together #
# and given a unique name. They used to define which commands #
# are available to certain types of Operators. #
-# #
-# Note that you are not restricted just to the class names shown #
-# here and you can make your own up. That is the idea, this ircd #
-# is very unrestrictive about configuration. #
# #
# Syntax is as follow: #
# <class name="name" commands="oper commands"> #
@@ -194,16 +196,11 @@
# server admin to decide on which operators get #
# what commands #
# host - hostmask operators will recieve on oper-up. #
-# (optional) #
+#(optional) #
# #
# Syntax is as follows: #
# <type name="name" classes="class name" host="oper hostmask"> #
# #
-# Please note that you are not restricted to just the four oper types #
-# shown below. You can make up your own opertypes, that is what its #
-# designed for! Please note that oper types, and classes above, are #
-# case sensitive and may only be one word long, no spaces. #
-# #
<type name="NetAdmin" classes="OperChat BanControl HostCloak Shutdown ServerLink" host="netadmin.omega.org.za">
<type name="GlobalOp" classes="OperChat BanControl HostCloak ServerLink" host="ircop.omega.org.za">
@@ -247,7 +244,7 @@
# not have to resolve - but it is expected to be sent #
# in the remote servers connection info. #
# ipaddr - Valid host or ip address for remote server. * #
-# port - Valid listening TCP port for remote server. #
+# port - Valid listening UDP port for remote server. #
# sendpass - Password to send to create an outbound connection to #
# this server. #
# recvpass - Password to receive to accept an inbound connection #
@@ -311,11 +308,7 @@
# shell using shell scripts, perl scripts etc, and to monitor the #
# ircd's state via cron jobs. #
# #
-# This tag is NOT optional and must be defined. Once you have defined #
-# it, remove the die tag above it to mark it as valid. #
-# #
-<die value="Someone did not define their PID file path!">
<pid file="/path/to/inspircd.pid">
#-#-#-#-#-#-#-#-#-#-#-#-#- BANLIST LIMITS #-#-#-#-#-#-#-#-#-#-#-#-#-#-#
@@ -397,9 +390,12 @@
netbuffersize="10240"
maxwho="128"
noservices="0"
+ somaxconn="128"
+ softlimit="128"
allowhalfop="yes">
+
#-#-#-#-#-#-#-#-#-#-#-#-#- MODULE OPTIONS -#-#-#-#-#-#-#-#-#-#-#-#-#
# #
# These tags define which modules will be loaded on startup by your #
@@ -419,23 +415,8 @@
# are incorporated into the executable and can be loaded and removed #
# similarly to if they were in a ramdisk. #
-
-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
-# ____ _____ _ ____ _____ _ _ ___ ____ ____ ___ _____ _
-# | _ \| ____| / \ | _ \ |_ _| | | |_ _/ ___| | __ )_ _|_ _| |
-# | |_) | _| / _ \ | | | | | | | |_| || |\___ \ | _ \| | | | | |
-# | _ <| |___ / ___ \| |_| | | | | _ || | ___) | | |_) | | | | |_|
-# |_| \_\_____/_/ \_\____/ |_| |_| |_|___|____/ |____/___| |_| (_)
-#
-# Please note that as of 1.0 Beta 6 and onwards, linking is modular.
-# This means that unless you load m_spanningtree.so (as commented out
-# below) you will be UNABLE TO LINK ANY SERVERS (including services!).
-# Uncommenting the tag below loads basic linking support.
-#
-#<module name="m_spanningtree.so">
-
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
-# Foobar module - does nothing. This is a test module for coders.
+# Foobar module - does nothing
#<module name="m_foobar.so">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
@@ -653,10 +634,6 @@
# Oper modes module: Allows you to specify modes to add/remove on oper
#<module name="m_opermodes.so">
-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
-# SWHOIS module. Allows opers to place arbitary text in their WHOIS.
-#<module name="m_swhois.so">
-
#-#-#-#-#-#-#-#-#-#-#- FILTER CONFIGURATION -#-#-#-#-#-#-#-#-#-#-#-#
# #
diff --git a/include/inspircd_io.h b/include/inspircd_io.h
index 19338e54b..158794555 100644
--- a/include/inspircd_io.h
+++ b/include/inspircd_io.h
@@ -22,6 +22,7 @@
#include <vector>
#include "inspircd.h"
#include "globals.h"
+#include "modules.h"
/** Flags for use with log()
*/
@@ -250,6 +251,10 @@ class ServerConfig : public classbase
*/
int ports[255];
+ /** A list of ports claimed by IO Modules
+ */
+ std::map<int,Module*> IOHookModule;
+
ServerConfig();
/** Clears the include stack in preperation for
@@ -269,6 +274,9 @@ class ServerConfig : public classbase
int ConfValueEnum(char* tag,std::stringstream *config);
int EnumConf(std::stringstream *config_f,const char* tag);
int EnumValues(std::stringstream *config, const char* tag, int index);
+ Module* GetIOHook(int port);
+ bool AddIOHook(int port, Module* iomod);
+ bool DelIOHook(int port);
};
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();