Skip to content

Commit

Permalink
gossipd: only use IP discovery if no addresses are announced
Browse files Browse the repository at this point in the history
This will only add the discovered `remote_addr` IPs if no other
addresses would be announced. Meaning whenever a public address was
found by autobind or an address was specified via commandline or config,
IP discovery will be disabled.

Addresses: #5305

Note from the author: We could/should also enable IP discovery when we only
have a TOR address (but without --always-use-proxy ofc). This will give
nodes an option to have a bootstrap way to be reached until IP discovery
can do the job in a more stable way.

Changelog-Changed: Only use IP discovery as fallback when no addresses would be announced
  • Loading branch information
m-schmoock committed Jul 11, 2022
1 parent cac2140 commit b955b1b
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions gossipd/gossip_generation.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,24 @@ static u8 *create_node_announcement(const tal_t *ctx, struct daemon *daemon,
u8 *addresses = tal_arr(tmpctx, u8, 0);
u8 *announcement;
struct tlv_node_ann_tlvs *na_tlv;
size_t i;
size_t i, count_announceable;

/* add all announceable addresses */
count_announceable = tal_count(daemon->announceable);
was = tal_arr(tmpctx, struct wireaddr, 0);
for (i = 0; i < tal_count(daemon->announceable); i++)
for (i = 0; i < count_announceable; i++)
tal_arr_expand(&was, daemon->announceable[i]);

/* add reported `remote_addr` v4 and v6 of our self */
if (daemon->remote_addr_v4 != NULL &&
!wireaddr_arr_contains(was, daemon->remote_addr_v4))
tal_arr_expand(&was, *daemon->remote_addr_v4);
if (daemon->remote_addr_v6 != NULL &&
!wireaddr_arr_contains(was, daemon->remote_addr_v6))
tal_arr_expand(&was, *daemon->remote_addr_v6);
/* Add IP discovery `remote_addr` v4 and v6 of our self. */
/* Only do that if we don't have addresses announced. */
if (count_announceable == 0) {
if (daemon->remote_addr_v4 != NULL &&
!wireaddr_arr_contains(was, daemon->remote_addr_v4))
tal_arr_expand(&was, *daemon->remote_addr_v4);
if (daemon->remote_addr_v6 != NULL &&
!wireaddr_arr_contains(was, daemon->remote_addr_v6))
tal_arr_expand(&was, *daemon->remote_addr_v6);
}

/* Sort by address type again, as we added dynamic remote_addr v4/v6. */
/* BOLT #7:
Expand Down

0 comments on commit b955b1b

Please sign in to comment.