diff --git a/connectd/connectd.c b/connectd/connectd.c index 02a2e010b..a71270deb 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -1412,7 +1412,8 @@ static void connect_init(struct daemon *daemon, const u8 *msg) &daemon->announce_websocket, &daemon->dev_fast_gossip, &dev_disconnect, - &daemon->dev_no_ping_timer)) { + &daemon->dev_no_ping_timer, + &daemon->dev_handshake_no_reply)) { /* This is a helper which prints the type expected and the actual * message, then exits (it should never be called!). */ master_badmsg(WIRE_CONNECTD_INIT, msg); diff --git a/connectd/connectd.h b/connectd/connectd.h index 00a188212..20b65ce1a 100644 --- a/connectd/connectd.h +++ b/connectd/connectd.h @@ -266,7 +266,9 @@ struct daemon { int dev_disconnect_fd; /* Did we exhaust fds? If so, skip dev_report_fds */ bool dev_exhausted_fds; -}; + /* Allow connections in, but don't send anything */ + bool dev_handshake_no_reply; + }; /* Called by io_tor_connect once it has a connection out. */ struct io_plan *connection_out(struct io_conn *conn, struct connecting *connect); diff --git a/connectd/connectd_wire.csv b/connectd/connectd_wire.csv index 2df3dd00e..d15ffc66c 100644 --- a/connectd/connectd_wire.csv +++ b/connectd/connectd_wire.csv @@ -25,6 +25,8 @@ msgdata,connectd_init,dev_fast_gossip,bool, # If this is set, then fd 5 is dev_disconnect_fd. msgdata,connectd_init,dev_disconnect,bool, msgdata,connectd_init,dev_no_ping_timer,bool, +# Allow incoming connections, but don't talk. +msgdata,connectd_init,dev_noreply,bool, # Connectd->master, here are the addresses I bound, can announce. msgtype,connectd_init_reply,2100 diff --git a/connectd/peer_exchange_initmsg.c b/connectd/peer_exchange_initmsg.c index bef289ad3..99933e3c0 100644 --- a/connectd/peer_exchange_initmsg.c +++ b/connectd/peer_exchange_initmsg.c @@ -295,5 +295,9 @@ struct io_plan *peer_exchange_initmsg(struct io_conn *conn, break; } + /* Don't converse if we said "no reply" */ + if (daemon->dev_handshake_no_reply) + return io_wait(conn, peer->msg, io_never, NULL); + return io_write(conn, peer->msg, tal_bytelen(peer->msg), next, peer); } diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index b9757e4cf..2ba6d54c6 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -764,7 +764,8 @@ int connectd_init(struct lightningd *ld) !ld->deprecated_ok, ld->dev_fast_gossip, ld->dev_disconnect_fd >= 0, - ld->dev_no_ping_timer); + ld->dev_no_ping_timer, + ld->dev_handshake_no_reply); subd_req(ld->connectd, ld->connectd, take(msg), -1, 0, connect_init_done, NULL); diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 76c8dcc16..0434990a4 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -148,6 +148,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx) ld->dev_allow_shutdown_destination_change = false; ld->dev_hsmd_no_preapprove_check = false; ld->dev_hsmd_fail_preapprove = false; + ld->dev_handshake_no_reply = false; /*~ We try to ensure enough fds for twice the number of channels * we start with. We have a developer option to change that factor diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 8b1d973b7..090e8b6c5 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -356,6 +356,9 @@ struct lightningd { bool dev_hsmd_no_preapprove_check; bool dev_hsmd_fail_preapprove; + /* Tell connectd not to talk after handshake */ + bool dev_handshake_no_reply; + /* tor support */ struct wireaddr *proxyaddr; bool always_use_proxy; diff --git a/lightningd/options.c b/lightningd/options.c index 8c794f271..0ec3abd69 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -952,6 +952,10 @@ static void dev_register_opts(struct lightningd *ld) opt_set_u32, opt_show_u32, &ld->fd_limit_multiplier, "Try to set fd limit to this many times by number of channels (default: 2)"); + clnopt_noarg("--dev-handshake-no-reply", OPT_DEV, + opt_set_bool, + &ld->dev_handshake_no_reply, + "Don't send or read init message after connection"); /* This is handled directly in daemon_developer_mode(), so we ignore it here */ clnopt_noarg("--dev-debug-self", OPT_DEV, opt_ignore,