mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
gossipd: don't try to connect to non-routable addresses.
Someone could try to announce an internal address, and we might probe it. This breaks tests, so we add '--dev-allow-localhost' for our tests, so we don't eliminate that one. Of course, now we need to skip some more tests in non-developer mode. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
af065417e1
commit
d40d22b68e
@@ -185,6 +185,11 @@ void gossip_init(struct lightningd *ld)
|
||||
u64 capabilities = HSM_CAP_ECDH | HSM_CAP_SIGN_GOSSIP;
|
||||
struct wireaddr_internal *wireaddrs = ld->proposed_wireaddr;
|
||||
enum addr_listen_announce *listen_announce = ld->proposed_listen_announce;
|
||||
bool allow_localhost = false;
|
||||
#if DEVELOPER
|
||||
if (ld->dev_allow_localhost)
|
||||
allow_localhost = true;
|
||||
#endif
|
||||
|
||||
msg = towire_hsm_client_hsmfd(tmpctx, &ld->id, capabilities);
|
||||
if (!wire_sync_write(ld->hsm_fd, msg))
|
||||
@@ -219,7 +224,8 @@ void gossip_init(struct lightningd *ld)
|
||||
get_offered_global_features(tmpctx),
|
||||
get_offered_local_features(tmpctx), wireaddrs,
|
||||
listen_announce, ld->rgb,
|
||||
ld->alias, ld->config.channel_update_interval, ld->reconnect);
|
||||
ld->alias, ld->config.channel_update_interval, ld->reconnect,
|
||||
allow_localhost);
|
||||
subd_send_msg(ld->gossip, msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||
ld->dev_debug_subdaemon = NULL;
|
||||
ld->dev_disconnect_fd = -1;
|
||||
ld->dev_subdaemon_fail = false;
|
||||
ld->dev_allow_localhost = false;
|
||||
|
||||
if (getenv("LIGHTNINGD_DEV_MEMLEAK"))
|
||||
memleak_init(ld, backtrace_state);
|
||||
|
||||
@@ -189,6 +189,9 @@ struct lightningd {
|
||||
/* If we have --dev-fail-on-subdaemon-fail */
|
||||
bool dev_subdaemon_fail;
|
||||
|
||||
/* Allow and accept localhost node_announcement addresses */
|
||||
bool dev_allow_localhost;
|
||||
|
||||
/* Things we've marked as not leaking. */
|
||||
const void **notleaks;
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
@@ -415,6 +415,9 @@ static void dev_register_opts(struct lightningd *ld)
|
||||
"Time between gossip broadcasts in milliseconds");
|
||||
opt_register_arg("--dev-disconnect=<filename>", opt_subd_dev_disconnect,
|
||||
NULL, ld, "File containing disconnection points");
|
||||
opt_register_noarg("--dev-allow-localhost", opt_set_bool,
|
||||
&ld->dev_allow_localhost,
|
||||
"Announce and allow announcments for localhost address");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user