From 5879f6b4e07688800676b7885d03946dc177f93c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 17 Jul 2019 07:14:14 +0930 Subject: [PATCH] devtools/gossipwith: expose the INIT messages. Usually we send a canned INIT message and ignore theirs. This adds an option to not do that. Signed-off-by: Rusty Russell --- devtools/gossipwith.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/devtools/gossipwith.c b/devtools/gossipwith.c index 8a19bcc44..3497060f2 100644 --- a/devtools/gossipwith.c +++ b/devtools/gossipwith.c @@ -19,6 +19,7 @@ #define io_read_ simple_read #define io_close simple_close static bool stream_stdin = false; +static bool no_init = false; static struct io_plan *simple_write(struct io_conn *conn, const void *data, size_t len, @@ -130,11 +131,13 @@ static struct io_plan *handshake_success(struct io_conn *conn, } else localfeatures = NULL; - msg = towire_init(NULL, NULL, localfeatures); + if (!no_init) { + msg = towire_init(NULL, NULL, localfeatures); - sync_crypto_write(pps, take(msg)); - /* Ignore their init message. */ - tal_free(sync_crypto_read(NULL, pps)); + sync_crypto_write(pps, take(msg)); + /* Ignore their init message. */ + tal_free(sync_crypto_read(NULL, pps)); + } if (stream_stdin) pollfd[0].fd = STDIN_FILENO; @@ -220,6 +223,8 @@ int main(int argc, char *argv[]) "Terminate after reading this many messages (> 0)"); opt_register_noarg("--stdin", opt_set_bool, &stream_stdin, "Stream gossip messages from stdin."); + opt_register_noarg("--no-init", opt_set_bool, &no_init, + "Don't send or swallow init messages."); opt_register_arg("--privkey", opt_set_secret, opt_show_secret, ¬sosecret, "Secret key to use for our identity");