mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Comment on how we came up with this code, and comment it
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7116 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
e8aed79a4b
commit
3ee9f47ac1
@ -368,12 +368,15 @@ void CloseIPC()
|
||||
}
|
||||
|
||||
|
||||
/* These three functions were created from looking at how ares does it
|
||||
* (...and they look far tidier in C++)
|
||||
*/
|
||||
|
||||
/* Get active nameserver */
|
||||
bool GetNameServer(HKEY regkey, const char *key, char* &output)
|
||||
{
|
||||
/* Test for the size we need */
|
||||
DWORD size = 0;
|
||||
DWORD result = RegQueryValueEx(regkey, key, 0, NULL, NULL, &size);
|
||||
|
||||
if (((result != ERROR_SUCCESS) && (result != ERROR_MORE_DATA)) || (!size))
|
||||
return false;
|
||||
|
||||
@ -387,6 +390,7 @@ bool GetNameServer(HKEY regkey, const char *key, char* &output)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check a network interface for its nameserver */
|
||||
bool GetInterface(HKEY regkey, const char *key, char* &output)
|
||||
{
|
||||
char buf[39];
|
||||
@ -414,8 +418,10 @@ std::string FindNameServerWin()
|
||||
HKEY top, key;
|
||||
char* dns = NULL;
|
||||
|
||||
/* Lets see if the correct registry hive and tree exist */
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\Tcpip\\Parameters", 0, KEY_READ, &top) == ERROR_SUCCESS)
|
||||
{
|
||||
/* If they do, attempt to get the nameserver name */
|
||||
RegOpenKeyEx(top, "Interfaces", 0, KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS, &key);
|
||||
if ((GetNameServer(top, "NameServer", dns)) || (GetNameServer(top, "DhcpNameServer", dns))
|
||||
|| (GetInterface(key, "NameServer", dns)) || (GetInterface(key, "DhcpNameServer", dns)))
|
||||
@ -431,3 +437,4 @@ std::string FindNameServerWin()
|
||||
}
|
||||
return returnval;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user