diff options
author | Mike Chiussi <chiussi@gmail.com> | 2006-09-07 03:53:14 +0000 |
---|---|---|
committer | Mike Chiussi <chiussi@gmail.com> | 2006-09-07 03:53:14 +0000 |
commit | 5af47d16415dd81543f4b74445aa2de9667d3829 (patch) | |
tree | 828fc4b0eab91828e791314dcd327d36aa81d237 | |
parent | c8b053ba874c81bf68467a2f8fe41c1b9343d49b (diff) | |
download | tor-5af47d16415dd81543f4b74445aa2de9667d3829.tar tor-5af47d16415dd81543f4b74445aa2de9667d3829.tar.gz |
- added some debugging lines to load_nameservers_from_registry()
svn:r8342
-rw-r--r-- | src/or/dns.c | 4 | ||||
-rw-r--r-- | src/or/eventdns.c | 36 |
2 files changed, 34 insertions, 6 deletions
diff --git a/src/or/dns.c b/src/or/dns.c index a8771f023..122e60d1b 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -1291,8 +1291,10 @@ configure_nameservers(int force) eventdns_search_clear(); eventdns_clear_nameservers_and_suspend(); } - if (eventdns_config_windows_nameservers()) + if (eventdns_config_windows_nameservers()) { + log_warn(LD_EXIT,"Could not config nameservers."); return -1; + } if (eventdns_count_nameservers() == 0) { log_warn(LD_EXIT, "Unable to find any platform nameservers in " "your Windows configuration. Perhaps you should list a " diff --git a/src/or/eventdns.c b/src/or/eventdns.c index 536e6b64d..4eb533f32 100644 --- a/src/or/eventdns.c +++ b/src/or/eventdns.c @@ -298,6 +298,7 @@ #undef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) + #if 0 #ifdef __USE_ISOC99B // libevent doesn't work without this @@ -2061,12 +2062,14 @@ load_nameservers_with_getnetworkparams(void) IP_ADDR_STRING *ns; DWORD (WINAPI *fn)(FIXED_INFO*, DWORD*); - if (!(handle = LoadLibrary("iphlpapi.dll"))) + if (!(handle = LoadLibrary("iphlpapi.dll"))) goto done; + if (!(fn = (DWORD (WINAPI*)(FIXED_INFO*,DWORD*)) - GetProcAddress(handle, "GetNetworkParams"))) + GetProcAddress(handle, "GetNetworkParams"))) { goto done; + } buf = malloc(size); if (!buf) { status = 4; goto done; } @@ -2137,21 +2140,35 @@ static int load_nameservers_from_registry(void) { int found = 0; + int r; #define TRY(k, name) \ if (!found && config_nameserver_from_reg_key(k,name) == 0) { \ log(EVENTDNS_LOG_DEBUG,"Found nameservers in %s/%s",#k,name); \ found = 1; \ + } else {\ + if (!found)\ + log(EVENTDNS_LOG_DEBUG,"Didn't find nameservers in %s/%s",#k,#name);\ } if (((int)GetVersion()) > 0) { /* NT */ HKEY nt_key = 0, interfaces_key = 0; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, - KEY_READ, &nt_key) != ERROR_SUCCESS) + KEY_READ, &nt_key) != ERROR_SUCCESS){ + log(EVENTDNS_LOG_DEBUG,"Couldn't open nt key, %d",(int)GetLastError()); return -1; - RegOpenKeyEx(nt_key, "Interfaces", 0, + + } + r = RegOpenKeyEx(nt_key, "Interfaces", 0, KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS, &interfaces_key); + + if (r != ERROR_SUCCESS ) { + log(EVENTDNS_LOG_DEBUG,"Couldn't open interfaces key, %d",(int)GetLastError()); + return -1; + + } + TRY(nt_key, "NameServer"); TRY(nt_key, "DhcpNameServer"); TRY(interfaces_key, "NameServer"); @@ -2161,11 +2178,20 @@ load_nameservers_from_registry(void) } else { HKEY win_key = 0; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_9X_KEY, 0, - KEY_READ, &win_key) != ERROR_SUCCESS) + KEY_READ, &win_key) != ERROR_SUCCESS) { + log(EVENTDNS_LOG_DEBUG,"Couldn't open registry key, %d",(int)GetLastError()); return -1; + + } TRY(win_key, "NameServer"); RegCloseKey(win_key); } + + if (found == 0) { + log(EVENTDNS_LOG_WARN,"Didn't find any nameservers."); + } + + return found ? 0 : -1; #undef TRY } |