Subject: Re: Resolving names without dns-suffix on windows

Re: Resolving names without dns-suffix on windows

From: Maxim Ruban <m.ruban_at_drweb.com>
Date: Wed, 26 Jun 2013 16:20:07 +0400

Rene,

Yes, get_DNS_NetworkParams() & get_DNS_AdaptersAddresses() return
domain, but the only one domain.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365900%28v=vs.85%29.aspx
- result of GetNetworkParams call
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366058%28v=vs.85%29.aspx
- result of GetAdaptersAddresses call

GetAdaptersAddresses may return multiple domains within field
PIP_ADAPTER_DNS_SUFFIX FirstDnsSuffix,
however the field was introduces in Windows SDK 7.0 and works on Vista
SP1 and later.
This field in header looks like

typedef struct _IP_ADAPTER_ADDRESSES_LH {
...
#if (NTDDI_VERSION >= NTDDI_VISTASP1)
     PIP_ADAPTER_DNS_SUFFIX FirstDnsSuffix;
#endif
}

and I dont know how use it without no-so-good hack (i.e. copy definition
from SDK into some c-ares file)
or adding limitation for user's compiler.

I chose registry-way since it's quite simple, and on windows-nt
platforms registry structure has not changed till Win7.
I haven't yet tested in under Win2k(3,8)/Win8, but it works fine on XP &
Win7.

As to option/necessity of getting more domains, I think it is convenient
for user not to specify anything manually.
However there is a thing I am unsure: what if some domains is not
functioning - imho, it may cause lookup delays.

Maybe getting one domain is enough. (I will be satisfied with this)

As to "goto" it's kinda copy-paste from get_DNS_Registry :)
Also, get_DNS_Suffixes may be moved into get_DNS_Windows.
I've placed it into init_by_default to allow override domain list by
value specified in LOCALDOMAIN,
but see no reasons for such "feature".

On 2013-06-26 1:06 AM, René Berber wrote:
>
>
> On 6/25/2013 3:37 PM, Daniel Stenberg wrote:
>
>> On Tue, 25 Jun 2013, Maxim Ruban wrote:
>>
>>> Patch is in attach (pl. let me know if something wrong with it - I've
>>> made it by TortoiseCVS on Windows, and don't know if it's compatible
>>> with Unix-family tools).
>>>
>>> Please, review it and improve if neccessary.
>>
>> I'm very interested in "+1"s or other expressions of acknowledgements as
>> I'm a Windows illiterate and I need help to tell a good fix from
>> something that needs improvements.
>>
>> Given some support on this list, I don't mind to merge and push.
>
> The code uses a goto, which is a no-no if I remember correctly.
>
> I haven't had time to research if reading the Windows registry is
> necessary at all, what comes to mind is: what if the existing calls to
> get_DNS_Windows(), get_DNS_NetworkParams(), and
> get_DNS_AdaptersAddresses() are already doing that (and how else would
> they do their work).
>
> As pointed out by Maxim, there are several issues here, (1) resolving
> simple names (i.e. with no domain), my patch solves that; (2) getting
> all the domains (i.e. from all active network interfaces).
>
> I think we need a good test case, or several.
Received on 2013-06-26