Skip to content

Allow longer nameservers.#121

Merged
yarrick merged 1 commit intoyarrick:masterfrom
nneonneo:namelen-patch
Aug 25, 2025
Merged

Allow longer nameservers.#121
yarrick merged 1 commit intoyarrick:masterfrom
nneonneo:namelen-patch

Conversation

@nneonneo
Copy link
Copy Markdown
Contributor

@nneonneo nneonneo commented Aug 25, 2025

IPv6 nameservers can be significantly longer than 16 characters in length. For example, 2001:0db8:85a3:0000:0000:8a2e:0370:7334 is 39 characters long, and certain syntax elements (e.g. zone indices) can make them even longer.

This patch allows up to 256 characters for the nameserver, which is large enough to contain the maximum length of any hostname (~253 ASCII characters), and definitely enough for any IPv4 or IPv6 address.

Testing

I am using an IPv6 nameserver whose IP address is longer than 16 bytes. Without this patch, I get the error iodine: Cannot lookup nameserver '2001:db8:85a3:0': Unknown error. With this patch, Iodine works correctly.

Note that the Unknown error part occurs because my getaddrinfo returns 8 ("nodename nor servname provided, or not known") but this gets translated into -1 by get_addr, and then -1 gets passed into gai_strerror. This is unfortunate as the actual error gets swallowed; a potentially better error handling strategy would be to return addrlen in a pointer parameter and have only 0 be a successful result, but this would necessitate a number of changes throughout the code.

IPv6 nameservers can be significantly longer than 16 characters in length. For example, `2001:0db8:85a3:0000:0000:8a2e:0370:7334` is 39 characters long, and certain syntax elements (e.g. zone indices) can make them even longer. This patch allows up to 256 characters for the nameserver, which is large enough to contain the maximum length of any hostname (~253 ASCII characters), and definitely enough for any IPv4 or IPv6 address.
@yarrick
Copy link
Copy Markdown
Owner

yarrick commented Aug 25, 2025

Thanks, this looks good. I don't think it is valid to use hostnames to specify nameservers though

@yarrick yarrick merged commit 3fcd128 into yarrick:master Aug 25, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants