mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 11:09:04 -04:00
Started moving of data into ServerConfig class
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2393 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
44d3b5b826
commit
d582107b33
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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, ...);
|
||||
|
20
src/mode.cpp
20
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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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!
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user