Tweak tor-resolve docs and logs

Resolves 14325
This commit is contained in:
Nick Mathewson 2015-01-28 10:11:08 -05:00
parent 20d0b1a04e
commit f75ca04520
3 changed files with 25 additions and 12 deletions

5
changes/ticket14325 Normal file
View File

@ -0,0 +1,5 @@
o Documentation fixes:
- Make the tor-resolve documentation match its help string and its
options. Resolves part of ticket 14325.
- Log a more useful error message from tor-resolve when failing to
look up a hidden service address. Resolves part of ticket 14325.

View File

@ -14,7 +14,7 @@ tor-resolve - resolve a hostname to an IP address via tor
SYNOPSIS SYNOPSIS
-------- --------
**tor-resolve** [-4|-5] [-v] [-x] __hostname__ [__sockshost__[:__socksport__]] **tor-resolve** [-4|-5] [-v] [-x] [-p __socksport__] __hostname__ [__sockshost__[:__socksport__]]
DESCRIPTION DESCRIPTION
----------- -----------
@ -40,6 +40,9 @@ OPTIONS
Use the SOCKS4a protocol rather than the default SOCKS5 protocol. Doesn't Use the SOCKS4a protocol rather than the default SOCKS5 protocol. Doesn't
support reverse DNS. support reverse DNS.
**-p** __socksport__::
Override the default SOCKS port without setting the hostname.
SEE ALSO SEE ALSO
-------- --------
**tor**(1), **torify**(1). + **tor**(1), **torify**(1). +

View File

@ -108,6 +108,18 @@ build_socks_resolve_request(char **out,
return len; return len;
} }
static void
onion_warning(const char *hostname)
{
log_warn(LD_NET,
"%s is a hidden service; those don't have IP addresses. "
"You can use the AutomapHostsOnResolve option to have Tor return a "
"fake address for hidden services. Or you can have your "
"application send the address to Tor directly; we recommend an "
"application that uses SOCKS 5 with hostnames.",
hostname);
}
/** Given a <b>len</b>-byte SOCKS4a response in <b>response</b>, set /** Given a <b>len</b>-byte SOCKS4a response in <b>response</b>, set
* *<b>addr_out</b> to the address it contains (in host order). * *<b>addr_out</b> to the address it contains (in host order).
* Return 0 on success, -1 on error. * Return 0 on success, -1 on error.
@ -137,10 +149,7 @@ parse_socks4a_resolve_response(const char *hostname,
if (status != 90) { if (status != 90) {
log_warn(LD_NET,"Got status response '%d': socks request failed.", status); log_warn(LD_NET,"Got status response '%d': socks request failed.", status);
if (!strcasecmpend(hostname, ".onion")) { if (!strcasecmpend(hostname, ".onion")) {
log_warn(LD_NET, onion_warning(hostname);
"%s is a hidden service; those don't have IP addresses. "
"To connect to a hidden service, you need to send the hostname "
"to Tor; we suggest an application that uses SOCKS 4a.",hostname);
return -1; return -1;
} }
return -1; return -1;
@ -276,11 +285,7 @@ do_resolve(const char *hostname, uint32_t sockshost, uint16_t socksport,
(unsigned)reply_buf[1], (unsigned)reply_buf[1],
socks5_reason_to_string(reply_buf[1])); socks5_reason_to_string(reply_buf[1]));
if (reply_buf[1] == 4 && !strcasecmpend(hostname, ".onion")) { if (reply_buf[1] == 4 && !strcasecmpend(hostname, ".onion")) {
log_warn(LD_NET, onion_warning(hostname);
"%s is a hidden service; those don't have IP addresses. "
"To connect to a hidden service, you need to send the hostname "
"to Tor; we suggest an application that uses SOCKS 4a.",
hostname);
} }
goto err; goto err;
} }
@ -326,8 +331,8 @@ do_resolve(const char *hostname, uint32_t sockshost, uint16_t socksport,
static void static void
usage(void) usage(void)
{ {
puts("Syntax: tor-resolve [-4] [-v] [-x] [-F] [-p port] " puts("Syntax: tor-resolve [-4] [-5] [-v] [-x] [-F] [-p port] "
"hostname [sockshost:socksport]"); "hostname [sockshost[:socksport]]");
exit(1); exit(1);
} }