mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 16:44:20 +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:
@@ -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,
|
static struct io_plan *conn_proxy_init(struct io_conn *conn,
|
||||||
struct reaching *reach)
|
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);
|
io_set_finish(conn, connect_failed, reach);
|
||||||
return io_tor_connect(conn, reach->daemon->proxyaddr,
|
return io_tor_connect(conn, reach->daemon->proxyaddr, host, port, reach);
|
||||||
&reach->addr.u.wireaddr, reach);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct addrhint *
|
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
|
// called when we want to connect to TOR SOCKS5
|
||||||
struct io_plan *io_tor_connect(struct io_conn *conn,
|
struct io_plan *io_tor_connect(struct io_conn *conn,
|
||||||
const struct addrinfo *tor_proxyaddr,
|
const struct addrinfo *tor_proxyaddr,
|
||||||
const struct wireaddr *addr,
|
const char *host, u16 port,
|
||||||
struct reaching *reach)
|
struct reaching *reach)
|
||||||
{
|
{
|
||||||
struct reaching_socks *reach_tor = tal(reach, struct reaching_socks);
|
struct reaching_socks *reach_tor = tal(reach, struct reaching_socks);
|
||||||
|
|
||||||
reach_tor->port = htons(addr->port);
|
reach_tor->port = htons(port);
|
||||||
reach_tor->host = fmt_wireaddr_without_port(reach_tor, addr);
|
reach_tor->host = tal_strdup(reach_tor, host);
|
||||||
reach_tor->reach = reach;
|
reach_tor->reach = reach;
|
||||||
|
|
||||||
return io_connect(conn, tor_proxyaddr,
|
return io_connect(conn, tor_proxyaddr,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ struct reaching;
|
|||||||
|
|
||||||
struct io_plan *io_tor_connect(struct io_conn *conn,
|
struct io_plan *io_tor_connect(struct io_conn *conn,
|
||||||
const struct addrinfo *tor_proxyaddr,
|
const struct addrinfo *tor_proxyaddr,
|
||||||
const struct wireaddr *addr,
|
const char *host, u16 port,
|
||||||
struct reaching *reach);
|
struct reaching *reach);
|
||||||
|
|
||||||
#endif /* LIGHTNING_GOSSIPD_TOR_H */
|
#endif /* LIGHTNING_GOSSIPD_TOR_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user