getdnsapi / getdns

A modern asynchronous DNS API https://getdnsapi.net/
Other
461 stars 127 forks source link

Parse IP addresses from JSON-like strings to allow better IPv6 address handling #514

Open uzlonewolf opened 2 years ago

uzlonewolf commented 2 years ago

This will allow quoted "::" and "[::]" style IPv6 addresses. Combined with a small change to stubby this will close both #358 and stubby#304

wtoorop commented 2 years ago

Thanks @uzlonewolf , but I think this approach might be a bit too generic. Any text string looking like an IP address (even as rdata field in for example a TXT RR) will be converted to an IP dict with this PR. Having that said, I do like to approach of an IP address nested in a string and I do think this would indeed be the correct way to address getdnsapi/stubby#304 . So I'm thinking maybe we can adapt getdns_context_set_upstream_recursive_servers() to accept strings in the list and convert it to addresses. Likewise for the other settings that accept IP address dicts (getdns_context_set_dns_root_servers() and getdns_context_set_listen_addresses()). WDYT?

uzlonewolf commented 2 years ago

Yes, I do like that idea a lot better. I'll try to modify this PR to do that in the next day or 2.

wtoorop commented 2 years ago

Op 06-12-2021 om 11:04 schreef uzlonewolf:

Yes, I do like that idea a lot better. I'll try to modify this PR to do that in the next day or 2.

Excellent! Thanks!

uzlonewolf commented 2 years ago

Well, after spending a couple hours on this and successfully making getdns_context_set_listen_addresses() accept an IP string, I'm still not happy with the results. It's most likely going to be a breaking change to anyone using the API and passing in an IP address as a binary string. It's probably fine for the listen addresses since those most likely include a port number and thus get passed as a dict, however the getdns_context_set_..._servers() functions are likely to have been used with binary strings.