mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
gossipd: hand io_tor_connect the host as a string.
Previously it converted the wireaddr to a string internally: to support unresolved names we need that done externally. We actually tell the SOCKS5 proxy to do a domain lookup already, even though we give use IP/IPv6 address, so this change is sufficient to support connect-by-name. Note replacement of assert() with an explicit case statement, which has the benefit that the compiler complains when we add new ADDR_INTERNAL types. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
a1dc4eef56
commit
0d23f4fb4a
@ -1925,10 +1925,27 @@ static struct io_plan *conn_init(struct io_conn *conn, struct reaching *reach)
|
||||
static struct io_plan *conn_proxy_init(struct io_conn *conn,
|
||||
struct reaching *reach)
|
||||
{
|
||||
assert(reach->addr.itype == ADDR_INTERNAL_WIREADDR);
|
||||
char *host = NULL;
|
||||
u16 port;
|
||||
|
||||
switch (reach->addr.itype) {
|
||||
case ADDR_INTERNAL_WIREADDR:
|
||||
host = fmt_wireaddr_without_port(tmpctx,
|
||||
&reach->addr.u.wireaddr);
|
||||
port = reach->addr.u.wireaddr.port;
|
||||
break;
|
||||
case ADDR_INTERNAL_SOCKNAME:
|
||||
case ADDR_INTERNAL_ALLPROTO:
|
||||
case ADDR_INTERNAL_AUTOTOR:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!host)
|
||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||
"Can't reach to %u address", reach->addr.itype);
|
||||
|
||||
io_set_finish(conn, connect_failed, reach);
|
||||
return io_tor_connect(conn, reach->daemon->proxyaddr,
|
||||
&reach->addr.u.wireaddr, reach);
|
||||
return io_tor_connect(conn, reach->daemon->proxyaddr, host, port, reach);
|
||||
}
|
||||
|
||||
static struct addrhint *
|
||||
|
@ -151,13 +151,13 @@ static struct io_plan *io_tor_connect_do_req(struct io_conn *conn,
|
||||
// called when we want to connect to TOR SOCKS5
|
||||
struct io_plan *io_tor_connect(struct io_conn *conn,
|
||||
const struct addrinfo *tor_proxyaddr,
|
||||
const struct wireaddr *addr,
|
||||
const char *host, u16 port,
|
||||
struct reaching *reach)
|
||||
{
|
||||
struct reaching_socks *reach_tor = tal(reach, struct reaching_socks);
|
||||
|
||||
reach_tor->port = htons(addr->port);
|
||||
reach_tor->host = fmt_wireaddr_without_port(reach_tor, addr);
|
||||
reach_tor->port = htons(port);
|
||||
reach_tor->host = tal_strdup(reach_tor, host);
|
||||
reach_tor->reach = reach;
|
||||
|
||||
return io_connect(conn, tor_proxyaddr,
|
||||
|
@ -10,7 +10,7 @@ struct reaching;
|
||||
|
||||
struct io_plan *io_tor_connect(struct io_conn *conn,
|
||||
const struct addrinfo *tor_proxyaddr,
|
||||
const struct wireaddr *addr,
|
||||
const char *host, u16 port,
|
||||
struct reaching *reach);
|
||||
|
||||
#endif /* LIGHTNING_GOSSIPD_TOR_H */
|
||||
|
Loading…
Reference in New Issue
Block a user