X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspircd_io.cpp;h=aee8abe88d2ecc57c1814a71091a4f1aa50dadbd;hb=59b1a8955142935b02af6446005ab47fc7c3fc8c;hp=d452a3dbebdbbbb3e0548cb5f4bedb9c9faa71c5;hpb=0291b2f2edad6d62f4e0c08a804a2276959e6e7b;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp index d452a3dbe..aee8abe88 100644 --- a/src/inspircd_io.cpp +++ b/src/inspircd_io.cpp @@ -82,7 +82,12 @@ bool ServerConfig::AddIOHook(int port, Module* iomod) IOHookModule[port] = iomod; return true; } - return false; + else + { + ModuleException err("Port already hooked by another module"); + throw(err); + return false; + } } bool ServerConfig::DelIOHook(int port) @@ -197,8 +202,7 @@ void ServerConfig::Read(bool bail, userrec* user) /* Check we dont have more than one of singular tags */ if (!CheckOnce("server",bail,user) || !CheckOnce("admin",bail,user) || !CheckOnce("files",bail,user) - || !CheckOnce("power",bail,user) || !CheckOnce("options",bail,user) - || !CheckOnce("dns",bail,user) || !CheckOnce("pid",bail,user)) + || !CheckOnce("power",bail,user) || !CheckOnce("options",bail,user) || !CheckOnce("pid",bail,user)) { return; } @@ -257,12 +261,46 @@ void ServerConfig::Read(bool bail, userrec* user) Config->NetBufferSize = atoi(NB); Config->MaxWhoResults = atoi(MW); Config->dns_timeout = atoi(DNT); + if (!strchr(Config->ServerName,'.')) + { + log(DEFAULT,"WARNING: '%s' is not a fully-qualified domain name. Changed to '%s%c'",Config->ServerName,Config->ServerName,'.'); + strlcat(Config->ServerName,".",MAXBUF); + } if (!Config->dns_timeout) Config->dns_timeout = 5; if (!Config->MaxConn) Config->MaxConn = SOMAXCONN; if (!*Config->DNSServer) - strlcpy(Config->DNSServer,"127.0.0.1",MAXBUF); + { + // attempt to look up their nameserver from /etc/resolv.conf + log(DEFAULT,"WARNING: not defined, attempting to find working server in /etc/resolv.conf..."); + ifstream resolv("/etc/resolv.conf"); + std::string nameserver; + bool found_server = false; + if (resolv.is_open()) + { + while (resolv >> nameserver) + { + if ((nameserver == "nameserver") && (!found_server)) + { + resolv >> nameserver; + strlcpy(Config->DNSServer,nameserver.c_str(),MAXBUF); + found_server = true; + log(DEFAULT," set to '%s' as first resolver in /etc/resolv.conf.",nameserver.c_str()); + } + } + if (!found_server) + { + log(DEFAULT,"/etc/resolv.conf contains no viable nameserver entries! Defaulting to nameserver '127.0.0.1'!"); + strlcpy(Config->DNSServer,"127.0.0.1",MAXBUF); + } + } + else + { + log(DEFAULT,"/etc/resolv.conf can't be opened! Defaulting to nameserver '127.0.0.1'!"); + strlcpy(Config->DNSServer,"127.0.0.1",MAXBUF); + } + } if (!*Config->ModPath) strlcpy(Config->ModPath,MOD_PATH,MAXBUF); Config->AllowHalfop = ((!strcasecmp(AH,"true")) || (!strcasecmp(AH,"1")) || (!strcasecmp(AH,"yes"))); @@ -335,6 +373,12 @@ void ServerConfig::Read(bool bail, userrec* user) { c.threshold = atoi(thold); } + else + { + c.threshold = 1; + c.flood = 999; + log(DEFAULT,"Warning: Connect allow line '%s' has no flood/threshold settings. Setting this tag to 999 lines in 1 second.",c.host.c_str()); + } if (atoi(sqmax)>0) { c.sendqmax = atoi(sqmax);