From 284f0a04c90688aa83c8d67134a380a704e97385 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 22 Jun 2018 14:04:07 +0930 Subject: [PATCH] gossipd: don't announce bound address if given with --bind-addr, even if public. Only --addr implies announce-if-public: --bind-addr does not. It's also possible to have --bind-addr to an automatic Tor address: you'd have to dig the onion address out of the logs or getinfo to use it, but it's possible. Signed-off-by: Rusty Russell --- gossipd/gossip.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gossipd/gossip.c b/gossipd/gossip.c index a1f88ff75..720be102e 100644 --- a/gossipd/gossip.c +++ b/gossipd/gossip.c @@ -2586,10 +2586,11 @@ static struct wireaddr_internal *setup_listeners(const tal_t *ctx, for (size_t i = 0; i < tal_count(daemon->proposed_wireaddr); i++) { struct wireaddr_internal wa = daemon->proposed_wireaddr[i]; + bool announce = (daemon->proposed_listen_announce[i] + & ADDR_ANNOUNCE); if (!(daemon->proposed_listen_announce[i] & ADDR_LISTEN)) { - assert(daemon->proposed_listen_announce[i] - & ADDR_ANNOUNCE); + assert(announce); /* You can only announce wiretypes! */ assert(daemon->proposed_wireaddr[i].itype == ADDR_INTERNAL_WIREADDR); @@ -2608,6 +2609,7 @@ static struct wireaddr_internal *setup_listeners(const tal_t *ctx, addrun.sun_path); io_new_listener(daemon, fd, connection_in, daemon); /* We don't announce socket names */ + assert(!announce); add_binding(&binding, &wa); continue; case ADDR_INTERNAL_AUTOTOR: @@ -2629,7 +2631,8 @@ static struct wireaddr_internal *setup_listeners(const tal_t *ctx, true); if (ipv6_ok) { add_binding(&binding, &wa); - if (public_address(daemon, &wa.u.wireaddr)) + if (announce + && public_address(daemon, &wa.u.wireaddr)) add_announcable(daemon, &wa.u.wireaddr); } wa.u.wireaddr.type = ADDR_TYPE_IPV4; @@ -2638,7 +2641,8 @@ static struct wireaddr_internal *setup_listeners(const tal_t *ctx, if (handle_wireaddr_listen(daemon, &wa.u.wireaddr, ipv6_ok)) { add_binding(&binding, &wa); - if (public_address(daemon, &wa.u.wireaddr)) + if (announce + && public_address(daemon, &wa.u.wireaddr)) add_announcable(daemon, &wa.u.wireaddr); } continue; @@ -2646,7 +2650,7 @@ static struct wireaddr_internal *setup_listeners(const tal_t *ctx, case ADDR_INTERNAL_WIREADDR: handle_wireaddr_listen(daemon, &wa.u.wireaddr, false); add_binding(&binding, &wa); - if (public_address(daemon, &wa.u.wireaddr)) + if (announce && public_address(daemon, &wa.u.wireaddr)) add_announcable(daemon, &wa.u.wireaddr); continue; case ADDR_INTERNAL_FORPROXY: @@ -2663,6 +2667,9 @@ static struct wireaddr_internal *setup_listeners(const tal_t *ctx, if (!(daemon->proposed_listen_announce[i] & ADDR_LISTEN)) continue; + if (!(daemon->proposed_listen_announce[i] & ADDR_ANNOUNCE)) + continue; + if (daemon->proposed_wireaddr[i].itype != ADDR_INTERNAL_AUTOTOR) continue;