Thanks to (86) of
ZBXNEXT-1263 we now save peer hostname/IP in peer field of zbx_socket_t structure and reuse when necessary.
The only exception is zbx_tcp_check_security() calling getpeername() and inet_ntoa()/zbx_getnameinfo() independently. We should reuse peer at least and possibly think about storing getpeername() result in zbx_socket_t structure too on stage of zbx_tcp_accept().
Suppose zabbix_sender disconnects (due to timeout or network failure) right after server/proxy performs zbx_tcp_accept(). Server/proxy will be able to read sender data but will have to reject it because of security restriction since second call of getpeername() will fail.
Also peer in zbx_socket_t and host in zbx_get_ip_by_socket() use different in size static buffers.