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

Added option to send message after connection was established #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bin/wscat
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ program
.option('--key <key>', 'Specify a Client SSL Certificate\'s key (--connect only)')
.option('--passphrase [passphrase]', 'Specify a Client SSL Certificate Key\'s passphrase (--connect only). If you don\'t provide a value, it will be prompted for.')
.option('--no-color', 'Run without color')
.option('--message <message>', 'Send message after connection was established')
.parse(process.argv);

if (program.listen && program.connect) {
Expand Down Expand Up @@ -197,6 +198,7 @@ if (program.listen && program.connect) {
if (program.ca) options.ca = fs.readFileSync(program.ca);
if (program.cert) options.cert = fs.readFileSync(program.cert);
if (program.key) options.key = fs.readFileSync(program.key);
if (program.message) options.message = program.message

var headers = into({}, (program.header || []).map(function split(s) {
return splitOnce(':', s);
Expand All @@ -216,6 +218,11 @@ if (program.listen && program.connect) {

ws.on('open', function open() {
wsConsole.print(Console.Types.Control, 'connected (press CTRL+C to quit)', Console.Colors.Green);

if (options.message) {
ws.send(options.message);
}

wsConsole.on('line', function line(data) {
ws.send(data);
wsConsole.prompt();
Expand Down