Handle non-127.0.0.1 IPv4 loopback addresses

In legacy/trac#17901 (moved), we identified some FreeBSD jails and OpenVZ VMs as having no 127.0.0.1. legacy/trac#17901 (moved) deals with those systems that have no loopback at all.

But some FreeBSD jails block access to 127.0.0.1, and have loopback on a valid yet unexpected address, like 127.0.0.2.

Tor could bind to any address in 127/8 (or ::1, see legacy/trac#11360 (moved)) and be accessible locally.

One possible implementation is:

  • find all addresses on all loopback interfaces (legacy/trac#17949 (moved))
  • choose the address that's closest to 127.0.0.1
  • use that address as the bind address
  • If there is no 127.0.0.0/8 (or ::1) on the server, reject the *Port with a warning that tells the user to use AF_UNIX (if their system supports it), or supply an explicit IP address if they really want their *Port listening on a non-local address.

Operators can always specify an explicit bind address in the *Port line, so this isn't a serious usability issue.