I've decided to create separate issue disregarding that we have already ZBX-3783 because I'll mention server side, maybe there also will be something to change/fix - all is up to you.
I'm creating this issue based on a real case happened.
My perl script resolved a host name to IP and mistakenly added one line break at the end of IP address. Then the script updates host's IP using zabbix API.
By API method "hostinterface.update" I was able to successfully put these params:
As it look then (note here the line break):
As it should look if there no line break:
This line break of course is not visible in frontend.
So it's bad that API allows to do that -> has to be fixed.
IF server/proxy compiled with IPv6 support then it is able to process the IP address with a line break(s) at the end.
But without IPv6 support an agent goes to unavailable. Error message text in frontend is (the line break preserved here !):
Such problem becomes very unclear - what is bad actually.
Difference is that with IPv6 server/proxy uses "getaddrinfo()" system call, but without IPv6 - another system call - "gethostbyname()".
See comms.c lines 282 and 348
I don't know why it is so.
"# man gethostbyname" says that, quote:
" The gethostbyname*() and gethostbyaddr*() functions are obsolete. Applications should use getaddrinfo(3) and getnameinfo(3) instead.
This page is part of release 3.27 of the Linux man-pages project."
As we see the getaddrinfo() (used with IPv6) is more, say, "robust" in our case
So question to C devs - is this good/required to use namely gethostbyname() there in zabbix code ?