[ldns-users] How to use _searchlist provided by ldns_struct_resolver?

Matthijs Mekking matthijs at NLnetLabs.nl
Mon Oct 25 12:00:58 UTC 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

You requested:
"So I would expect ldns_resolver_search() should try every combination
for given name (with and without suffix(es))."

Adding the root zone to the search list ensures that every combination
is tried (all search domains appended or treat it as a fqdn).

But now, if I understand correctly, you want to be able to choose
whether you should do a fqdn query or append a search domain?

Best regards,

Matthijs



On 10/25/2010 01:45 PM, Zbynek Michl wrote:
> Hi Matthijs,
> 
> thanks for your fixes, however I think that it is not a good idea to add
> "." zone to the end of the search list in ldns_resolver_new_frm_fp_l()
> by default.
> 
> In my case I am querying for A/AAAA records and it does not make a sense
> to query domain names with just one label (e.g. myname.)
> 
> It would be better to make new resolver option for this or let user to
> add it by hand if he needs it (as it was in previous releases of ldns).
> 
> Regards,
> Zbynek
> 
> On 18.10.2010 13:11, Matthijs Mekking wrote:
> Hi Zbynek,
> 
> On 10/15/2010 03:01 PM, Zbynek Michl wrote:
> ...
>>>> So I would expect ldns_resolver_search() should try every combination
>>>> for given name (with and without suffix(es)).
> 
> I guess by default adding the root domain (".") to the search list would
> fix that.
> 
>>>> Btw reading of searchlist from resolv.conf containing more than one
>>>> suffix (e.g. search mydomain.com mydomain.cz) still does not work
>>>> properly.
> 
> Fixed this in r3357.
> 
> Best regards,
> Matthijs
> 
>>>>
>>>> Thanks,
>>>> Zbynek
>>>>
>>>> On 20.9.2010 12:40, Matthijs Mekking wrote:
>>>> Hi Zbynek,
>>>>
>>>> I noticed that the dname2str function prints a dot after every label.
>>>> And that function is used in ldns_resolver_search(...) to determine if
>>>> the domain is a relative or a fqdn. I fixed this in trunk, r3347.
>>>>
>>>> I found another bug in the ldns_resolver_search function. The
>>>> ldns_resolver stops as soon it founds a packet. But it would be nice if
>>>> the ldns_resolver continues its search if the RCODE of that packet is
>>>> not NOERROR. This fix is in trunk since r3349.
>>>>
>>>> Thanks for your report.
>>>>
>>>> Best regards,
>>>>
>>>> Matthijs
>>>>
>>>>
>>>> On 09/14/2010 06:46 PM, Zbynek Michl wrote:
>>>>>>> Hi Matthijs,
>>>>>>>
>>>>>>> I have tried to make a dname like this:
>>>>>>>
>>>>>>> domain = ldns_dname_new_frm_str("myhostname");
>>>>>>> new_domain = ldns_dname_new_frm_data(ldns_rdf_size(domain) - 1,
>>>>>>>                                        ldns_rdf_data(domain));
>>>>>>> printf("domain: %s\n", ldns_rdf2str(domain));
>>>>>>> printf("new_domain: %s\n", ldns_rdf2str(new_domain));
>>>>>>>
>>>>>>> It is strange for me that both printf()s print the same result
>>>>>>> (with dot
>>>>>>> at the end). And then when I use:
>>>>>>>
>>>>>>> p = ldns_resolver_search(res, new_domain, LDNS_RR_TYPE_A,
>>>>>>>                            LDNS_RR_CLASS_IN, LDNS_RD);
>>>>>>>
>>>>>>> resolver returns FORMERR, because ldns_resolver_search() uses
>>>>>>> ldns_rdf2str() which causes to call ldns_resolver_query() with
>>>>>>> incorrect
>>>>>>> domain name.
>>>>>>>
>>>>>>>
>>>>>>> Another error of ldns_resolver_search() is that it does not check
>>>>>>> RCODE.
>>>>>>> In case of this resolv.conf:
>>>>>>>
>>>>>>> search mydomain.com
>>>>>>> search mydomain.cz
>>>>>>>
>>>>>>> and query for "myhostname" will try just first search value even if
>>>>>>> NXDOMAIN is returned.
>>>>>>>
>>>>>>> Last error that I have observed is that ldns_resolver_new_frm_file()
>>>>>>> reads just first domain name on line, so this searchlist
>>>>>>> definition is
>>>>>>> not read completely:
>>>>>>>
>>>>>>> search mydomain.com mydomain.cz
>>>>>>>
>>>>>>>
>>>>>>> Regards,
>>>>>>> Zbynek
>>>>>>>
>>>>>>> On 12.5.2010 09:04, Matthijs Mekking wrote:
>>>>>>> Hi Zbynek,
>>>>>>>
>>>>>>> Sorry for the late follow-up. You are right that making a dname from
>>>>>>> string always returns an absolute dname. You can try making a
>>>>>>> dname with
>>>>>>> ldns_dname_new_frm_data().
>>>>>>>
>>>>>>> Best regards,
>>>>>>>
>>>>>>> Matthijs
>>>>>>>
>>>>>>> Zbynek Michl wrote:
>>>>>>>>>> Hello,
>>>>>>>>>>
>>>>>>>>>> I am trying to use search list, but unsuccessfully. Here is an
>>>>>>>>>> sample:
>>>>>>>>>>
>>>>>>>>>> --- CODE ---
>>>>>>>>>> ldns_rdf *domain = ldns_dname_new_frm_str("myhostname");
>>>>>>>>>> ldns_rdf *search = ldns_dname_new_frm_str("mydomain.cz");
>>>>>>>>>>
>>>>>>>>>> ldns_resolver_push_searchlist(res, search);
>>>>>>>>>>
>>>>>>>>>> p = ldns_resolver_search(res, domain, LDNS_RR_TYPE_A,
>>>>>>>>>>                 LDNS_RR_CLASS_IN, LDNS_RD);
>>>>>>>>>> --- /CODE ---
>>>>>>>>>>
>>>>>>>>>> The problem is that "myhostname.mydomain.cz" will never be tried,
>>>>>>>>>> because of ldns_dname_new_frm_str() adds "." to the end of
>>>>>>>>>> "myhostname"
>>>>>>>>>> and therefore ldns_resolver_search() will not concatenate
>>>>>>>>>> "mydomain.cz".
>>>>>>>>>> So how can I create "myhostname" RDF without trailing "."? Or any
>>>>>>>>>> other
>>>>>>>>>> suggestion?
>>>>>>>>>>
>>>>>>>>>> Cheers,
>>>>>>>>>> Zbynek
>>>>>>>>>> _______________________________________________
>>>>>>>>>> ldns-users mailing list
>>>>>>>>>> ldns-users at open.nlnetlabs.nl
>>>>>>>>>> http://open.nlnetlabs.nl/mailman/listinfo/ldns-users
>>>>>>>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMxXF6AAoJEA8yVCPsQCW5LWwIAIMYOLgYG6680UteYwTrC85t
l4wFpVBcoyoyGIWl68d4bt25z/G2UlT7obSiCZGY7x+YraPpbeE0UI1466W3eJEe
cmzZ8dMAbytCdkT/XMmmEf0uxbg/KziKHuM7KcixI49aJXDz/p/Dk/2RrnAPyir8
R2nXDKRCV8ieOGXjcROjxwB6kXtP3DrrCYTLbZhzJE3l06bykp/hOeX3MrdtrSXm
UzxrdnSRgDQjqwxJ68dnsCjEbtw6r8EJeCjKBYYdBbhwTybZ8jyNJetKW/ZO5G+4
XKcj4EXouOZjVLtV2toKHhwiGr4JYfmUVGKg7zf7GDULSbuEKzkhreNPTyjneFk=
=wGOB
-----END PGP SIGNATURE-----



More information about the ldns-users mailing list