From 4e935c6ed40cf7e8a1abc09a2c3c7753a1c93167 Mon Sep 17 00:00:00 2001 From: Matei Copot Date: Thu, 31 Oct 2019 08:25:11 +0100 Subject: [PATCH] [minor] added --hide-ping for hiding 'Received ping' and pong messages --- README.md | 1 + bin/wscat | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a0ad273..4f38bb6 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Options: -o, --origin optional origin -x, --execute execute command after connecting -w, --wait wait given seconds after executing command + -P, --hide-ping hide internal ping/pong messages --host optional host -s, --subprotocol optional subprotocol (default: []) -n, --no-check do not check for unauthorized certificates diff --git a/bin/wscat b/bin/wscat index 88ae8d5..d7adfd0 100755 --- a/bin/wscat +++ b/bin/wscat @@ -116,6 +116,7 @@ program .option('-o, --origin ', 'optional origin') .option('-x, --execute ', 'execute command after connecting') .option('-w, --wait ', 'wait given seconds after executing command') + .option('-P, --hide-ping', 'hide internal ping/pong messages') .option('--host ', 'optional host') .option('-s, --subprotocol ', 'optional subprotocol', collect, []) .option('-n, --no-check', 'do not check for unauthorized certificates') @@ -336,19 +337,23 @@ if (program.listen) { }); ws.on('ping', () => { - wsConsole.print( - Console.Types.Incoming, - 'Received ping', - Console.Colors.Blue - ); + if (!program.hidePing) { + wsConsole.print( + Console.Types.Incoming, + 'Received ping', + Console.Colors.Blue + ); + } }); ws.on('pong', () => { - wsConsole.print( - Console.Types.Incoming, - 'Received pong', - Console.Colors.Blue - ); + if (!program.hidePing) { + wsConsole.print( + Console.Types.Incoming, + 'Received pong', + Console.Colors.Blue + ); + } }); wsConsole.on('close', () => {