Consolidate host IP detection in utils.localinterfaces

This PR replaces a number of hard-coded 127.0.0.1 references with
LOCALHOST, and consolidates the computation of LOCALHOST,
LOCAL_IPS, and a new PUBLIC_IPS in the localinterfaces module.

It's unclear to me when LOCALHOST would not be 127.0.0.1.  I suppose
you could have another IP in the 127.0.0.0/8 block, or a IPv6 address.
It may also be possible to not have a loopback interface at all.  In
that case it's possible that we need a LOOPBACK variable in
utils.localinterfaces which is a valid loopback interface or None, so
that consumers can differentiate between generic IPs pointing back to
the local host and the loopback interface.