Add the ability to specify DNS servers and make adns work right in case they

are specified.

svn path=/trunk/; revision=23626
This commit is contained in:
Art Yerkes 2006-08-20 20:51:54 +00:00
parent 43d5f7e90d
commit 9cb66d7953
3 changed files with 49 additions and 30 deletions

View file

@ -49,7 +49,7 @@ DNS_STATUS WINAPI DnsQuery_A
PDNS_RECORD *QueryResultSet, PDNS_RECORD *QueryResultSet,
PVOID *Reserved ) { PVOID *Reserved ) {
adns_state astate; adns_state astate;
int quflags = 0; int quflags = 0, i;
int adns_error; int adns_error;
adns_answer *answer; adns_answer *answer;
LPSTR CurrentName; LPSTR CurrentName;
@ -62,12 +62,20 @@ DNS_STATUS WINAPI DnsQuery_A
adns_error = adns_init( &astate, adns_error = adns_init( &astate,
adns_if_noenv | adns_if_noenv |
adns_if_noerrprint | adns_if_noerrprint |
adns_if_noserverwarn, adns_if_noserverwarn |
(Servers ? adns_if_noserver : 0),
0 ); 0 );
if( adns_error != adns_s_ok ) { if( adns_error != adns_s_ok ) {
return DnsIntTranslateAdnsToDNS_STATUS( adns_error ); return DnsIntTranslateAdnsToDNS_STATUS( adns_error );
} }
if (Servers) {
for( i = 0; i < Servers->AddrCount; i++ ) {
adns_addserver( astate, *((struct in_addr *)&Servers->AddrArray[i]) );
}
}
/* /*
* adns doesn't resolve chained CNAME records (a CNAME which points to * adns doesn't resolve chained CNAME records (a CNAME which points to
* another CNAME pointing to another... pointing to an A record), according * another CNAME pointing to another... pointing to an A record), according

View file

@ -95,7 +95,8 @@ typedef enum {
adns_if_eintr= 0x0020, /* allow _wait and _synchronous to return EINTR */ adns_if_eintr= 0x0020, /* allow _wait and _synchronous to return EINTR */
adns_if_nosigpipe= 0x0040, /* applic has SIGPIPE set to SIG_IGN, do not protect */ adns_if_nosigpipe= 0x0040, /* applic has SIGPIPE set to SIG_IGN, do not protect */
adns_if_checkc_entex= 0x0100, /* do consistency checks on entry/exit to adns funcs */ adns_if_checkc_entex= 0x0100, /* do consistency checks on entry/exit to adns funcs */
adns_if_checkc_freq= 0x0300 /* do consistency checks very frequently (slow!) */ adns_if_checkc_freq= 0x0300, /* do consistency checks very frequently (slow!) */
adns_if_noserver= 0x0800, /* do not get dns servers from the environment */
} adns_initflags; } adns_initflags;
typedef enum { typedef enum {
@ -367,6 +368,9 @@ typedef struct {
ADNS_API int adns_init(adns_state *newstate_r, adns_initflags flags, ADNS_API int adns_init(adns_state *newstate_r, adns_initflags flags,
FILE *diagfile /*0=>stderr*/); FILE *diagfile /*0=>stderr*/);
/* ReactOS addition */
ADNS_API void adns_addserver(adns_state state, struct in_addr server);
ADNS_API int adns_init_strcfg(adns_state *newstate_r, adns_initflags flags, ADNS_API int adns_init_strcfg(adns_state *newstate_r, adns_initflags flags,
FILE *diagfile /*0=>discard*/, const char *configtext); FILE *diagfile /*0=>discard*/, const char *configtext);

View file

@ -525,7 +525,7 @@ static int init_finish(adns_state ads) {
struct protoent *proto; struct protoent *proto;
int r; int r;
if (!ads->nservers) { if (!ads->nservers && !(ads->iflags & adns_if_noserver)) {
if (ads->diagfile && ads->iflags & adns_if_debug) if (ads->diagfile && ads->iflags & adns_if_debug)
fprintf(ads->diagfile,"adns: no nameservers, using localhost\n"); fprintf(ads->diagfile,"adns: no nameservers, using localhost\n");
ia.s_addr= htonl(INADDR_LOOPBACK); ia.s_addr= htonl(INADDR_LOOPBACK);
@ -589,33 +589,35 @@ int adns_init(adns_state *ads_r, adns_initflags flags, FILE *diagfile) {
ccf_options(ads,"ADNS_RES_OPTIONS",-1,adns_res_options); ccf_options(ads,"ADNS_RES_OPTIONS",-1,adns_res_options);
#ifdef ADNS_JGAA_WIN32 #ifdef ADNS_JGAA_WIN32
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN); if (!(flags & adns_if_noserver)) {
strcat(PathBuf,"\\resolv.conf"); GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
readconfig(ads,PathBuf,1); strcat(PathBuf,"\\resolv.conf");
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN); readconfig(ads,PathBuf,1);
strcat(PathBuf,"\\resolv-adns.conf"); GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
readconfig(ads,PathBuf,0); strcat(PathBuf,"\\resolv-adns.conf");
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN); readconfig(ads,PathBuf,0);
strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv.conf"); GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
readconfig(ads,PathBuf,1); strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv.conf");
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN); readconfig(ads,PathBuf,1);
strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv-adns.conf"); GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
readconfig(ads,PathBuf,0); strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv-adns.conf");
network_info_result = GetNetworkParams(network_info, &network_info_blen); readconfig(ads,PathBuf,0);
if (network_info_result != ERROR_SUCCESS){ network_info_result = GetNetworkParams(network_info, &network_info_blen);
switch(network_info_result) { if (network_info_result != ERROR_SUCCESS){
case ERROR_BUFFER_OVERFLOW: network_err_str = "ERROR_BUFFER_OVERFLOW"; break; switch(network_info_result) {
case ERROR_INVALID_PARAMETER: network_err_str = "ERROR_INVALID_PARAMETER"; break; case ERROR_BUFFER_OVERFLOW: network_err_str = "ERROR_BUFFER_OVERFLOW"; break;
case ERROR_NO_DATA: network_err_str = "ERROR_NO_DATA"; break; case ERROR_INVALID_PARAMETER: network_err_str = "ERROR_INVALID_PARAMETER"; break;
case ERROR_NOT_SUPPORTED: network_err_str = "ERROR_NOT_SUPPORTED"; break;} case ERROR_NO_DATA: network_err_str = "ERROR_NO_DATA"; break;
adns__diag(ads,-1,0,"GetNetworkParams() failed with error [%d] %s", case ERROR_NOT_SUPPORTED: network_err_str = "ERROR_NOT_SUPPORTED"; break;}
network_info_result,network_err_str); adns__diag(ads,-1,0,"GetNetworkParams() failed with error [%d] %s",
network_info_result,network_err_str);
} }
else { else {
for(pip = &(network_info->DnsServerList); pip; pip = pip->Next) { for(pip = &(network_info->DnsServerList); pip; pip = pip->Next) {
addr.s_addr = inet_addr(pip->IpAddress.String); addr.s_addr = inet_addr(pip->IpAddress.String);
if ((addr.s_addr != INADDR_ANY) && (addr.s_addr != INADDR_NONE)) if ((addr.s_addr != INADDR_ANY) && (addr.s_addr != INADDR_NONE))
addserver(ads, addr); addserver(ads, addr);
}
} }
} }
#else #else
@ -730,3 +732,8 @@ adns_query adns_forallqueries_next(adns_state ads, void **context_r) {
if (context_r) *context_r= qu->ctx.ext; if (context_r) *context_r= qu->ctx.ext;
return qu; return qu;
} }
/* ReactOS addition */
void adns_addserver(adns_state ads, struct in_addr addr) {
addserver(ads, addr);
}