wireaddr: tell caller that we failed due to wanting DNS lookup, don't try.

This is useful for the next patch, where we want to hand the unresolved
name through to the proxy.

This also addresses @Saibato's worry that we still called getaddrinfo()
(with the AI_NUMERICHOST option) even if we didn't want a lookup.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-05-10 12:25:15 +09:30
parent 5345e43354
commit a1dc4eef56
4 changed files with 36 additions and 18 deletions

View File

@@ -299,15 +299,17 @@ static char *opt_set_offline(struct lightningd *ld)
static char *opt_add_proxy_addr(const char *arg, struct lightningd *ld)
{
bool needed_dns;
tal_free(ld->proxyaddr);
/* We use a tal_arr here, so we can marshal it to gossipd */
ld->proxyaddr = tal_arr(ld, struct wireaddr, 1);
if (!parse_wireaddr(arg, ld->proxyaddr, 9050, !ld->use_proxy_always,
if (!parse_wireaddr(arg, ld->proxyaddr, 9050,
ld->use_proxy_always ? &needed_dns : NULL,
NULL)) {
return tal_fmt(NULL, "Unable to parse Tor proxy address '%s'",
arg);
return tal_fmt(NULL, "Unable to parse Tor proxy address '%s' %s",
arg, needed_dns ? " (needed dns)" : "");
}
return NULL;
}