HiddenServicePort should connect to localhost by default
HiddenServicePort currently connects to 127.0.0.1 by default, but this will fail in configs where localhost is somewhere else in 127.0.0.0/8 or is [::1]. (Such as BSD jails.)
Instead, we can:
- resolve "localhost", and check that it's in 127.0.0.0/8 or [::1], and use the IPv4 address first for compatibility with existing configurations
- default to 127.0.0.1 if that exists
- default to [::1] if 127.0.0.1 does not exist
This is not a security issue, as it results in a failed hidden service connection on unusual configs. It's a minor usability issue.