summaryrefslogtreecommitdiff
path: root/win/inspircd_win32wrapper.cpp
diff options
context:
space:
mode:
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-17 20:48:20 +0000
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-17 20:48:20 +0000
commit8a2e5dcbe47996628477d4ddfa040e017c4de156 (patch)
tree13f1c55fd893ae5c18ed0bd7bcec6cc35595c49f /win/inspircd_win32wrapper.cpp
parentbd5c443a6a7e93df59e0ef23aacba46b0916a8da (diff)
Fix up finding dns server to use for windows to match latest configreader changes.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11892 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'win/inspircd_win32wrapper.cpp')
-rw-r--r--win/inspircd_win32wrapper.cpp47
1 files changed, 28 insertions, 19 deletions
diff --git a/win/inspircd_win32wrapper.cpp b/win/inspircd_win32wrapper.cpp
index 1309e6064..3cc4f240e 100644
--- a/win/inspircd_win32wrapper.cpp
+++ b/win/inspircd_win32wrapper.cpp
@@ -354,7 +354,7 @@ bool GetInterface(HKEY regkey, const char *key, char* &output)
std::string FindNameServerWin()
{
- std::string returnval = "127.0.0.1";
+ std::string returnval;
HKEY top, key;
char* dns = NULL;
@@ -517,27 +517,36 @@ void WindowsForkKillOwner()
CloseHandle(hProcess);
}
-bool ValidateDnsServer(ServerConfig* conf, const char* tag, const char* value, ValueItem &data)
+void FindDNS(std::string& server)
{
- if (!*(data.GetString()))
+ if (!server.empty())
+ return;
+
+ ServerInstance->Logs->Log("CONFIG",DEFAULT,"WARNING: <dns:server> not defined, attempting to find working server in the registry...");
+ std::string nameserver = FindNameServerWin();
+
+ /* If empty use default to 127.0.0.1 */
+ if (nameserver.empty())
{
- std::string nameserver;
- ServerInstance->Logs->Log("win32",DEFAULT,"WARNING: <dns:server> not defined, attempting to find working server in the registry...");
- nameserver = FindNameServerWin();
- /* Windows stacks multiple nameservers in one registry key, seperated by commas.
- * Spotted by Cataclysm.
- */
- if (nameserver.find(',') != std::string::npos)
- nameserver = nameserver.substr(0, nameserver.find(','));
- /* Just to be FUCKING AKWARD, windows fister... err i mean vista...
- * seperates the nameservers with spaces instead.
- */
- if (nameserver.find(' ') != std::string::npos)
- nameserver = nameserver.substr(0, nameserver.find(' '));
- data.Set(nameserver.c_str());
- ServerInstance->Logs->Log("win32",DEFAULT,"<dns:server> set to '%s' as first active resolver in registry.", nameserver.c_str());
+ ServerInstance->Logs->Log("CONFIG",DEFAULT,"/etc/resolv.conf contains no viable nameserver entries! Defaulting to nameserver '127.0.0.1'!");
+ server = "127.0.0.1";
+ return;
}
- return true;
+
+ /* Windows stacks multiple nameservers in one registry key, seperated by commas.
+ * Spotted by Cataclysm.
+ */
+ if (nameserver.find(',') != std::string::npos)
+ nameserver = nameserver.substr(0, nameserver.find(','));
+
+ /* Just to be FUCKING AKWARD, windows fister... err i mean vista...
+ * seperates the nameservers with spaces instead.
+ */
+ if (nameserver.find(' ') != std::string::npos)
+ nameserver = nameserver.substr(0, nameserver.find(' '));
+
+ server = nameserver;
+ ServerInstance->Logs->Log("CONFIG",DEFAULT,"<dns:server> set to '%s' as first active resolver in registry.", nameserver.c_str());
}
int gettimeofday(struct timeval * tv, void * tz)