summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-14 11:19:12 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-14 11:19:12 +0000
commitcc0cd720c6910e63834fdf9d82399637cda37786 (patch)
treea36e1d9dd9c5732f24d881b89e58ddb95359c078
parent5bb7fddb282c4dcc98d4a696c42c99ef12f88d80 (diff)
Moved tons of stuff into class ServerConfig
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2395 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/inspircd_io.h4
-rw-r--r--src/commands.cpp2
-rw-r--r--src/dnsqueue.cpp2
-rw-r--r--src/helperfuncs.cpp42
-rw-r--r--src/inspircd.cpp37
5 files changed, 44 insertions, 43 deletions
diff --git a/include/inspircd_io.h b/include/inspircd_io.h
index 36b00e935..200c4a8c2 100644
--- a/include/inspircd_io.h
+++ b/include/inspircd_io.h
@@ -37,6 +37,7 @@ class ServerConfig
char PrefixQuit[MAXBUF];
char DieValue[MAXBUF];
char DNSServer[MAXBUF];
+ char DisabledCommands[MAXBUF];
char ModPath[1024];
char MyExecutable[1024];
FILE *log_file;
@@ -70,6 +71,7 @@ class ServerConfig
*DNSServer = '\0';
*ModPath = '\0';
*MyExecutable = '\0';
+ *DisabledCommands = '\0';
log_file = NULL;
nofork = false;
unlimitcore = false;
@@ -80,7 +82,7 @@ class ServerConfig
MaxConn = SOMAXCONN;
MaxWhoResults = 100;
debugging = 0;
- LogLevel = 0;
+ LogLevel = 30;
DieDelay = 5;
}
};
diff --git a/src/commands.cpp b/src/commands.cpp
index 2a3ebb72b..25cfab93a 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -1522,7 +1522,7 @@ void handle_squit(char **parameters, int pcnt, userrec *user)
void handle_links(char **parameters, int pcnt, userrec *user)
{
- WriteServ(user->fd,"364 %s %s %s :0 %s",user->nick,Config->ServerName,Config->ServerName,ServerDesc);
+ 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/dnsqueue.cpp b/src/dnsqueue.cpp
index 93d682012..ce309a688 100644
--- a/src/dnsqueue.cpp
+++ b/src/dnsqueue.cpp
@@ -87,7 +87,7 @@ public:
userrec* usr = Find(nick);
if (usr)
{
- resolver1.SetNS(std::string(DNSServer));
+ resolver1.SetNS(std::string(Config->DNSServer));
if (!resolver1.ReverseLookup(std::string(usr->host)))
{
return false;
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 97f423d3f..75d4b1692 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -56,7 +56,7 @@ extern ServerConfig *Config;
extern time_t TIME;
extern char lowermap[255];
extern std::stringstream config_f;
-
+static char list[MAXBUF];
extern userrec* fd_ref_table[65536];
extern serverstats* stats;
@@ -82,13 +82,13 @@ void log(int level,char *text, ...)
va_list argsPtr;
time_t rawtime;
struct tm * timeinfo;
- if (level < LogLevel)
+ if (level < Config->LogLevel)
return;
time(&rawtime);
- timeinfo = localtime (&rawtime);
+ timeinfo = localtime(&rawtime);
- if (log_file)
+ if (Config->log_file)
{
char b[MAXBUF];
va_start (argsPtr, text);
@@ -96,8 +96,9 @@ void log(int level,char *text, ...)
va_end(argsPtr);
strlcpy(b,asctime(timeinfo),MAXBUF);
b[24] = ':'; // we know this is the end of the time string
- fprintf(log_file,"%s %s\n",b,textbuffer);
- if (nofork)
+ if (Config->log_file)
+ fprintf(Config->log_file,"%s %s\n",b,textbuffer);
+ if (Config->nofork)
{
// nofork enabled? display it on terminal too
printf("%s %s\n",b,textbuffer);
@@ -160,7 +161,7 @@ void Write(int sock,char *text, ...)
int MOD_RESULT = 0;
FOREACH_RESULT(OnRawSocketWrite(sock,tb,bytes));
fd_ref_table[sock]->AddWriteBuf(tb);
- statsSent += bytes;
+ stats->statsSent += bytes;
}
else log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
}
@@ -182,14 +183,14 @@ void WriteServ(int sock, char* text, ...)
vsnprintf(textbuffer, MAXBUF, text, argsPtr);
va_end(argsPtr);
- int bytes = snprintf(tb,MAXBUF,":%s %s\r\n",ServerName,textbuffer);
+ int bytes = snprintf(tb,MAXBUF,":%s %s\r\n",Config->ServerName,textbuffer);
chop(tb);
if (fd_ref_table[sock])
{
int MOD_RESULT = 0;
FOREACH_RESULT(OnRawSocketWrite(sock,tb,bytes));
fd_ref_table[sock]->AddWriteBuf(tb);
- statsSent += bytes;
+ stats->statsSent += bytes;
}
else log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
}
@@ -218,7 +219,7 @@ void WriteFrom(int sock, userrec *user,char* text, ...)
int MOD_RESULT = 0;
FOREACH_RESULT(OnRawSocketWrite(sock,tb,bytes));
fd_ref_table[sock]->AddWriteBuf(tb);
- statsSent += bytes;
+ stats->statsSent += bytes;
}
else log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
}
@@ -244,7 +245,7 @@ void WriteTo(userrec *source, userrec *dest,char *data, ...)
// if no source given send it from the server.
if (!source)
{
- WriteServ(dest->fd,":%s %s",ServerName,textbuffer);
+ WriteServ(dest->fd,":%s %s",Config->ServerName,textbuffer);
}
else
{
@@ -374,7 +375,7 @@ std::string GetServerDescription(char* servername)
}
else
{
- return ServerDesc; // not a remote server that can be found, it must be me.
+ return Config->ServerDesc; // not a remote server that can be found, it must be me.
}
}
@@ -520,7 +521,7 @@ void ServerNoticeAll(char* text, ...)
{
if ((i->second) && (i->second->fd != FD_MAGIC_NUMBER))
{
- WriteServ(i->second->fd,"NOTICE $%s :%s",ServerName,textbuffer);
+ WriteServ(i->second->fd,"NOTICE $%s :%s",Config->ServerName,textbuffer);
}
}
}
@@ -540,7 +541,7 @@ void ServerPrivmsgAll(char* text, ...)
{
if ((i->second) && (i->second->fd != FD_MAGIC_NUMBER))
{
- WriteServ(i->second->fd,"PRIVMSG $%s :%s",ServerName,textbuffer);
+ WriteServ(i->second->fd,"PRIVMSG $%s :%s",Config->ServerName,textbuffer);
}
}
}
@@ -962,7 +963,6 @@ int usercount_i(chanrec *c)
return 0;
}
- strcpy(list,"");
for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
{
if (i->second)
@@ -1136,18 +1136,18 @@ void ShowMOTD(userrec *user)
WriteServ(user->fd,"422 %s :Message of the day file is missing.",user->nick);
return;
}
- snprintf(buf,65535,":%s 375 %s :- %s message of the day\r\n", ServerName, user->nick, ServerName);
+ snprintf(buf,65535,":%s 375 %s :- %s message of the day\r\n", Config->ServerName, user->nick, Config->ServerName);
WholeMOTD = WholeMOTD + buf;
for (unsigned int i = 0; i != MOTD.size(); i++)
{
- snprintf(buf,65535,":%s 372 %s :- %s\r\n", ServerName, user->nick, MOTD[i].c_str());
+ snprintf(buf,65535,":%s 372 %s :- %s\r\n", Config->ServerName, user->nick, MOTD[i].c_str());
WholeMOTD = WholeMOTD + buf;
}
- snprintf(buf,65535,":%s 376 %s :End of message of the day.\r\n", ServerName, user->nick);
+ snprintf(buf,65535,":%s 376 %s :End of message of the day.\r\n", Config->ServerName, user->nick);
WholeMOTD = WholeMOTD + buf;
// only one write operation
user->AddWriteBuf(WholeMOTD);
- statsSent += WholeMOTD.length();
+ stats->statsSent += WholeMOTD.length();
}
void ShowRULES(userrec *user)
@@ -1157,12 +1157,12 @@ void ShowRULES(userrec *user)
WriteServ(user->fd,"NOTICE %s :Rules file is missing.",user->nick);
return;
}
- WriteServ(user->fd,"NOTICE %s :%s rules",user->nick,ServerName);
+ WriteServ(user->fd,"NOTICE %s :%s rules",user->nick,Config->ServerName);
for (unsigned int i = 0; i != RULES.size(); i++)
{
WriteServ(user->fd,"NOTICE %s :%s",user->nick,RULES[i].c_str());
}
- WriteServ(user->fd,"NOTICE %s :End of %s rules.",user->nick,ServerName);
+ WriteServ(user->fd,"NOTICE %s :End of %s rules.",user->nick,Config->ServerName);
}
// this returns 1 when all modules are satisfied that the user should be allowed onto the irc server
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 7ae6390bb..ed2c9de44 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -105,7 +105,6 @@ user_hash clientlist;
chan_hash chanlist;
whowas_hash whowas;
command_table cmdlist;
-autoconnects autoconns;
file_cache MOTD;
file_cache RULES;
address_cache IP;
@@ -289,13 +288,13 @@ void ReadConfig(bool bail, userrec* user)
ConfValue("options","softlimit",0,SLIMT,&config_f);
Config->SoftLimit = atoi(SLIMT);
- if ((SoftLimit < 1) || (SoftLimit > MAXCLIENTS))
+ if ((Config->SoftLimit < 1) || (Config->SoftLimit > MAXCLIENTS))
{
log(DEFAULT,"WARNING: <options:softlimit> value is greater than %d or less than 0, set to %d.",MAXCLIENTS,MAXCLIENTS);
Config->SoftLimit = MAXCLIENTS;
}
Config->MaxConn = atoi(MCON);
- if (MaxConn > SOMAXCONN)
+ if (Config->MaxConn > SOMAXCONN)
log(DEFAULT,"WARNING: <options:somaxconn> value may be higher than the system-defined SOMAXCONN value!");
Config->NetBufferSize = atoi(NB);
Config->MaxWhoResults = atoi(MW);
@@ -1115,18 +1114,18 @@ int main(int argc, char** argv)
for (int i = 1; i < argc; i++)
{
if (!strcmp(argv[i],"-nofork")) {
- nofork = true;
+ Config->nofork = true;
}
if (!strcmp(argv[i],"-wait")) {
sleep(6);
}
if (!strcmp(argv[i],"-nolimit")) {
- unlimitcore = true;
+ Config->unlimitcore = true;
}
}
}
- strlcpy(MyExecutable,argv[0],MAXBUF);
+ strlcpy(Config->MyExecutable,argv[0],MAXBUF);
// initialize the lowercase mapping table
for (unsigned int cn = 0; cn < 256; cn++)
@@ -1329,7 +1328,7 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip)
clientlist[tempnick]->server = (char*)FindServerNamePtr(Config->ServerName);
strlcpy(clientlist[tempnick]->ident, "unknown",IDENTMAX);
clientlist[tempnick]->registered = 0;
- clientlist[tempnick]->signon = TIME+dns_timeout;
+ clientlist[tempnick]->signon = TIME + Config->dns_timeout;
clientlist[tempnick]->lastping = 1;
clientlist[tempnick]->port = port;
strlcpy(clientlist[tempnick]->ip,ip,16);
@@ -1355,7 +1354,7 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip)
}
}
- clientlist[tempnick]->nping = TIME+clientlist[tempnick]->pingmax+dns_timeout;
+ clientlist[tempnick]->nping = TIME+clientlist[tempnick]->pingmax + Config->dns_timeout;
clientlist[tempnick]->timeout = TIME+class_regtimeout;
clientlist[tempnick]->flood = class_flood;
clientlist[tempnick]->threshold = class_threshold;
@@ -1368,7 +1367,7 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip)
for (int i = 0; i < MAXCHANS; i++)
clientlist[tempnick]->chans.push_back(a);
- if (clientlist.size() > SoftLimit)
+ if (clientlist.size() > Config->SoftLimit)
{
kill_link(clientlist[tempnick],"No more connections allowed");
return;
@@ -1452,8 +1451,8 @@ void FullConnectUser(userrec* user)
}
- WriteServ(user->fd,"NOTICE Auth :Welcome to \002%s\002!",Network);
- WriteServ(user->fd,"001 %s :Welcome to the %s IRC Network %s!%s@%s",user->nick,Network,user->nick,user->ident,user->host);
+ WriteServ(user->fd,"NOTICE Auth :Welcome to \002%s\002!",Config->Network);
+ WriteServ(user->fd,"001 %s :Welcome to the %s IRC Network %s!%s@%s",user->nick,Config->Network,user->nick,user->ident,user->host);
WriteServ(user->fd,"002 %s :Your host is %s, running version %s",user->nick,Config->ServerName,VERSION);
WriteServ(user->fd,"003 %s :This server was created %s %s",user->nick,__TIME__,__DATE__);
WriteServ(user->fd,"004 %s %s %s iowghraAsORVSxNCWqBzvdHtGI lvhopsmntikrRcaqOALQbSeKVfHGCuzN",user->nick,Config->ServerName,VERSION);
@@ -1462,7 +1461,7 @@ void FullConnectUser(userrec* user)
v << "WALLCHOPS MODES=13 CHANTYPES=# PREFIX=(ohv)@%+ MAP SAFELIST MAXCHANNELS=" << MAXCHANS;
v << " MAXBANS=60 NICKLEN=" << NICKMAX;
v << " TOPICLEN=" << MAXTOPIC << " KICKLEN=" << MAXKICK << " MAXTARGETS=20 AWAYLEN=" << MAXAWAY << " CHANMODES=ohvb,k,l,psmnti NETWORK=";
- v << Network;
+ v << Config->Network;
std::string data005 = v.str();
FOREACH_MOD On005Numeric(data005);
// anfl @ #ratbox, efnet reminded me that according to the RFC this cant contain more than 13 tokens per line...
@@ -1512,7 +1511,7 @@ std::string GetVersionString()
#else
char dnsengine[] = "singlethread";
#endif
- snprintf(versiondata,MAXBUF,"%s Rev. %s %s :%s [FLAGS=%lu,%s,%s]",VERSION,GetRevision.c_str(),Config->ServerName,SYSTEM,(unsigned long)OPTIMISATION,SE->GetName().c_str(),dnsengine);
+ snprintf(versiondata,MAXBUF,"%s Rev. %s %s :%s [FLAGS=%lu,%s,%s]",VERSION,GetRevision().c_str(),Config->ServerName,SYSTEM,(unsigned long)OPTIMISATION,SE->GetName().c_str(),dnsengine);
return versiondata;
}
@@ -1878,7 +1877,7 @@ void process_command(userrec *user, char* cmd)
}
if ((user->registered == 7) && (!strchr(user->modes,'o')))
{
- std::stringstream dcmds(DisabledCommands);
+ std::stringstream dcmds(Config->DisabledCommands);
while (!dcmds.eof())
{
std::string thiscmd;
@@ -2103,7 +2102,7 @@ bool LoadModule(const char* filename)
#ifdef STATIC_LINK
snprintf(modfile,MAXBUF,"%s",filename);
#else
- snprintf(modfile,MAXBUF,"%s/%s",ModPath,filename);
+ snprintf(modfile,MAXBUF,"%s/%s",Config->ModPath,filename);
#endif
std::string filename_str = filename;
#ifndef STATIC_LINK
@@ -2167,7 +2166,7 @@ bool LoadModule(const char* filename)
int BindPorts()
{
- char configToken[MAXBUF];
+ char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF];
int clientportcount = 0;
for (int count = 0; count < ConfValueEnum("bind",&config_f); count++)
{
@@ -2179,7 +2178,7 @@ int BindPorts()
// modules handle server bind types now,
// its not a typo in the strcmp.
ports[clientportcount] = atoi(configToken);
- strlcpy(addrs[clientportcount],Addr,256);
+ strlcpy(Config->addrs[clientportcount],Addr,256);
clientportcount++;
log(DEBUG,"InspIRCd: startup: read binding %s:%s [%s] from config",Addr,configToken, Type);
}
@@ -2193,7 +2192,7 @@ int BindPorts()
log(DEBUG,"InspIRCd: startup: bad fd %lu",(unsigned long)openSockfd[boundPortCount]);
return(ERROR);
}
- if (BindSocket(openSockfd[boundPortCount],client,server,ports[count],addrs[count]) == ERROR)
+ if (BindSocket(openSockfd[boundPortCount],client,server,ports[count],Config->addrs[count]) == ERROR)
{
log(DEFAULT,"InspIRCd: startup: failed to bind port %lu",(unsigned long)ports[count]);
}
@@ -2247,7 +2246,7 @@ int InspIRCd(char** argv, int argc)
// write once here, to try it out and make sure its ok
WritePID(PID);
- if (!nofork)
+ if (!Config->nofork)
{
if (DaemonSeed() == ERROR)
{