Skip to content

Commit 095f650

Browse files
m-schmoockniftynei
authored andcommitted
peer_control: fix getinfo showing unannounced addr
Currently discovered IPs are only announced when we don't have any usable addresses detected or configured already. However, the cli command `getinfo` still showed theses unannounced addr as if they were announced. Changelog-Fixed: peer_control: getinfo showing unannounced addresses.
1 parent 2853da1 commit 095f650

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

lightningd/peer_control.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,7 @@ static struct command_result *json_getinfo(struct command *cmd,
22082208
struct channel *channel;
22092209
unsigned int pending_channels = 0, active_channels = 0,
22102210
inactive_channels = 0, num_peers = 0;
2211+
size_t count_announceable;
22112212

22122213
if (!param(cmd, buffer, params, NULL))
22132214
return command_param_failed();
@@ -2241,15 +2242,22 @@ static struct command_result *json_getinfo(struct command *cmd,
22412242
/* Add network info */
22422243
if (cmd->ld->listen) {
22432244
/* These are the addresses we're announcing */
2245+
count_announceable = tal_count(cmd->ld->announceable);
22442246
json_array_start(response, "address");
2245-
for (size_t i = 0; i < tal_count(cmd->ld->announceable); i++)
2247+
for (size_t i = 0; i < count_announceable; i++)
22462248
json_add_address(response, NULL, cmd->ld->announceable+i);
2247-
if (cmd->ld->remote_addr_v4 != NULL &&
2248-
!wireaddr_arr_contains(cmd->ld->announceable, cmd->ld->remote_addr_v4))
2249-
json_add_address(response, NULL, cmd->ld->remote_addr_v4);
2250-
if (cmd->ld->remote_addr_v6 != NULL &&
2251-
!wireaddr_arr_contains(cmd->ld->announceable, cmd->ld->remote_addr_v6))
2252-
json_add_address(response, NULL, cmd->ld->remote_addr_v6);
2249+
2250+
/* Currently, IP discovery will only be announced by gossipd, if we
2251+
* don't already have usable addresses.
2252+
* See `create_node_announcement` in `gossip_generation.c`. */
2253+
if (count_announceable == 0) {
2254+
if (cmd->ld->remote_addr_v4 != NULL &&
2255+
!wireaddr_arr_contains(cmd->ld->announceable, cmd->ld->remote_addr_v4))
2256+
json_add_address(response, NULL, cmd->ld->remote_addr_v4);
2257+
if (cmd->ld->remote_addr_v6 != NULL &&
2258+
!wireaddr_arr_contains(cmd->ld->announceable, cmd->ld->remote_addr_v6))
2259+
json_add_address(response, NULL, cmd->ld->remote_addr_v6);
2260+
}
22532261
json_array_end(response);
22542262

22552263
/* This is what we're actually bound to. */

0 commit comments

Comments
 (0)