diag_testport suggestions and issues
I hope you don't mind that I place multiple things in a single ticket here about diag_testport:
1) can output error "Cannot connect to an IPv6
address using IPv4." (and vice-versa) But that
is_ipaddrv4 / is_ipaddrv6 is for IP addresses. The "host" field
may be a hostname, so a hostname like ipv6.test-ipv6.com
returns only AAAA, and doesn't give that "Cannot connect" error.
This is misleading. I do understand that the hostname is passed
direct to netcat.
2) diag_testport has confusing documentation about
mix of IPv4 and AAAA, but I can set IP Protocol to IPv6
and I have NO IPv6 and a test will return "successful."
Also it uses the word "forced" but IPv4 and IPv6 are only options
so one must be selected.
3) suggestion: since the IP Protocol list only has two choices, maybe
just display as radio instead of drop-down menu
4) the diag_testport code suggests that -4 or -6 should be used,
but that is only done if the host is an IP number and not a hostname.
It is interesting that the code has many checks for setting this
-4 or -6, but the IP Protocol selection is not even used unless
the host is an IP number. If -6 is used on an IPv4 network, even
the getaddrinfo() will fail and netcat will indicate that (but
diag_testport won't do that).
5) Actually the IP Protocol selection as a choice makes no
sense: diag_testport is smart enough to detect that it is
mismatched and smart enough to see an optional sourceip's protocol,
then it is smart enough to select the protocol on its own.
But if it would honor the ipprotocol for hostnames (no IP number),
then maybe a value of having that IP Protocol selection is valid.
It may be useful to run netcat with -v
and provide that output, like "No route to host" or "Succeeded!".