Fix comparison of IPv6 addrs and reduce duplicated calls to ipaddr.js