summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-04-08 17:05:48 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-04-08 17:05:48 +0000
commitd54fbc71e2a2e0f70002e2d36c669c4aa3d59e17 (patch)
tree9e22656474f0fc034de7cf317d7aa7ae22a8abe8 /src
parent315cd88a911eaa327df520e8533be82efea0c66f (diff)
Split inspircd_io.* insp inspsocket.* and configreader.* with a few odd bits going into inspircd.*, doesn't look like I've broken anything... :P
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3847 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp4
-rw-r--r--src/cmd_admin.cpp17
-rw-r--r--src/cmd_away.cpp20
-rw-r--r--src/cmd_die.cpp16
-rw-r--r--src/cmd_eline.cpp21
-rw-r--r--src/cmd_gline.cpp21
-rw-r--r--src/cmd_info.cpp16
-rw-r--r--src/cmd_invite.cpp17
-rw-r--r--src/cmd_kill.cpp24
-rw-r--r--src/cmd_kline.cpp35
-rw-r--r--src/cmd_links.cpp15
-rw-r--r--src/cmd_map.cpp13
-rw-r--r--src/cmd_modules.cpp38
-rw-r--r--src/cmd_nick.cpp34
-rw-r--r--src/cmd_notice.cpp33
-rw-r--r--src/cmd_oper.cpp29
-rw-r--r--src/cmd_ping.cpp43
-rw-r--r--src/cmd_privmsg.cpp40
-rw-r--r--src/cmd_qline.cpp26
-rw-r--r--src/cmd_quit.cpp22
-rw-r--r--src/cmd_rehash.cpp42
-rw-r--r--src/cmd_restart.cpp45
-rw-r--r--src/cmd_stats.cpp37
-rw-r--r--src/cmd_time.cpp47
-rw-r--r--src/cmd_topic.cpp41
-rw-r--r--src/cmd_user.cpp42
-rw-r--r--src/cmd_version.cpp32
-rw-r--r--src/cmd_wallops.cpp33
-rw-r--r--src/cmd_who.cpp40
-rw-r--r--src/cmd_whois.cpp39
-rw-r--r--src/cmd_whowas.cpp41
-rw-r--r--src/cmd_zline.cpp25
-rw-r--r--src/command_parse.cpp12
-rw-r--r--src/commands.cpp15
-rw-r--r--src/dnsqueue.cpp23
-rw-r--r--src/dynamic.cpp2
-rw-r--r--src/helperfuncs.cpp45
-rw-r--r--src/inspircd.cpp100
-rw-r--r--src/message.cpp2
-rw-r--r--src/mode.cpp2
-rw-r--r--src/modules.cpp18
-rw-r--r--src/modules/extra/m_sqloper.cpp2
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp1
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp1
-rw-r--r--src/modules/m_spanningtree.cpp7
-rw-r--r--src/modules/m_spanningtree_ng.cpp7
-rw-r--r--src/socket.cpp482
-rw-r--r--src/userprocess.cpp3
-rw-r--r--src/users.cpp5
49 files changed, 389 insertions, 1286 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 164525abe..4eba586ab 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -16,7 +16,7 @@
using namespace std;
-#include "inspircd_config.h"
+#include "configreader.h"
#include "inspircd.h"
#include "inspircd_io.h"
#include <unistd.h>
@@ -672,5 +672,3 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason)
}
}
}
-
-
diff --git a/src/cmd_admin.cpp b/src/cmd_admin.cpp
index 0bb4b07fe..735e593c7 100644
--- a/src/cmd_admin.cpp
+++ b/src/cmd_admin.cpp
@@ -14,23 +14,10 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <string>
-#include <vector>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "inspstring.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
#include "cmd_admin.h"
extern ServerConfig* Config;
@@ -42,5 +29,3 @@ void cmd_admin::Handle (char **parameters, int pcnt, userrec *user)
WriteServ(user->fd,"258 %s :Nickname - %s",user->nick,Config->AdminNick);
WriteServ(user->fd,"258 %s :E-Mail - %s",user->nick,Config->AdminEmail);
}
-
-
diff --git a/src/cmd_away.cpp b/src/cmd_away.cpp
index 65e613acb..732cf9d91 100644
--- a/src/cmd_away.cpp
+++ b/src/cmd_away.cpp
@@ -14,27 +14,13 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <string>
-#include <map>
-#include <sstream>
#include <vector>
-#include <deque>
+#include "inspircd_config.h"
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "message.h"
#include "commands.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
#include "cmd_away.h"
extern ServerConfig* Config;
@@ -59,5 +45,3 @@ void cmd_away::Handle (char **parameters, int pcnt, userrec *user)
FOREACH_MOD(I_OnCancelAway,OnCancelAway(user));
}
}
-
-
diff --git a/src/cmd_die.cpp b/src/cmd_die.cpp
index bc8f58099..a8d3f14e6 100644
--- a/src/cmd_die.cpp
+++ b/src/cmd_die.cpp
@@ -14,23 +14,13 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
+#include <unistd.h>
#include <string>
+#include <vector>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "inspstring.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
#include "cmd_die.h"
extern ServerConfig* Config;
diff --git a/src/cmd_eline.cpp b/src/cmd_eline.cpp
index b7b49472c..e25f2b7fe 100644
--- a/src/cmd_eline.cpp
+++ b/src/cmd_eline.cpp
@@ -14,31 +14,14 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
#include <string>
-#include <map>
-#include <sstream>
#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
#include "xline.h"
-#include "inspstring.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_eline.h"
extern int MODCOUNT;
@@ -80,5 +63,3 @@ void cmd_eline::Handle (char **parameters, int pcnt, userrec *user)
// no need to apply the lines for an eline
}
-
-
diff --git a/src/cmd_gline.cpp b/src/cmd_gline.cpp
index 5285383cc..0d01c0875 100644
--- a/src/cmd_gline.cpp
+++ b/src/cmd_gline.cpp
@@ -14,31 +14,14 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
#include <string>
-#include <map>
-#include <sstream>
#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
#include "xline.h"
-#include "inspstring.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_eline.h"
extern ServerConfig* Config;
@@ -80,5 +63,3 @@ void cmd_gline::Handle (char **parameters, int pcnt, userrec *user)
}
}
}
-
-
diff --git a/src/cmd_info.cpp b/src/cmd_info.cpp
index 692fa0e07..1f3e3182f 100644
--- a/src/cmd_info.cpp
+++ b/src/cmd_info.cpp
@@ -14,23 +14,11 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <string>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "message.h"
#include "commands.h"
-#include "inspstring.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
#include "cmd_info.h"
extern ServerConfig* Config;
@@ -82,5 +70,3 @@ void cmd_info::Handle (char **parameters, int pcnt, userrec *user)
FOREACH_MOD(I_OnInfo,OnInfo(user));
WriteServ(user->fd, "374 %s :End of /INFO list", user->nick);
}
-
-
diff --git a/src/cmd_invite.cpp b/src/cmd_invite.cpp
index 33e61189d..8baeb30b0 100644
--- a/src/cmd_invite.cpp
+++ b/src/cmd_invite.cpp
@@ -14,26 +14,13 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <string>
#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "message.h"
#include "commands.h"
-#include "inspstring.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
-#include "command_parse.h"
+#include "message.h"
#include "cmd_invite.h"
extern ServerConfig* Config;
diff --git a/src/cmd_kill.cpp b/src/cmd_kill.cpp
index f90347e95..44594a0e1 100644
--- a/src/cmd_kill.cpp
+++ b/src/cmd_kill.cpp
@@ -14,30 +14,14 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
#include <vector>
-#include <deque>
+#include "inspircd_config.h"
+#include "hash_map.h"
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "message.h"
#include "commands.h"
-#include "inspstring.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
#include "cmd_kill.h"
extern ServerConfig* Config;
@@ -103,5 +87,3 @@ void cmd_kill::Handle (char **parameters, int pcnt, userrec *user)
WriteServ(user->fd, "401 %s %s :No such nick/channel", user->nick, parameters[0]);
}
}
-
-
diff --git a/src/cmd_kline.cpp b/src/cmd_kline.cpp
index 9c840b469..d6805c4d5 100644
--- a/src/cmd_kline.cpp
+++ b/src/cmd_kline.cpp
@@ -14,53 +14,28 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
#include <time.h>
#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
#include <map>
#include <sstream>
#include <vector>
#include <deque>
+
+#include "inspircd_config.h"
+#include "configreader.h"
+#include "hash_map.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "mode.h"
#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_kline.h"
extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
extern int MODCOUNT;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
void cmd_kline::Handle (char **parameters, int pcnt, userrec *user)
{
@@ -96,5 +71,3 @@ void cmd_kline::Handle (char **parameters, int pcnt, userrec *user)
}
}
}
-
-
diff --git a/src/cmd_links.cpp b/src/cmd_links.cpp
index 9b1061a03..e94a04edc 100644
--- a/src/cmd_links.cpp
+++ b/src/cmd_links.cpp
@@ -14,23 +14,12 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <string>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "message.h"
#include "commands.h"
-#include "inspstring.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
#include "cmd_links.h"
extern ServerConfig* Config;
@@ -40,5 +29,3 @@ void cmd_links::Handle (char **parameters, int pcnt, userrec *user)
WriteServ(user->fd,"364 %s %s %s :0 %s",user->nick,Config->ServerName,Config->ServerName,Config->ServerDesc);
WriteServ(user->fd,"365 %s * :End of /LINKS list.",user->nick);
}
-
-
diff --git a/src/cmd_map.cpp b/src/cmd_map.cpp
index 5949420aa..07173eb2a 100644
--- a/src/cmd_map.cpp
+++ b/src/cmd_map.cpp
@@ -14,21 +14,11 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
-#include "modules.h"
-#include "message.h"
#include "commands.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_map.h"
extern ServerConfig* Config;
@@ -41,4 +31,3 @@ void cmd_map::Handle (char **parameters, int pcnt, userrec *user)
WriteServ(user->fd,"006 %s :%s",user->nick,Config->ServerName);
WriteServ(user->fd,"007 %s :End of /MAP",user->nick);
}
-
diff --git a/src/cmd_modules.cpp b/src/cmd_modules.cpp
index 0e5b12672..e4e208f7d 100644
--- a/src/cmd_modules.cpp
+++ b/src/cmd_modules.cpp
@@ -14,53 +14,27 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
#include <time.h>
#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
#include <map>
#include <sstream>
#include <vector>
#include <deque>
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "configreader.h"
+#include "hash_map.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
+#include "wildcard.h"
#include "cmd_modules.h"
extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
extern int MODCOUNT;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
-extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
char* itab[] = {
"OnUserConnect", "OnUserQuit", "OnUserDisconnect", "OnUserJoin", "OnUserPart", "OnRehash", "OnServerRaw",
@@ -143,5 +117,3 @@ void cmd_modules::Handle (char **parameters, int pcnt, userrec *user)
}
WriteServ(user->fd,"901 %s :End of MODULES list",user->nick);
}
-
-
diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp
index 26a603867..16b3d2b94 100644
--- a/src/cmd_nick.cpp
+++ b/src/cmd_nick.cpp
@@ -14,53 +14,26 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
#include <vector>
-#include <deque>
+#include "inspircd_config.h"
+#include "configreader.h"
+#include "hash_map.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "mode.h"
#include "xline.h"
-#include "inspstring.h"
#include "dnsqueue.h"
#include "dns.h"
#include "helperfuncs.h"
#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_nick.h"
extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
extern int MODCOUNT;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
void cmd_nick::Handle (char **parameters, int pcnt, userrec *user)
{
@@ -194,4 +167,3 @@ void cmd_nick::Handle (char **parameters, int pcnt, userrec *user)
FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(user,oldnick));
}
}
-
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
index 784f1e185..6a9af4a40 100644
--- a/src/cmd_notice.cpp
+++ b/src/cmd_notice.cpp
@@ -14,39 +14,19 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
#include <map>
#include <sstream>
#include <vector>
#include <deque>
+#include "configreader.h"
+#include "hash_map.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
#include "message.h"
+#include "wildcard.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_notice.h"
extern ServerConfig* Config;
@@ -55,11 +35,6 @@ extern int MODCOUNT;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
void cmd_notice::Handle (char **parameters, int pcnt, userrec *user)
{
@@ -159,5 +134,3 @@ void cmd_notice::Handle (char **parameters, int pcnt, userrec *user)
WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
}
}
-
-
diff --git a/src/cmd_oper.cpp b/src/cmd_oper.cpp
index 2681da13e..718465e9f 100644
--- a/src/cmd_oper.cpp
+++ b/src/cmd_oper.cpp
@@ -14,24 +14,13 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
#include <sstream>
#include <vector>
-#include <deque>
+#include "inspircd_config.h"
+#include "configreader.h"
+#include "typedefs.h"
#include "users.h"
-#include "ctables.h"
#include "globals.h"
#include "modules.h"
#include "dynamic.h"
@@ -45,21 +34,15 @@ using namespace std;
#include "helperfuncs.h"
#include "hashcomp.h"
#include "socketengine.h"
-#include "typedefs.h"
+
#include "command_parse.h"
#include "cmd_oper.h"
extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+extern ModuleList modules;
+extern FactoryList factory;
extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
bool OneOfMatches(const char* host, const char* hostlist)
{
diff --git a/src/cmd_ping.cpp b/src/cmd_ping.cpp
index ee43c0cb8..2ac09e6c4 100644
--- a/src/cmd_ping.cpp
+++ b/src/cmd_ping.cpp
@@ -14,56 +14,15 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
-#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_ping.h"
extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
void cmd_ping::Handle (char **parameters, int pcnt, userrec *user)
{
WriteServ(user->fd,"PONG %s :%s",Config->ServerName,parameters[0]);
}
-
-
diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp
index 85bb4d6d2..0814c08c4 100644
--- a/src/cmd_privmsg.cpp
+++ b/src/cmd_privmsg.cpp
@@ -14,52 +14,24 @@
* ---------------------------------------------------
*/
-using namespace std;
-
+#include <string>
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
#include "message.h"
+#include "wildcard.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_privmsg.h"
extern ServerConfig* Config;
extern InspIRCd* ServerInstance;
extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+extern ModuleList modules;
+extern FactoryList factory;
extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
void cmd_privmsg::Handle (char **parameters, int pcnt, userrec *user)
{
@@ -163,5 +135,3 @@ void cmd_privmsg::Handle (char **parameters, int pcnt, userrec *user)
WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
}
}
-
-
diff --git a/src/cmd_qline.cpp b/src/cmd_qline.cpp
index 76e9a7b80..e86c23a09 100644
--- a/src/cmd_qline.cpp
+++ b/src/cmd_qline.cpp
@@ -14,37 +14,19 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
#include "xline.h"
-#include "inspstring.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_eline.h"
extern ServerConfig* Config;
extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+extern ModuleList modules;
+extern FactoryList factory;
void cmd_qline::Handle (char **parameters, int pcnt, userrec *user)
{
@@ -77,5 +59,3 @@ void cmd_qline::Handle (char **parameters, int pcnt, userrec *user)
}
}
}
-
-
diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp
index 4863d6333..e3529278c 100644
--- a/src/cmd_quit.cpp
+++ b/src/cmd_quit.cpp
@@ -14,22 +14,11 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
+#include "configreader.h"
#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
#include <vector>
-#include <deque>
#include "users.h"
#include "ctables.h"
#include "globals.h"
@@ -45,19 +34,16 @@ using namespace std;
#include "helperfuncs.h"
#include "hashcomp.h"
#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_quit.h"
extern ServerConfig* Config;
extern InspIRCd* ServerInstance;
extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+extern ModuleList modules;
+extern FactoryList factory;
extern time_t TIME;
extern user_hash clientlist;
extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
extern std::vector<userrec*> local_users;
extern userrec* fd_ref_table[MAX_DESCRIPTORS];
@@ -133,5 +119,3 @@ void cmd_quit::Handle (char **parameters, int pcnt, userrec *user)
fd_ref_table[user->fd] = NULL;
delete user;
}
-
-
diff --git a/src/cmd_rehash.cpp b/src/cmd_rehash.cpp
index 421ad9b13..8c219ad90 100644
--- a/src/cmd_rehash.cpp
+++ b/src/cmd_rehash.cpp
@@ -14,52 +14,18 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_rehash.h"
extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
+extern ModuleList modules;
+extern FactoryList factory;
void cmd_rehash::Handle (char **parameters, int pcnt, userrec *user)
{
@@ -76,5 +42,3 @@ void cmd_rehash::Handle (char **parameters, int pcnt, userrec *user)
}
FOREACH_MOD(I_OnRehash,OnRehash(parameter));
}
-
-
diff --git a/src/cmd_restart.cpp b/src/cmd_restart.cpp
index c16570a74..01cf650db 100644
--- a/src/cmd_restart.cpp
+++ b/src/cmd_restart.cpp
@@ -14,52 +14,13 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
-#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_restart.h"
-extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
+extern ServerConfig* Config;;
void cmd_restart::Handle (char **parameters, int pcnt, userrec *user)
{
@@ -100,5 +61,3 @@ void cmd_restart::Handle (char **parameters, int pcnt, userrec *user)
WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host);
}
}
-
-
diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp
index 4f2de6dfe..c83974ec4 100644
--- a/src/cmd_stats.cpp
+++ b/src/cmd_stats.cpp
@@ -14,18 +14,10 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
+#include "configreader.h"
+#include "hash_map.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
@@ -36,10 +28,7 @@ using namespace std;
#define RUSAGE_SELF 0
#define RUSAGE_CHILDREN -1
#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+
#include "users.h"
#include "ctables.h"
#include "globals.h"
@@ -55,21 +44,17 @@ using namespace std;
#include "helperfuncs.h"
#include "hashcomp.h"
#include "socketengine.h"
-#include "typedefs.h"
#include "command_parse.h"
#include "cmd_stats.h"
extern ServerConfig* Config;
extern InspIRCd* ServerInstance;
extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+extern ModuleList modules;
+extern FactoryList factory;
extern time_t TIME;
extern user_hash clientlist;
extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
void cmd_stats::Handle (char **parameters, int pcnt, userrec *user)
{
@@ -205,12 +190,12 @@ void cmd_stats::Handle (char **parameters, int pcnt, userrec *user)
if (*parameters[0] == 'T')
{
- WriteServ(user->fd,"249 Brain :accepts %d refused %d",ServerInstance->stats->statsAccept,ServerInstance->stats->statsRefused);
- WriteServ(user->fd,"249 Brain :unknown commands %d",ServerInstance->stats->statsUnknown);
- WriteServ(user->fd,"249 Brain :nick collisions %d",ServerInstance->stats->statsCollisions);
- WriteServ(user->fd,"249 Brain :dns requests %d succeeded %d failed %d",ServerInstance->stats->statsDns,ServerInstance->stats->statsDnsGood,ServerInstance->stats->statsDnsBad);
- WriteServ(user->fd,"249 Brain :connections %d",ServerInstance->stats->statsConnects);
- WriteServ(user->fd,"249 Brain :bytes sent %dK recv %dK",(ServerInstance->stats->statsSent / 1024),(ServerInstance->stats->statsRecv / 1024));
+ WriteServ(user->fd,"249 %s :accepts %d refused %d",user->nick,ServerInstance->stats->statsAccept,ServerInstance->stats->statsRefused);
+ WriteServ(user->fd,"249 %s :unknown commands %d",user->nick,ServerInstance->stats->statsUnknown);
+ WriteServ(user->fd,"249 %s :nick collisions %d",user->nick,ServerInstance->stats->statsCollisions);
+ WriteServ(user->fd,"249 %s :dns requests %d succeeded %d failed %d",user->nick,ServerInstance->stats->statsDns,ServerInstance->stats->statsDnsGood,ServerInstance->stats->statsDnsBad);
+ WriteServ(user->fd,"249 %s :connections %d",user->nick,ServerInstance->stats->statsConnects);
+ WriteServ(user->fd,"249 %s :bytes sent %dK recv %dK",user->nick,(ServerInstance->stats->statsSent / 1024),(ServerInstance->stats->statsRecv / 1024));
}
/* stats o */
diff --git a/src/cmd_time.cpp b/src/cmd_time.cpp
index f914add49..cabb260c6 100644
--- a/src/cmd_time.cpp
+++ b/src/cmd_time.cpp
@@ -14,60 +14,21 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
-#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_time.h"
extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
void cmd_time::Handle (char **parameters, int pcnt, userrec *user)
{
- time_t rawtime;
- struct tm * timeinfo;
+ struct tm* timeinfo;
- time(&rawtime);
- timeinfo = localtime(&rawtime);
+ timeinfo = localtime(&TIME);
char tms[26];
snprintf(tms,26,"%s",asctime(timeinfo));
@@ -76,5 +37,3 @@ void cmd_time::Handle (char **parameters, int pcnt, userrec *user)
WriteServ(user->fd,"391 %s %s :%s",user->nick,Config->ServerName,tms);
}
-
-
diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp
index 0b94eb53b..b9051ea6f 100644
--- a/src/cmd_topic.cpp
+++ b/src/cmd_topic.cpp
@@ -14,52 +14,19 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
#include "message.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
-#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_topic.h"
extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
+extern ModuleList modules;
+extern FactoryList factory;
void cmd_topic::Handle (char **parameters, int pcnt, userrec *user)
{
@@ -135,5 +102,3 @@ void cmd_topic::Handle (char **parameters, int pcnt, userrec *user)
}
}
}
-
-
diff --git a/src/cmd_user.cpp b/src/cmd_user.cpp
index d088a80f0..f606751d7 100644
--- a/src/cmd_user.cpp
+++ b/src/cmd_user.cpp
@@ -14,52 +14,18 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
-#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
#include "message.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_user.h"
extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
+extern ModuleList modules;
+extern FactoryList factory;
void cmd_user::Handle (char **parameters, int pcnt, userrec *user)
{
@@ -93,5 +59,3 @@ void cmd_user::Handle (char **parameters, int pcnt, userrec *user)
//ConnectUser(user,NULL);
}
}
-
-
diff --git a/src/cmd_version.cpp b/src/cmd_version.cpp
index 8e80e3778..bdb8a8b23 100644
--- a/src/cmd_version.cpp
+++ b/src/cmd_version.cpp
@@ -14,39 +14,11 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
-#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_version.h"
extern ServerConfig* Config;
@@ -75,5 +47,3 @@ void cmd_version::Handle (char **parameters, int pcnt, userrec *user)
}
}
}
-
-
diff --git a/src/cmd_wallops.cpp b/src/cmd_wallops.cpp
index 077ead78e..bad638815 100644
--- a/src/cmd_wallops.cpp
+++ b/src/cmd_wallops.cpp
@@ -14,39 +14,10 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
-#include "users.h"
-#include "ctables.h"
-#include "globals.h"
+#include "configreader.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_wallops.h"
extern int MODCOUNT;
@@ -59,5 +30,3 @@ void cmd_wallops::Handle (char **parameters, int pcnt, userrec *user)
WriteWallOps(user,false,"%s",parameters[0]);
FOREACH_MOD(I_OnWallops,OnWallops(user,parameters[0]));
}
-
-
diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp
index f5a376e39..49c44765c 100644
--- a/src/cmd_who.cpp
+++ b/src/cmd_who.cpp
@@ -14,59 +14,24 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
-#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
#include "message.h"
+#include "modules.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
-#include "inspircd.h"
#include "cmd_who.h"
extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-extern time_t TIME;
extern user_hash clientlist;
extern chan_hash chanlist;
extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
{
chanrec* Ptr = NULL;
char tmp[10];
- /* theres more to do here, but for now just close the socket */
if (pcnt == 1)
{
if ((IS_SINGLE(parameters[0],'0')) || (IS_SINGLE(parameters[0],'*')))
@@ -185,4 +150,3 @@ void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
}
}
}
-
diff --git a/src/cmd_whois.cpp b/src/cmd_whois.cpp
index 37283784b..75e469f92 100644
--- a/src/cmd_whois.cpp
+++ b/src/cmd_whois.cpp
@@ -14,52 +14,21 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "message.h"
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_whois.h"
extern ServerConfig* Config;
extern InspIRCd* ServerInstance;
extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+extern ModuleList modules;
+extern FactoryList factory;
extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
void do_whois(userrec* user, userrec* dest,unsigned long signon, unsigned long idle, char* nick)
{
diff --git a/src/cmd_whowas.cpp b/src/cmd_whowas.cpp
index 143877219..bb8866239 100644
--- a/src/cmd_whowas.cpp
+++ b/src/cmd_whowas.cpp
@@ -14,53 +14,14 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
-#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
-#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_whowas.h"
extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
-
extern whowas_users whowas;
void cmd_whowas::Handle (char **parameters, int pcnt, userrec* user)
diff --git a/src/cmd_zline.cpp b/src/cmd_zline.cpp
index 7ffe5cd73..a040787ba 100644
--- a/src/cmd_zline.cpp
+++ b/src/cmd_zline.cpp
@@ -14,37 +14,20 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
#include "users.h"
-#include "ctables.h"
-#include "globals.h"
#include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
#include "commands.h"
#include "xline.h"
-#include "inspstring.h"
#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
-#include "command_parse.h"
#include "cmd_eline.h"
extern ServerConfig* Config;
extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+extern ModuleList modules;
+extern FactoryList factory;
void cmd_zline::Handle (char **parameters, int pcnt, userrec *user)
{
@@ -82,5 +65,3 @@ void cmd_zline::Handle (char **parameters, int pcnt, userrec *user)
}
}
}
-
-
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index e81595ac4..7a26f209b 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -14,11 +14,9 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
#include <unistd.h>
#include <fcntl.h>
#include <sys/errno.h>
@@ -26,15 +24,8 @@ using namespace std;
#include <sys/utsname.h>
#include <time.h>
#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
#include <sstream>
#include <vector>
-#include <deque>
#include <sched.h>
#ifdef THREADED_DNS
#include <pthread.h>
@@ -838,4 +829,3 @@ void CommandParser::SetupCommandTable()
this->CreateCommand(new cmd_server);
this->CreateCommand(new cmd_commands);
}
-
diff --git a/src/commands.cpp b/src/commands.cpp
index e5d58bfba..e4fc939ea 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -14,11 +14,9 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
#include <unistd.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
@@ -26,15 +24,8 @@ using namespace std;
#include <cstdio>
#include <time.h>
#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
#include <sstream>
#include <vector>
-#include <deque>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
@@ -67,8 +58,8 @@ extern ServerConfig* Config;
extern InspIRCd* ServerInstance;
extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+extern ModuleList modules;
+extern FactoryList factory;
extern time_t TIME;
const long duration_m = 60;
diff --git a/src/dnsqueue.cpp b/src/dnsqueue.cpp
index 20118038b..73d80d11d 100644
--- a/src/dnsqueue.cpp
+++ b/src/dnsqueue.cpp
@@ -14,41 +14,23 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
#include <unistd.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
-#include <cstdio>
-#include <time.h>
#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
#include "users.h"
#include "globals.h"
#include "inspstring.h"
#include "dnsqueue.h"
-#include <time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <string.h>
#include "dns.h"
#include "helperfuncs.h"
#include "hashcomp.h"
#include "socketengine.h"
+#include "socket.h"
extern ServerConfig* Config;
extern InspIRCd* ServerInstance;
@@ -288,4 +270,3 @@ void dns_poll(int fdcheck)
if (ServerInstance && ServerInstance->SE)
ServerInstance->SE->DelFd(fdcheck);
}
-
diff --git a/src/dynamic.cpp b/src/dynamic.cpp
index 8e63b7d03..d9ace43e0 100644
--- a/src/dynamic.cpp
+++ b/src/dynamic.cpp
@@ -17,7 +17,7 @@
using namespace std;
#include "inspircd_config.h"
-#include "inspircd_io.h"
+#include "configreader.h"
#include "globals.h"
#include "dynamic.h"
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index c467172d8..3a0f39c6d 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -14,25 +14,16 @@
* ---------------------------------------------------
*/
-using namespace std;
-
+#include <stdarg.h>
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
#include <unistd.h>
#include <fcntl.h>
#include <sys/errno.h>
#include <time.h>
#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
#include <sstream>
-#include <vector>
-#include <deque>
-#include <stdarg.h>
#include "connection.h"
#include "users.h"
#include "ctables.h"
@@ -50,7 +41,7 @@ using namespace std;
#include "typedefs.h"
extern int MODCOUNT;
-extern std::vector<Module*> modules;
+extern ModuleList modules;
extern ServerConfig *Config;
extern InspIRCd* ServerInstance;
extern time_t TIME;
@@ -278,8 +269,6 @@ void WriteServ(int sock, char* text, ...)
{
va_list argsPtr;
char textbuffer[MAXBUF];
- char tb[MAXBUF];
- int bytes;
if ((sock < 0) || (sock > MAX_DESCRIPTORS))
return;
@@ -1603,6 +1592,34 @@ bool AllModulesReportReady(userrec* user)
return true;
}
+/* Make Sure Modules Are Avaliable!
+ * (BugFix By Craig.. See? I do work! :p)
+ * Modified by brain, requires const char*
+ * to work with other API functions
+ */
+
+/* XXX - Needed? */
+bool FileExists (const char* file)
+{
+ FILE *input;
+ if ((input = fopen (file, "r")) == NULL)
+ {
+ return(false);
+ }
+ else
+ {
+ fclose (input);
+ return(true);
+ }
+}
+
+char* CleanFilename(char* name)
+{
+ char* p = name + strlen(name);
+ while ((p != name) && (*p != '/')) p--;
+ return (p != name ? ++p : p);
+}
+
bool DirValid(char* dirandfile)
{
char work[MAXBUF];
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index bdb1812c3..fd164000a 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -16,11 +16,9 @@
/* Now with added unF! ;) */
-using namespace std;
-
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
#include <fcntl.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
@@ -29,13 +27,9 @@ using namespace std;
#include <exception>
#include <stdexcept>
#include <new>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
#include <map>
#include <sstream>
+#include <fstream>
#include <vector>
#include <deque>
#ifdef THREADED_DNS
@@ -132,6 +126,96 @@ bool FindServerName(std::string servername)
return false;
}
+void Exit(int status)
+{
+ if (Config->log_file)
+ fclose(Config->log_file);
+ send_error("Server shutdown.");
+ exit (status);
+}
+
+void Start()
+{
+ printf("\033[1;32mInspire Internet Relay Chat Server, compiled %s at %s\n",__DATE__,__TIME__);
+ printf("(C) ChatSpike Development team.\033[0m\n\n");
+ printf("Developers:\t\t\033[1;32mBrain, FrostyCoolSlug, w00t, Om\033[0m\n");
+ printf("Others:\t\t\t\033[1;32mSee /INFO Output\033[0m\n");
+ printf("Name concept:\t\t\033[1;32mLord_Zathras\033[0m\n\n");
+}
+
+void Killed(int status)
+{
+ if (Config->log_file)
+ fclose(Config->log_file);
+ send_error("Server terminated.");
+ exit(status);
+}
+
+void Rehash(int status)
+{
+ WriteOpers("Rehashing config file %s due to SIGHUP",CleanFilename(CONFIG_FILE));
+ fclose(Config->log_file);
+ OpenLog(NULL,0);
+ Config->Read(false,NULL);
+ FOREACH_MOD(I_OnRehash,OnRehash(""));
+}
+
+void SetSignals()
+{
+ signal (SIGALRM, SIG_IGN);
+ signal (SIGHUP, Rehash);
+ signal (SIGPIPE, SIG_IGN);
+ signal (SIGTERM, Exit);
+ signal (SIGSEGV, Error);
+}
+
+bool DaemonSeed()
+{
+ int childpid;
+ if ((childpid = fork ()) < 0)
+ return (ERROR);
+ else if (childpid > 0)
+ {
+ /* We wait a few seconds here, so that the shell prompt doesnt come back over the output */
+ sleep(6);
+ exit (0);
+ }
+ setsid ();
+ umask (007);
+ printf("InspIRCd Process ID: \033[1;32m%lu\033[0m\n",(unsigned long)getpid());
+
+ rlimit rl;
+ if (getrlimit(RLIMIT_CORE, &rl) == -1)
+ {
+ log(DEFAULT,"Failed to getrlimit()!");
+ return false;
+ }
+ else
+ {
+ rl.rlim_cur = rl.rlim_max;
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ log(DEFAULT,"setrlimit() failed, cannot increase coredump size.");
+ }
+
+ return true;
+}
+
+void WritePID(const std::string &filename)
+{
+ std::ofstream outfile(filename.c_str());
+ if (outfile.is_open())
+ {
+ outfile << getpid();
+ outfile.close();
+ }
+ else
+ {
+ printf("Failed to write PID-file '%s', exiting.\n",filename.c_str());
+ log(DEFAULT,"Failed to write PID-file '%s', exiting.",filename.c_str());
+ Exit(0);
+ }
+}
+
std::string InspIRCd::GetRevision()
{
return REVISION;
diff --git a/src/message.cpp b/src/message.cpp
index 1cc97743b..28a11fda9 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -18,7 +18,7 @@ using namespace std;
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
#include <unistd.h>
#include <fcntl.h>
#include <sys/errno.h>
diff --git a/src/mode.cpp b/src/mode.cpp
index cdf73350f..b6905df9e 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -18,7 +18,7 @@ using namespace std;
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
#include <unistd.h>
#include <sys/errno.h>
#include <time.h>
diff --git a/src/modules.cpp b/src/modules.cpp
index 2a7b2696f..223b1fe30 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -14,20 +14,13 @@
* ---------------------------------------------------
*/
-using namespace std;
-
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
#include <unistd.h>
#include <sys/errno.h>
#include <time.h>
#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
#include <map>
#include <sstream>
#include <vector>
@@ -54,17 +47,18 @@ using namespace std;
extern ServerConfig *Config;
extern InspIRCd* ServerInstance;
extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
+extern ModuleList modules;
+extern FactoryList factory;
extern std::vector<InspSocket*> module_sockets;
extern std::vector<userrec*> local_users;
extern time_t TIME;
-class Server;
extern userrec* fd_ref_table[MAX_DESCRIPTORS];
-
extern user_hash clientlist;
extern chan_hash chanlist;
extern command_table cmdlist;
+
+class Server;
+
ExtModeList EMode;
// returns true if an extended mode character is in use
diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp
index a5b79dc54..64f9f497f 100644
--- a/src/modules/extra/m_sqloper.cpp
+++ b/src/modules/extra/m_sqloper.cpp
@@ -32,6 +32,7 @@ using namespace std;
#include "channels.h"
#include "modules.h"
#include "inspircd.h"
+#include "configreader.h"
#include "helperfuncs.h"
#include "m_sql.h"
#include "cmd_oper.h"
@@ -244,4 +245,3 @@ extern "C" void * init_module( void )
{
return new ModuleSQLOperFactory;
}
-
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 33f15e376..52209d44c 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -4,6 +4,7 @@
#include <gnutls/gnutls.h>
#include "inspircd_config.h"
+#include "configreader.h"
#include "users.h"
#include "channels.h"
#include "modules.h"
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 27e6e3f02..1e20b1ccf 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -5,6 +5,7 @@
#include <openssl/err.h>
#include "inspircd_config.h"
+#include "configreader.h"
#include "users.h"
#include "channels.h"
#include "modules.h"
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 0005f0683..3394044a3 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -23,11 +23,8 @@ using namespace std;
#include <deque>
#include "globals.h"
#include "inspircd_config.h"
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
+#include "hash_map.h"
+#include "configreader.h"
#include "users.h"
#include "channels.h"
#include "modules.h"
diff --git a/src/modules/m_spanningtree_ng.cpp b/src/modules/m_spanningtree_ng.cpp
index 0005f0683..3394044a3 100644
--- a/src/modules/m_spanningtree_ng.cpp
+++ b/src/modules/m_spanningtree_ng.cpp
@@ -23,11 +23,8 @@ using namespace std;
#include <deque>
#include "globals.h"
#include "inspircd_config.h"
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
+#include "hash_map.h"
+#include "configreader.h"
#include "users.h"
#include "channels.h"
#include "modules.h"
diff --git a/src/socket.cpp b/src/socket.cpp
index 1b657e568..f9b605d3b 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -14,410 +14,236 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
#include <string>
-#include <unistd.h>
-#include <fcntl.h>
-#include <poll.h>
-#include <sstream>
-#include <iostream>
-#include <fstream>
-#include <stdexcept>
+#include "configreader.h"
#include "socket.h"
#include "inspircd.h"
-#include "inspircd_io.h"
#include "inspstring.h"
#include "helperfuncs.h"
#include "socketengine.h"
-
+#include "message.h"
extern InspIRCd* ServerInstance;
extern ServerConfig* Config;
extern time_t TIME;
+extern int openSockfd[MAX_DESCRIPTORS];
InspSocket* socket_ref[MAX_DESCRIPTORS];
-InspSocket::InspSocket()
+/** This will bind a socket to a port. It works for UDP/TCP.
+ * If a hostname is given to bind to, the function will first
+ * attempt to resolve the hostname, then bind to the IP the
+ * hostname resolves to. This is a blocking lookup blocking for
+ * a maximum of one second before it times out, using the DNS
+ * server specified in the configuration file.
+ */
+bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port, char* addr)
{
- this->state = I_DISCONNECTED;
- this->fd = -1;
- this->ClosePending = false;
-}
+ memset(&server,0,sizeof(server));
+ insp_inaddr addy;
+ bool resolved = false;
+ char resolved_addr[128];
-InspSocket::InspSocket(int newfd, char* ip)
-{
- this->fd = newfd;
- this->state = I_CONNECTED;
- strlcpy(this->IP,ip,MAXBUF);
- this->ClosePending = false;
- ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE);
- socket_ref[this->fd] = this;
-}
+ if (*addr == '*')
+ *addr = 0;
-InspSocket::InspSocket(const std::string &ahost, int aport, bool listening, unsigned long maxtime) : fd(-1)
-{
- strlcpy(host,ahost.c_str(),MAXBUF);
- this->ClosePending = false;
- if (listening) {
- if ((this->fd = OpenTCPSocket()) == ERROR)
- {
- this->fd = -1;
- this->state = I_ERROR;
- this->OnError(I_ERR_SOCKET);
- this->ClosePending = true;
- log(DEBUG,"OpenTCPSocket() error");
- return;
- }
- else
- {
- if (!BindSocket(this->fd,this->client,this->server,aport,(char*)ahost.c_str()))
- {
- this->Close();
- this->fd = -1;
- this->state = I_ERROR;
- this->OnError(I_ERR_BIND);
- this->ClosePending = true;
- log(DEBUG,"BindSocket() error %s",strerror(errno));
- return;
- }
- else
- {
- this->state = I_LISTENING;
- ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE);
- socket_ref[this->fd] = this;
- log(DEBUG,"New socket now in I_LISTENING state");
- return;
- }
- }
- }
- else
+ if (*addr && !inet_aton(addr,&addy))
{
- strlcpy(this->host,ahost.c_str(),MAXBUF);
- this->port = aport;
-
- if (!inet_aton(host,&addy))
+ /* If they gave a hostname, bind to the IP it resolves to */
+ if (CleanAndResolve(resolved_addr, addr, true))
{
- log(DEBUG,"Attempting to resolve %s",this->host);
- /* Its not an ip, spawn the resolver */
- this->dns.SetNS(std::string(Config->DNSServer));
- this->dns.ForwardLookupWithFD(host,fd);
- timeout_end = time(NULL) + maxtime;
- timeout = false;
- this->state = I_RESOLVING;
- socket_ref[this->fd] = this;
+ inet_aton(resolved_addr,&addy);
+ log(DEFAULT,"Resolved binding '%s' -> '%s'",addr,resolved_addr);
+ server.sin_addr = addy;
+ resolved = true;
}
else
{
- log(DEBUG,"No need to resolve %s",this->host);
- strlcpy(this->IP,host,MAXBUF);
- timeout_end = time(NULL) + maxtime;
- this->DoConnect();
+ log(DEFAULT,"WARNING: Could not resolve '%s' to an IP for binding to on port %d",addr,port);
+ return false;
}
}
-}
-
-void InspSocket::SetQueues(int nfd)
-{
- // attempt to increase socket sendq and recvq as high as its possible
- int sendbuf = 32768;
- int recvbuf = 32768;
- setsockopt(nfd,SOL_SOCKET,SO_SNDBUF,(const void *)&sendbuf,sizeof(sendbuf));
- setsockopt(nfd,SOL_SOCKET,SO_RCVBUF,(const void *)&recvbuf,sizeof(sendbuf));
-}
-
-bool InspSocket::DoResolve()
-{
- log(DEBUG,"In DoResolve(), trying to resolve IP");
- if (this->dns.HasResult())
+ server.sin_family = AF_INET;
+ if (!resolved)
{
- log(DEBUG,"Socket has result");
- std::string res_ip = dns.GetResultIP();
- if (res_ip != "")
+ if (!*addr)
{
- log(DEBUG,"Socket result set to %s",res_ip.c_str());
- strlcpy(this->IP,res_ip.c_str(),MAXBUF);
- socket_ref[this->fd] = NULL;
+ server.sin_addr.s_addr = htonl(INADDR_ANY);
}
else
{
- log(DEBUG,"Socket DNS failure");
- this->Close();
- this->state = I_ERROR;
- this->OnError(I_ERR_RESOLVE);
- this->fd = -1;
- this->ClosePending = true;
- return false;
+ server.sin_addr = addy;
}
- return this->DoConnect();
}
- log(DEBUG,"No result for socket yet!");
- return true;
-}
-
-bool InspSocket::DoConnect()
-{
- log(DEBUG,"In DoConnect()");
- if ((this->fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+ server.sin_port = htons(port);
+ if (bind(sockfd,(struct sockaddr*)&server,sizeof(server)) < 0)
{
- log(DEBUG,"Cant socket()");
- this->state = I_ERROR;
- this->OnError(I_ERR_SOCKET);
- this->fd = -1;
return false;
}
-
- log(DEBUG,"Part 2 DoConnect() %s",this->IP);
- inet_aton(this->IP,&addy);
- addr.sin_family = AF_INET;
- addr.sin_addr = addy;
- addr.sin_port = htons(this->port);
-
- int flags;
- flags = fcntl(this->fd, F_GETFL, 0);
- fcntl(this->fd, F_SETFL, flags | O_NONBLOCK);
-
- if (connect(this->fd, (sockaddr*)&this->addr,sizeof(this->addr)) == -1)
+ else
{
- if (errno != EINPROGRESS)
+ log(DEBUG,"Bound port %s:%d",*addr ? addr : "*",port);
+ if (listen(sockfd, Config->MaxConn) == -1)
{
- log(DEBUG,"Error connect() %d: %s",this->fd,strerror(errno));
- this->OnError(I_ERR_CONNECT);
- this->Close();
- this->state = I_ERROR;
- this->fd = -1;
- this->ClosePending = true;
+ log(DEFAULT,"ERROR in listen(): %s",strerror(errno));
return false;
}
+ else
+ {
+ NonBlocking(sockfd);
+ return true;
+ }
}
- this->state = I_CONNECTING;
- ServerInstance->SE->AddFd(this->fd,false,X_ESTAB_MODULE);
- socket_ref[this->fd] = this;
- this->SetQueues(this->fd);
- log(DEBUG,"Returning true from InspSocket::DoConnect");
- return true;
}
-void InspSocket::Close()
+// Open a TCP Socket
+int OpenTCPSocket()
{
- if (this->fd != -1)
+ int sockfd;
+ int on = 1;
+ struct linger linger = { 0 };
+
+ if ((sockfd = socket (AF_INET, SOCK_STREAM, 0)) < 0)
{
- this->OnClose();
- shutdown(this->fd,2);
- close(this->fd);
- socket_ref[this->fd] = NULL;
- this->ClosePending = true;
- this->fd = -1;
+ log(DEFAULT,"Error creating TCP socket: %s",strerror(errno));
+ return (ERROR);
+ }
+ else
+ {
+ setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
+ /* This is BSD compatible, setting l_onoff to 0 is *NOT* http://web.irc.org/mla/ircd-dev/msg02259.html */
+ linger.l_onoff = 1;
+ linger.l_linger = 1;
+ setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &linger,sizeof(linger));
+ return (sockfd);
}
}
-std::string InspSocket::GetIP()
-{
- return this->IP;
-}
-
-char* InspSocket::Read()
+bool HasPort(int port, char* addr)
{
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
- return NULL;
- int n = recv(this->fd,this->ibuf,sizeof(this->ibuf),0);
- if ((n > 0) && (n <= (int)sizeof(this->ibuf)))
+ for (int count = 0; count < ServerInstance->stats->BoundPortCount; count++)
{
- ibuf[n] = 0;
- return ibuf;
- }
- else
- {
- if (errno == EAGAIN)
+ if ((port == Config->ports[count]) && (!strcasecmp(Config->addrs[count],addr)))
{
- return "";
- }
- else
- {
- log(DEBUG,"EOF or error on socket: %s",strerror(errno));
- return NULL;
+ return true;
}
}
+ return false;
}
-void InspSocket::MarkAsClosed()
-{
- log(DEBUG,"Marked as closed");
- this->ClosePending = true;
-}
-
-// There are two possible outcomes to this function.
-// It will either write all of the data, or an undefined amount.
-// If an undefined amount is written the connection has failed
-// and should be aborted.
-int InspSocket::Write(const std::string &data)
+int BindPorts(bool bail)
{
- if (this->ClosePending)
- return false;
+ char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF];
+ insp_sockaddr client, server;
+ int clientportcount = 0;
+ int BoundPortCount = 0;
- /*int result = write(this->fd,data.c_str(),data.length());
- if (result < 1)
- return false;
- return true;*/
-
- /* Try and append the data to the back of the queue, and send it on its way
- */
- outbuffer.push_back(data);
- return (!this->FlushWriteBuffer());
-}
+ if (!bail)
+ {
+ int InitialPortCount = ServerInstance->stats->BoundPortCount;
+ log(DEBUG,"Initial port count: %d",InitialPortCount);
-bool InspSocket::FlushWriteBuffer()
-{
- if (this->ClosePending)
- return true;
+ for (int count = 0; count < Config->ConfValueEnum(Config->config_data, "bind"); count++)
+ {
+ Config->ConfValue(Config->config_data, "bind", "port", count, configToken, MAXBUF);
+ Config->ConfValue(Config->config_data, "bind", "address", count, Addr, MAXBUF);
+ Config->ConfValue(Config->config_data, "bind", "type", count, Type, MAXBUF);
- if ((this->fd > -1) && (this->state == I_CONNECTED))
- {
- if (outbuffer.size())
+ if (((!*Type) || (!strcmp(Type,"clients"))) && (!HasPort(atoi(configToken),Addr)))
+ {
+ // modules handle server bind types now
+ Config->ports[clientportcount+InitialPortCount] = atoi(configToken);
+ if (*Addr == '*')
+ *Addr = 0;
+
+ strlcpy(Config->addrs[clientportcount+InitialPortCount],Addr,256);
+ clientportcount++;
+ log(DEBUG,"NEW binding %s:%s [%s] from config",Addr,configToken, Type);
+ }
+ }
+ int PortCount = clientportcount;
+ if (PortCount)
{
- int result = write(this->fd,outbuffer[0].c_str(),outbuffer[0].length());
- if (result > 0)
+ for (int count = InitialPortCount; count < InitialPortCount + PortCount; count++)
{
- if ((unsigned int)result == outbuffer[0].length())
+ if ((openSockfd[count] = OpenTCPSocket()) == ERROR)
{
- /* The whole block was written (usually a line)
- * Pop the block off the front of the queue
- */
- outbuffer.pop_front();
+ log(DEBUG,"Bad fd %d binding port [%s:%d]",openSockfd[count],Config->addrs[count],Config->ports[count]);
+ return ERROR;
+ }
+ if (!BindSocket(openSockfd[count],client,server,Config->ports[count],Config->addrs[count]))
+ {
+ log(DEFAULT,"Failed to bind port [%s:%d]: %s",Config->addrs[count],Config->ports[count],strerror(errno));
}
else
{
- std::string temp = outbuffer[0].substr(result);
- outbuffer[0] = temp;
+ /* Associate the new open port with a slot in the socket engine */
+ ServerInstance->SE->AddFd(openSockfd[count],true,X_LISTEN);
+ BoundPortCount++;
}
}
- else if ((result == -1) && (errno != EAGAIN))
- {
- log(DEBUG,"Write error on socket: %s",strerror(errno));
- this->OnError(I_ERR_WRITE);
- this->state = I_ERROR;
- this->ClosePending = true;
- return true;
- }
+ return InitialPortCount + BoundPortCount;
}
+ else
+ {
+ log(DEBUG,"There is nothing new to bind!");
+ }
+ return InitialPortCount;
}
- return (fd < 0);
-}
-bool InspSocket::Timeout(time_t current)
-{
- if (!socket_ref[this->fd] || !ServerInstance->SE->HasFd(this->fd))
+ for (int count = 0; count < Config->ConfValueEnum(Config->config_data, "bind"); count++)
{
- log(DEBUG,"No FD or socket ref");
- return false;
- }
+ Config->ConfValue(Config->config_data, "bind", "port", count, configToken, MAXBUF);
+ Config->ConfValue(Config->config_data, "bind", "address", count, Addr, MAXBUF);
+ Config->ConfValue(Config->config_data, "bind", "type", count, Type, MAXBUF);
- if (this->ClosePending)
- {
- log(DEBUG,"Close is pending");
- return true;
+ if ((!*Type) || (!strcmp(Type,"clients")))
+ {
+ // modules handle server bind types now
+ Config->ports[clientportcount] = atoi(configToken);
+
+ // If the client put bind "*", this is an unrealism.
+ // We don't actually support this as documented, but
+ // i got fed up of people trying it, so now it converts
+ // it to an empty string meaning the same 'bind to all'.
+ if (*Addr == '*')
+ *Addr = 0;
+
+ strlcpy(Config->addrs[clientportcount],Addr,256);
+ clientportcount++;
+ log(DEBUG,"Binding %s:%s [%s] from config",Addr,configToken, Type);
+ }
}
- if (((this->state == I_RESOLVING) || (this->state == I_CONNECTING)) && (current > timeout_end))
- {
- log(DEBUG,"Timed out, current=%lu timeout_end=%lu");
- // for non-listening sockets, the timeout can occur
- // which causes termination of the connection after
- // the given number of seconds without a successful
- // connection.
- this->OnTimeout();
- this->OnError(I_ERR_TIMEOUT);
- timeout = true;
- this->state = I_ERROR;
- this->ClosePending = true;
- return true;
- }
- return this->FlushWriteBuffer();
-}
+ int PortCount = clientportcount;
-bool InspSocket::Poll()
-{
- if (!socket_ref[this->fd] || !ServerInstance->SE->HasFd(this->fd))
- return false;
-
- int incoming = -1;
- bool n = true;
+ for (int count = 0; count < PortCount; count++)
+ {
+ if ((openSockfd[BoundPortCount] = OpenTCPSocket()) == ERROR)
+ {
+ log(DEBUG,"Bad fd %d binding port [%s:%d]",openSockfd[BoundPortCount],Config->addrs[count],Config->ports[count]);
+ return ERROR;
+ }
- if ((fd < 0) || (fd > MAX_DESCRIPTORS) || (this->ClosePending))
- return false;
+ if (!BindSocket(openSockfd[BoundPortCount],client,server,Config->ports[count],Config->addrs[count]))
+ {
+ log(DEFAULT,"Failed to bind port [%s:%d]: %s",Config->addrs[count],Config->ports[count],strerror(errno));
+ }
+ else
+ {
+ /* well we at least bound to one socket so we'll continue */
+ BoundPortCount++;
+ }
+ }
- switch (this->state)
+ /* if we didn't bind to anything then abort */
+ if (!BoundPortCount)
{
- case I_RESOLVING:
- log(DEBUG,"State = I_RESOLVING, calling DoResolve()");
- return this->DoResolve();
- break;
- case I_CONNECTING:
- log(DEBUG,"State = I_CONNECTING");
- this->SetState(I_CONNECTED);
- /* Our socket was in write-state, so delete it and re-add it
- * in read-state.
- */
- ServerInstance->SE->DelFd(this->fd);
- ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE);
- return this->OnConnected();
- break;
- case I_LISTENING:
- length = sizeof (client);
- incoming = accept (this->fd, (sockaddr*)&client,&length);
- this->SetQueues(incoming);
- this->OnIncomingConnection(incoming,inet_ntoa(client.sin_addr));
- return true;
- break;
- case I_CONNECTED:
- n = this->OnDataReady();
- /* Flush any pending, but not till after theyre done with the event
- * so there are less write calls involved.
- * Both FlushWriteBuffer AND the return result of OnDataReady must
- * return true for this to be ok.
- */
- if (this->FlushWriteBuffer())
- return false;
- return n;
- break;
- default:
- break;
+ log(DEFAULT,"No ports bound, bailing!");
+ printf("\nERROR: Could not bind any of %d ports! Please check your configuration.\n\n", PortCount);
+ return ERROR;
}
- return true;
-}
-void InspSocket::SetState(InspSocketState s)
-{
- log(DEBUG,"Socket state change");
- this->state = s;
-}
-
-InspSocketState InspSocket::GetState()
-{
- return this->state;
-}
-
-int InspSocket::GetFd()
-{
- return this->fd;
-}
-
-bool InspSocket::OnConnected() { return true; }
-void InspSocket::OnError(InspSocketError e) { return; }
-int InspSocket::OnDisconnect() { return 0; }
-int InspSocket::OnIncomingConnection(int newfd, char* ip) { return 0; }
-bool InspSocket::OnDataReady() { return true; }
-void InspSocket::OnTimeout() { return; }
-void InspSocket::OnClose() { return; }
-
-InspSocket::~InspSocket()
-{
- this->Close();
+ return BoundPortCount;
}
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index 956ddb61b..2adccc36e 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -20,7 +20,7 @@ using namespace std;
#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
#include <unistd.h>
#include <fcntl.h>
#include <sys/errno.h>
@@ -417,4 +417,3 @@ void DoBackgroundUserStuff(time_t TIME)
/* Remove all the queued users who are due to be quit, free memory used. */
GlobalGoners.Apply();
}
-
diff --git a/src/users.cpp b/src/users.cpp
index d6ee1d3bd..d4919af06 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -14,9 +14,8 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include "inspircd_config.h"
+#include "inspircd_config.h"
+#include "configreader.h"
#include "channels.h"
#include "connection.h"
#include "users.h"