summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd.h6
-rw-r--r--include/inspircd_io.h9
-rw-r--r--src/channels.cpp32
-rw-r--r--src/commands.cpp34
-rw-r--r--src/dns.cpp1
-rw-r--r--src/dnsqueue.cpp5
-rw-r--r--src/helperfuncs.cpp11
-rw-r--r--src/inspircd_io.cpp4
-rw-r--r--src/mode.cpp20
-rw-r--r--src/modules.cpp32
-rw-r--r--src/socket.cpp3
-rw-r--r--src/userprocess.cpp68
-rw-r--r--src/users.cpp4
-rw-r--r--src/xline.cpp47
14 files changed, 41 insertions, 235 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 3418d6ede..dc440708e 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -14,6 +14,9 @@
* ---------------------------------------------------
*/
+#ifndef __INSPIRCD_H__
+#define __INSPIRCD_H__
+
#include "inspircd_config.h"
#include <string>
#include <stdio.h>
@@ -75,6 +78,7 @@ typedef std::deque<std::string> file_cache;
class serverstats
{
+ public:
int statsAccept;
int statsRefused;
int statsUnknown;
@@ -156,3 +160,5 @@ void* dns_task(void* arg);
void process_buffer(const char* cmdbuf,userrec *user);
void FullConnectUser(userrec* user);
chanrec* ForceChan(chanrec* Ptr,ucrec &a,userrec* user, int created);
+
+#endif
diff --git a/include/inspircd_io.h b/include/inspircd_io.h
index 16ed158ea..36b00e935 100644
--- a/include/inspircd_io.h
+++ b/include/inspircd_io.h
@@ -14,11 +14,16 @@
* ---------------------------------------------------
*/
+#ifndef __INSPIRCD_IO_H__
+#define __INSPIRCD_IO_H__
+
#include <sstream>
#include <string>
+#include "inspircd.h"
class ServerConfig
{
+ public:
char ServerName[MAXBUF];
char Network[MAXBUF];
char ServerDesc[MAXBUF];
@@ -75,7 +80,7 @@ class ServerConfig
MaxConn = SOMAXCONN;
MaxWhoResults = 100;
debugging = 0;
- LogLevel = DEFAULT;
+ LogLevel = 0;
DieDelay = 5;
}
};
@@ -95,3 +100,5 @@ 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);
void WritePID(std::string filename);
+
+#endif
diff --git a/src/channels.cpp b/src/channels.cpp
index ce4718410..573289db9 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -53,45 +53,17 @@ using namespace std;
#define nspace std
#endif
+extern ServerConfig* Config;
+
extern int MODCOUNT;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
-
-extern int LogLevel;
-extern char ServerName[MAXBUF];
-extern char Network[MAXBUF];
-extern char ServerDesc[MAXBUF];
-extern char AdminName[MAXBUF];
-extern char AdminEmail[MAXBUF];
-extern char AdminNick[MAXBUF];
-extern char diepass[MAXBUF];
-extern char restartpass[MAXBUF];
-extern char motd[MAXBUF];
-extern char rules[MAXBUF];
-extern char list[MAXBUF];
-extern char PrefixQuit[MAXBUF];
-extern char DieValue[MAXBUF];
-
-extern int debugging;
extern int WHOWAS_STALE;
extern int WHOWAS_MAX;
-extern int DieDelay;
extern time_t startup_time;
-extern int NetBufferSize;
-int MaxWhoResults;
-extern time_t nb_start;
-
extern std::vector<std::string> module_names;
-
extern int boundPortCount;
-extern int portCount;
-
-extern int ports[MAXSOCKS];
-
extern std::stringstream config_f;
-
-extern FILE *log_file;
-
extern time_t TIME;
using namespace std;
diff --git a/src/commands.cpp b/src/commands.cpp
index 5cf042cda..aa1f02aab 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -63,53 +63,21 @@ using namespace std;
#include "socketengine.h"
extern SocketEngine* SE;
+extern ServerConfig* Config;
extern int MODCOUNT;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
-
-extern int LogLevel;
-extern char ServerName[MAXBUF];
-extern char Network[MAXBUF];
-extern char ServerDesc[MAXBUF];
-extern char AdminName[MAXBUF];
-extern char AdminEmail[MAXBUF];
-extern char AdminNick[MAXBUF];
-extern char diepass[MAXBUF];
-extern char restartpass[MAXBUF];
-extern char motd[MAXBUF];
-extern char rules[MAXBUF];
-extern char list[MAXBUF];
-extern char PrefixQuit[MAXBUF];
-extern char DieValue[MAXBUF];
-
-extern int debugging;
extern int WHOWAS_STALE;
extern int WHOWAS_MAX;
-extern int DieDelay;
extern time_t startup_time;
-extern int NetBufferSize;
-extern int MaxWhoResults;
-extern time_t nb_start;
-
-extern bool nofork;
-
extern time_t TIME;
-
extern std::vector<std::string> module_names;
-
-extern char MyExecutable[1024];
extern int boundPortCount;
extern int portCount;
-
extern int ports[MAXSOCKS];
-
extern std::stringstream config_f;
-
-
-extern FILE *log_file;
-
extern ClassVector Classes;
const long duration_m = 60;
diff --git a/src/dns.cpp b/src/dns.cpp
index 3c4701ed6..5a70bb41d 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -40,6 +40,7 @@ using namespace std;
#include "socketengine.h"
extern SocketEngine* SE;
+extern ServerConfig* Config;
serverstats* stats;
#define max(a,b) (a > b ? a : b)
diff --git a/src/dnsqueue.cpp b/src/dnsqueue.cpp
index 78be4d8f1..93d682012 100644
--- a/src/dnsqueue.cpp
+++ b/src/dnsqueue.cpp
@@ -43,7 +43,6 @@ using namespace std;
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
-#include <sys/poll.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <string.h>
@@ -53,9 +52,7 @@ using namespace std;
#include "socketengine.h"
extern SocketEngine* SE;
-typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash;
-extern user_hash clientlist;
-extern char DNSServer[MAXBUF];
+extern ServerConfig* Config;
class Lookup;
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index c6ff76523..97f423d3f 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -51,21 +51,12 @@ using namespace std;
extern int MODCOUNT;
extern std::vector<Module*> modules;
+extern ServerConfig *Config;
extern time_t TIME;
-extern bool nofork;
extern char lowermap[255];
-extern char ServerName[MAXBUF];
-extern char Network[MAXBUF];
-extern char ServerDesc[MAXBUF];
-extern char list[MAXBUF];
-
-extern int debugging;
-extern int LogLevel;
-
extern std::stringstream config_f;
-extern FILE *log_file;
extern userrec* fd_ref_table[65536];
extern serverstats* stats;
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index e601ae496..53a95093a 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -31,12 +31,10 @@ using namespace std;
#include "inspstring.h"
#include "helperfuncs.h"
-extern FILE *log_file;
+extern ServerConfig *Config;
extern int boundPortCount;
extern int openSockfd[MAXSOCKS];
extern time_t TIME;
-extern bool unlimitcore;
-extern int MaxConn;
std::vector<std::string> include_stack;
void WriteOpers(char* text, ...);
diff --git a/src/mode.cpp b/src/mode.cpp
index 82e38e355..d63ffcfb1 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -51,25 +51,7 @@ extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
extern std::vector<std::string> module_names;
-
-extern int LogLevel;
-extern char ServerName[MAXBUF];
-extern char Network[MAXBUF];
-extern char ServerDesc[MAXBUF];
-extern char AdminName[MAXBUF];
-extern char AdminEmail[MAXBUF];
-extern char AdminNick[MAXBUF];
-extern char diepass[MAXBUF];
-extern char restartpass[MAXBUF];
-extern char motd[MAXBUF];
-extern char rules[MAXBUF];
-extern char list[MAXBUF];
-extern char PrefixQuit[MAXBUF];
-extern char DieValue[MAXBUF];
-
-extern bool AllowHalfop;
-extern bool AllowProtect;
-extern bool AllowFounder;
+extern ServerConfig* Config;
extern time_t TIME;
diff --git a/src/modules.cpp b/src/modules.cpp
index ebd127556..5799289ef 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -50,55 +50,25 @@ using namespace std;
#include "socketengine.h"
extern SocketEngine* SE;
+extern ServerConfig *Config;
extern int MODCOUNT;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
-
extern std::vector<std::string> include_stack;
-
extern std::vector<InspSocket*> module_sockets;
extern time_t TIME;
-
-extern int LogLevel;
-extern char ServerName[MAXBUF];
-extern char Network[MAXBUF];
-extern char ServerDesc[MAXBUF];
-extern char AdminName[MAXBUF];
-extern char AdminEmail[MAXBUF];
-extern char AdminNick[MAXBUF];
-extern char diepass[MAXBUF];
-extern char restartpass[MAXBUF];
-extern char motd[MAXBUF];
-extern char rules[MAXBUF];
-extern char list[MAXBUF];
-extern char PrefixQuit[MAXBUF];
-extern char DieValue[MAXBUF];
-
-extern int debugging;
extern int WHOWAS_STALE;
extern int WHOWAS_MAX;
-extern int DieDelay;
extern time_t startup_time;
-extern int NetBufferSize;
-extern int MaxWhoResults;
-extern time_t nb_start;
-
extern std::vector<std::string> module_names;
-
extern int boundPortCount;
extern int portCount;
-
extern int ports[MAXSOCKS];
class Server;
extern std::stringstream config_f;
-
-
-
-extern FILE *log_file;
-
extern userrec* fd_ref_table[65536];
typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash;
diff --git a/src/socket.cpp b/src/socket.cpp
index 8da570fe4..420c29f6f 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -39,12 +39,9 @@ using namespace std;
extern SocketEngine* SE;
-extern FILE *log_file;
extern int boundPortCount;
extern int openSockfd[MAXSOCKS];
extern time_t TIME;
-extern bool unlimitcore;
-extern int MaxConn;
InspSocket* socket_ref[65535];
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index 3151e7f34..2e3c8713d 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -60,60 +60,22 @@ using namespace std;
extern int MODCOUNT;
extern int openSockfd[MAXSOCKS];
-extern bool nofork;
-extern bool unlimitcore;
extern struct sockaddr_in client,server;
-extern char addrs[MAXBUF][255];
extern socklen_t length;
-extern char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF];
-
-extern char DisabledCommands[MAXBUF];
-
-extern bool AllowHalfop;
-extern bool AllowProtect;
-extern bool AllowFounder;
-
extern std::vector<Module*> modules;
extern std::vector<std::string> module_names;
extern std::vector<ircd_module*> factory;
-
extern std::vector<InspSocket*> module_sockets;
-
extern SocketEngine* SE;
-
extern time_t TIME;
extern time_t OLDTIME;
-
-extern int DieDelay;
extern time_t startup_time;
-extern int NetBufferSize;
-extern int MaxConn;
-extern unsigned int SoftLimit;
-extern int MaxWhoResults;
-extern time_t nb_start;
-extern int dns_timeout;
extern serverstats* stats;
+extern ServerConfig *Config;
extern userrec* fd_ref_table[65536];
-
-extern int LogLevel;
-extern char ServerName[MAXBUF];
-extern char Network[MAXBUF];
-extern char ServerDesc[MAXBUF];
-extern char AdminName[MAXBUF];
-extern char AdminEmail[MAXBUF];
-extern char AdminNick[MAXBUF];
-extern char diepass[MAXBUF];
-extern char restartpass[MAXBUF];
-extern char motd[MAXBUF];
-extern char rules[MAXBUF];
-extern char list[MAXBUF];
-extern char PrefixQuit[MAXBUF];
-extern char DieValue[MAXBUF];
-extern char DNSServer[MAXBUF];
-extern char data[65536];
-
+char data[65536];
typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash;
typedef nspace::hash_map<std::string, chanrec*, nspace::hash<string>, irc::StrHashComp> chan_hash;
@@ -124,7 +86,6 @@ extern user_hash clientlist;
extern chan_hash chanlist;
extern whowas_hash whowas;
-extern FILE *log_file;
extern std::stringstream config_f;
void ProcessUser(userrec* cu)
@@ -146,7 +107,7 @@ void ProcessUser(userrec* cu)
log(DEBUG,"Read result: %d",result);
if (result)
{
- statsRecv += result;
+ stats->statsRecv += result;
// perform a check on the raw buffer as an array (not a string!) to remove
// characters 0 and 7 which are illegal in the RFC - replace them with spaces.
// hopefully this should stop even more people whining about "Unknown command: *"
@@ -174,12 +135,12 @@ void ProcessUser(userrec* cu)
{
WriteOpers("*** Excess flood from %s",current->ip);
log(DEFAULT,"Excess flood from: %s",current->ip);
- add_zline(120,ServerName,"Flood from unregistered connection",current->ip);
+ add_zline(120,Config->ServerName,"Flood from unregistered connection",current->ip);
apply_lines(APPLY_ZLINES);
}
return;
}
- if (current->recvq.length() > (unsigned)NetBufferSize)
+ if (current->recvq.length() > (unsigned)Config->NetBufferSize)
{
if (current->registered == 7)
{
@@ -189,7 +150,7 @@ void ProcessUser(userrec* cu)
{
WriteOpers("*** Excess flood from %s",current->ip);
log(DEFAULT,"Excess flood from: %s",current->ip);
- add_zline(120,ServerName,"Flood from unregistered connection",current->ip);
+ add_zline(120,Config->ServerName,"Flood from unregistered connection",current->ip);
apply_lines(APPLY_ZLINES);
}
return;
@@ -221,7 +182,7 @@ void ProcessUser(userrec* cu)
}
else
{
- add_zline(120,ServerName,"Flood from unregistered connection",current->ip);
+ add_zline(120,Config->ServerName,"Flood from unregistered connection",current->ip);
apply_lines(APPLY_ZLINES);
}
return;
@@ -347,7 +308,7 @@ bool DoBackgroundUserStuff(time_t TIME)
{
log(DEBUG,"signon exceed, registered=3, and modules ready, OK: %d %d",TIME,curr->signon);
curr->dns_done = true;
- statsDnsBad++;
+ stats->statsDnsBad++;
FullConnectUser(curr);
if (fd_ref_table[currfd] != curr) // something changed, bail pronto
return true;
@@ -367,7 +328,7 @@ bool DoBackgroundUserStuff(time_t TIME)
kill_link(curr,"Ping timeout");
return true;
}
- Write(curr->fd,"PING :%s",ServerName);
+ Write(curr->fd,"PING :%s",Config->ServerName);
log(DEBUG,"InspIRCd: pinging: %s",curr->nick);
curr->lastping = 0;
curr->nping = TIME+curr->pingmax; // was hard coded to 120
@@ -381,8 +342,8 @@ bool DoBackgroundUserStuff(time_t TIME)
void OpenLog(char** argv, int argc)
{
std::string logpath = GetFullProgDir(argv,argc) + "/ircd.log";
- log_file = fopen(logpath.c_str(),"a+");
- if (!log_file)
+ Config->log_file = fopen(logpath.c_str(),"a+");
+ if (!Config->log_file)
{
printf("ERROR: Could not write to logfile %s, bailing!\n\n",logpath.c_str());
Exit(ERROR);
@@ -408,10 +369,10 @@ void CheckRoot()
void CheckDie()
{
- if (DieValue[0])
+ if (*Config->DieValue)
{
- printf("WARNING: %s\n\n",DieValue);
- log(DEFAULT,"Ut-Oh, somebody didn't read their config file: '%s'",DieValue);
+ printf("WARNING: %s\n\n",Config->DieValue);
+ log(DEFAULT,"Ut-Oh, somebody didn't read their config file: '%s'",Config->DieValue);
exit(0);
}
}
@@ -420,6 +381,7 @@ void LoadAllModules()
{
/* We must load the modules AFTER initializing the socket engine, now */
MODCOUNT = -1;
+ char configToken[MAXBUF];
for (int count = 0; count < ConfValueEnum("module",&config_f); count++)
{
ConfValue("module","name",count,configToken,&config_f);
diff --git a/src/users.cpp b/src/users.cpp
index 46bf70744..f1dc57794 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -31,7 +31,7 @@ using namespace std;
#include "helperfuncs.h"
extern std::stringstream config_f;
-extern char ServerName[MAXBUF];
+extern ServerConfig* Config;
extern time_t TIME;
@@ -46,7 +46,7 @@ userrec::userrec()
strcpy(dhost,"");
strcpy(fullname,"");
strcpy(modes,"");
- server = (char*)FindServerNamePtr(ServerName);
+ server = (char*)FindServerNamePtr(Config->ServerName);
strcpy(awaymsg,"");
strcpy(oper,"");
reset_due = TIME;
diff --git a/src/xline.cpp b/src/xline.cpp
index 0815f3c61..0e0ed9257 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -50,55 +50,10 @@ using namespace std;
extern int MODCOUNT;
extern std::vector<Module*> modules;
extern std::vector<ircd_module*> factory;
-
-extern int LogLevel;
-extern char ServerName[MAXBUF];
-extern char Network[MAXBUF];
-extern char ServerDesc[MAXBUF];
-extern char AdminName[MAXBUF];
-extern char AdminEmail[MAXBUF];
-extern char AdminNick[MAXBUF];
-extern char diepass[MAXBUF];
-extern char restartpass[MAXBUF];
-extern char motd[MAXBUF];
-extern char rules[MAXBUF];
-extern char list[MAXBUF];
-extern char PrefixQuit[MAXBUF];
-extern char DieValue[MAXBUF];
-
-extern int debugging;
-extern int WHOWAS_STALE;
-extern int WHOWAS_MAX;
-extern int DieDelay;
-extern time_t startup_time;
-extern int NetBufferSize;
-extern time_t nb_start;
-
-extern std::vector<std::string> module_names;
-
-extern int boundPortCount;
-extern int portCount;
-
-extern int ports[MAXSOCKS];
-
+extern ServerConfig* Config;
extern std::stringstream config_f;
-
-extern FILE *log_file;
-
typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash;
-typedef nspace::hash_map<std::string, chanrec*, nspace::hash<string>, irc::StrHashComp> chan_hash;
-typedef nspace::hash_map<in_addr,string*, nspace::hash<in_addr>, irc::InAddr_HashComp> address_cache;
-typedef nspace::hash_map<std::string, WhoWasUser*, nspace::hash<string>, irc::StrHashComp> whowas_hash;
-typedef std::deque<command_t> command_table;
-
-
extern user_hash clientlist;
-extern chan_hash chanlist;
-extern whowas_hash whowas;
-extern command_table cmdlist;
-extern file_cache MOTD;
-extern file_cache RULES;
-extern address_cache IP;
/* Version two, now with optimized expiry!
*