Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[minor] added --hide-ping for hiding 'Received ping' and pong messages #110

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -23,6 +23,7 @@ Options:
-o, --origin <origin> optional origin
-x, --execute <command> execute command after connecting
-w, --wait <seconds> wait given seconds after executing command
-P, --hide-ping hide internal ping/pong messages
--host <host> optional host
-s, --subprotocol <protocol> optional subprotocol (default: [])
-n, --no-check do not check for unauthorized certificates
Expand Down
25 changes: 15 additions & 10 deletions bin/wscat
Expand Up @@ -116,6 +116,7 @@ program
.option('-o, --origin <origin>', 'optional origin')
.option('-x, --execute <command>', 'execute command after connecting')
.option('-w, --wait <seconds>', 'wait given seconds after executing command')
.option('-P, --hide-ping', 'hide internal ping/pong messages')
.option('--host <host>', 'optional host')
.option('-s, --subprotocol <protocol>', 'optional subprotocol', collect, [])
.option('-n, --no-check', 'do not check for unauthorized certificates')
Expand Down Expand Up @@ -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', () => {
Expand Down