mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
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:
parent
43d5f7e90d
commit
9cb66d7953
3 changed files with 49 additions and 30 deletions
|
@ -49,7 +49,7 @@ DNS_STATUS WINAPI DnsQuery_A
|
|||
PDNS_RECORD *QueryResultSet,
|
||||
PVOID *Reserved ) {
|
||||
adns_state astate;
|
||||
int quflags = 0;
|
||||
int quflags = 0, i;
|
||||
int adns_error;
|
||||
adns_answer *answer;
|
||||
LPSTR CurrentName;
|
||||
|
@ -62,12 +62,20 @@ DNS_STATUS WINAPI DnsQuery_A
|
|||
adns_error = adns_init( &astate,
|
||||
adns_if_noenv |
|
||||
adns_if_noerrprint |
|
||||
adns_if_noserverwarn,
|
||||
adns_if_noserverwarn |
|
||||
(Servers ? adns_if_noserver : 0),
|
||||
0 );
|
||||
|
||||
if( adns_error != adns_s_ok ) {
|
||||
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
|
||||
* another CNAME pointing to another... pointing to an A record), according
|
||||
|
|
6
reactos/lib/3rdparty/adns/src/adns.h
vendored
6
reactos/lib/3rdparty/adns/src/adns.h
vendored
|
@ -95,7 +95,8 @@ typedef enum {
|
|||
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_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;
|
||||
|
||||
typedef enum {
|
||||
|
@ -367,6 +368,9 @@ typedef struct {
|
|||
ADNS_API int adns_init(adns_state *newstate_r, adns_initflags flags,
|
||||
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,
|
||||
FILE *diagfile /*0=>discard*/, const char *configtext);
|
||||
|
||||
|
|
61
reactos/lib/3rdparty/adns/src/setup.c
vendored
61
reactos/lib/3rdparty/adns/src/setup.c
vendored
|
@ -525,7 +525,7 @@ static int init_finish(adns_state ads) {
|
|||
struct protoent *proto;
|
||||
int r;
|
||||
|
||||
if (!ads->nservers) {
|
||||
if (!ads->nservers && !(ads->iflags & adns_if_noserver)) {
|
||||
if (ads->diagfile && ads->iflags & adns_if_debug)
|
||||
fprintf(ads->diagfile,"adns: no nameservers, using localhost\n");
|
||||
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);
|
||||
|
||||
#ifdef ADNS_JGAA_WIN32
|
||||
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
|
||||
strcat(PathBuf,"\\resolv.conf");
|
||||
readconfig(ads,PathBuf,1);
|
||||
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
|
||||
strcat(PathBuf,"\\resolv-adns.conf");
|
||||
readconfig(ads,PathBuf,0);
|
||||
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
|
||||
strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv.conf");
|
||||
readconfig(ads,PathBuf,1);
|
||||
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
|
||||
strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv-adns.conf");
|
||||
readconfig(ads,PathBuf,0);
|
||||
network_info_result = GetNetworkParams(network_info, &network_info_blen);
|
||||
if (network_info_result != ERROR_SUCCESS){
|
||||
switch(network_info_result) {
|
||||
case ERROR_BUFFER_OVERFLOW: network_err_str = "ERROR_BUFFER_OVERFLOW"; break;
|
||||
case ERROR_INVALID_PARAMETER: network_err_str = "ERROR_INVALID_PARAMETER"; break;
|
||||
case ERROR_NO_DATA: network_err_str = "ERROR_NO_DATA"; break;
|
||||
case ERROR_NOT_SUPPORTED: network_err_str = "ERROR_NOT_SUPPORTED"; break;}
|
||||
adns__diag(ads,-1,0,"GetNetworkParams() failed with error [%d] %s",
|
||||
network_info_result,network_err_str);
|
||||
if (!(flags & adns_if_noserver)) {
|
||||
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
|
||||
strcat(PathBuf,"\\resolv.conf");
|
||||
readconfig(ads,PathBuf,1);
|
||||
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
|
||||
strcat(PathBuf,"\\resolv-adns.conf");
|
||||
readconfig(ads,PathBuf,0);
|
||||
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
|
||||
strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv.conf");
|
||||
readconfig(ads,PathBuf,1);
|
||||
GetWindowsDirectory(PathBuf, SECURE_PATH_LEN);
|
||||
strcat(PathBuf,"\\System32\\Drivers\\etc\\resolv-adns.conf");
|
||||
readconfig(ads,PathBuf,0);
|
||||
network_info_result = GetNetworkParams(network_info, &network_info_blen);
|
||||
if (network_info_result != ERROR_SUCCESS){
|
||||
switch(network_info_result) {
|
||||
case ERROR_BUFFER_OVERFLOW: network_err_str = "ERROR_BUFFER_OVERFLOW"; break;
|
||||
case ERROR_INVALID_PARAMETER: network_err_str = "ERROR_INVALID_PARAMETER"; break;
|
||||
case ERROR_NO_DATA: network_err_str = "ERROR_NO_DATA"; break;
|
||||
case ERROR_NOT_SUPPORTED: network_err_str = "ERROR_NOT_SUPPORTED"; break;}
|
||||
adns__diag(ads,-1,0,"GetNetworkParams() failed with error [%d] %s",
|
||||
network_info_result,network_err_str);
|
||||
}
|
||||
else {
|
||||
for(pip = &(network_info->DnsServerList); pip; pip = pip->Next) {
|
||||
addr.s_addr = inet_addr(pip->IpAddress.String);
|
||||
if ((addr.s_addr != INADDR_ANY) && (addr.s_addr != INADDR_NONE))
|
||||
addserver(ads, addr);
|
||||
else {
|
||||
for(pip = &(network_info->DnsServerList); pip; pip = pip->Next) {
|
||||
addr.s_addr = inet_addr(pip->IpAddress.String);
|
||||
if ((addr.s_addr != INADDR_ANY) && (addr.s_addr != INADDR_NONE))
|
||||
addserver(ads, addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -730,3 +732,8 @@ adns_query adns_forallqueries_next(adns_state ads, void **context_r) {
|
|||
if (context_r) *context_r= qu->ctx.ext;
|
||||
return qu;
|
||||
}
|
||||
|
||||
/* ReactOS addition */
|
||||
void adns_addserver(adns_state ads, struct in_addr addr) {
|
||||
addserver(ads, addr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue