getdns icon indicating copy to clipboard operation
getdns copied to clipboard

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

Open uzlonewolf opened this issue 4 years ago • 4 comments

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

uzlonewolf avatar Dec 04 '21 00:12 uzlonewolf

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?

wtoorop avatar Dec 06 '21 09:12 wtoorop

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.

uzlonewolf avatar Dec 06 '21 10:12 uzlonewolf

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!

wtoorop avatar Dec 06 '21 11:12 wtoorop

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.

uzlonewolf avatar Dec 07 '21 06:12 uzlonewolf