@ -150,9 +150,6 @@ struct daemon {
struct addrinfo * proxyaddr ;
bool use_proxy_always ;
bool tor_autoservice ;
struct wireaddr * tor_serviceaddr ;
char * tor_password ;
} ;
@ -1689,6 +1686,9 @@ static struct wireaddr_internal *setup_listeners(const tal_t *ctx,
/* We don't announce socket names */
add_binding ( & binding , & wa ) ;
continue ;
case ADDR_INTERNAL_AUTOTOR :
/* We handle these after we have all bindings. */
continue ;
case ADDR_INTERNAL_ALLPROTO : {
bool ipv6_ok ;
@ -1732,6 +1732,20 @@ static struct wireaddr_internal *setup_listeners(const tal_t *ctx,
daemon - > proposed_wireaddr [ i ] . itype ) ;
}
/* Now we have bindings, set up any Tor auto addresses */
for ( size_t i = 0 ; i < tal_count ( daemon - > proposed_wireaddr ) ; i + + ) {
if ( ! ( daemon - > proposed_listen_announce [ i ] & ADDR_LISTEN ) )
continue ;
if ( daemon - > proposed_wireaddr [ i ] . itype ! = ADDR_INTERNAL_AUTOTOR )
continue ;
add_announcable ( daemon ,
tor_autoservice ( tmpctx ,
& daemon - > proposed_wireaddr [ i ] . u . torservice ,
daemon - > tor_password ,
binding ) ) ;
}
return binding ;
}
@ -1754,8 +1768,8 @@ static struct io_plan *gossip_init(struct daemon_conn *master,
& daemon - > proposed_listen_announce , daemon - > rgb ,
daemon - > alias , & update_channel_interval , & daemon - > reconnect ,
& proxyaddr , & daemon - > use_proxy_always ,
& dev_allow_localhost , & daemon - > tor_autoservice ,
& daemon - > tor_serviceaddr , & daemon - > tor_ password ) ) {
& dev_allow_localhost ,
& daemon - > tor_password ) ) {
master_badmsg ( WIRE_GOSSIPCTL_INIT , msg ) ;
}
/* Prune time is twice update time */
@ -1791,17 +1805,9 @@ static struct io_plan *gossip_activate(struct daemon_conn *master,
if ( ! fromwire_gossipctl_activate ( msg , & listen ) )
master_badmsg ( WIRE_GOSSIPCTL_ACTIVATE , msg ) ;
if ( listen ) {
if ( listen )
binding = setup_listeners ( tmpctx , daemon ) ;
if ( daemon - > tor_autoservice ) {
struct wireaddr * tor ;
tor = tor_autoservice ( tmpctx ,
daemon - > tor_serviceaddr ,
daemon - > tor_password ,
binding ) ;
add_announcable ( daemon , tor ) ;
}
} else
else
binding = NULL ;
/* If we only advertize Tor addresses, force everything through proxy
@ -1924,6 +1930,10 @@ static struct io_plan *conn_init(struct io_conn *conn, struct reaching *reach)
status_failed ( STATUS_FAIL_INTERNAL_ERROR ,
" Can't reach to all protocols " ) ;
break ;
case ADDR_INTERNAL_AUTOTOR :
status_failed ( STATUS_FAIL_INTERNAL_ERROR ,
" Can't reach to autotor address " ) ;
break ;
case ADDR_INTERNAL_WIREADDR :
/* If it was a Tor address, we wouldn't be here. */
ai = wireaddr_to_addrinfo ( tmpctx , & reach - > addr . u . wireaddr ) ;
@ -2078,6 +2088,9 @@ static void try_reach_peer(struct daemon *daemon, const struct pubkey *id,
case ADDR_INTERNAL_ALLPROTO :
status_failed ( STATUS_FAIL_INTERNAL_ERROR ,
" Can't reach ALLPROTO " ) ;
case ADDR_INTERNAL_AUTOTOR :
status_failed ( STATUS_FAIL_INTERNAL_ERROR ,
" Can't reach AUTOTOR " ) ;
case ADDR_INTERNAL_WIREADDR :
switch ( a - > addr . u . wireaddr . type ) {
case ADDR_TYPE_TOR_V2 :