This function has a nasty API, since whether or not it invokes the resolver depends on whether one of its arguments is NULL. That's a good way for accidents to happen. This patch incidentally makes tor-resolve support socks hosts on IPv6.