summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-19 20:44:17 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-19 20:44:17 +0000
commitc1f1f982e8af92f633db150a26caa8b4d1fbdb01 (patch)
tree6fcc6038ff533f493f48a8c234c1db8aaf7cace0
parente187e4bb6022f414664285bbb51f2b2c094315af (diff)
Added check for if the servername contains a '.', if not append one on rehash
Added retrieval of nameserver from /etc/resolv.conf if <dns:server> is not defined. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3256 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/inspircd_io.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index a467a9ad5..5995115f5 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -257,12 +257,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: <server:name> '%s' is not a fully-qualified domain name. Changed to '%s\.'",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: <dns:server> 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,"<dns:server> 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")));