-
Notifications
You must be signed in to change notification settings - Fork 229
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
Merge wscat2 #30
Open
nwwells
wants to merge
45
commits into
websockets:master
Choose a base branch
from
jnordberg:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Merge wscat2 #30
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
4a793fe
Show code and reason for non-1000 close events from server
dstillman ffab4de
Merge pull request #1 from jnordberg/better-usage
jnordberg ff1074a
Merge pull request #2 from dstillman/show-close-code
jnordberg 2ceccd9
Merge branch 'bare-hostname'
jnordberg 5c159ce
Don't use negative exit codes
jnordberg 6e2fdb2
Add --retry option
jnordberg 7367281
Merge remote-tracking branch 'origin/feature/retry'
jnordberg fff05a7
Add .gitignore
jnordberg e8732bc
Merge remote-tracking branch 'esphen/message-option'
jnordberg 40b1a05
Update dependencies
jnordberg 8ba68ff
Rename module
jnordberg 22ae25a
Added new behaviours for better debugging
jonmilley e47afae
Fix keepalive timeout being interpreted as milliseconds
c365d2b
1.1.0
d2f3adc
Fix installation instructions
dbf095d
Merge pull request #4 from robinzimmermann/master
jnordberg 835b4ad
Out with the old
jnordberg 94b3df0
In with the new
jnordberg 32854de
Add license and readme
jnordberg 919914d
Travis!
jnordberg 0952e79
Fix tests
jnordberg 41bdb21
Only test against node 6 and 7
jnordberg 665e565
Add travis badge
jnordberg 8446bc9
WebSocket Subprotocol (#5)
ArtiomL ac2d4b5
Improve build script
jnordberg b831ab7
Add Developing section to README
jnordberg c18dd57
Update dependencies
jnordberg 0eceaf6
Fix version in build script
jnordberg c65e8c9
Version 2.0.1
jnordberg d25ff92
Test against node 6, 8, 10 and 11
jnordberg 98f3bcf
partway
FGasper 0c4bf8f
further
FGasper 8d6d804
add -n option, too
FGasper e9bb636
Update dependencies
jnordberg a5f1050
Skip undefined in WebSocket constructor
jnordberg 363d9b4
Version 2.1.0
jnordberg ab062d2
Update usage
jnordberg 73d25da
Drop support for node 6 and add node 12
jnordberg ac1f565
Add rawmode option to stdin
ff6ddd1
Version 2.2.0
jnordberg b928155
Add -c/--report-close option so caller can know WebSocket exit status.
FGasper 87f4ed7
Version 2.3.0
jnordberg 272f058
Add -R/--send-resize option to optionally send resize events as text …
37cb7fa
Update dependencies
jnordberg 2b00221
Version 2.4.0
jnordberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
lib | ||
test/testfile* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- "8" | ||
- "10" | ||
- "11" | ||
- "12" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Copyright 2017 Johan Nordberg <[email protected]> | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
SHELL := /bin/bash | ||
PATH := ./node_modules/.bin:$(PATH) | ||
|
||
SRC_FILES := $(shell find src -name '*.ts') | ||
|
||
.PHONY: all | ||
all: lib | ||
|
||
.PHONY: test | ||
test: node_modules | ||
tslint -p tsconfig.json -c tslint.json && \ | ||
./test/cli.sh | ||
|
||
.PHONY: lint | ||
lint: node_modules | ||
tslint -p tsconfig.json -c tslint.json -t stylish --fix | ||
|
||
lib: $(SRC_FILES) node_modules | ||
tsc -p tsconfig.json && \ | ||
sed -i "" "1s/ts-node/node/" lib/cli.js && \ | ||
rm lib/cli.d.ts && \ | ||
VERSION="$$(node -p 'require("./package.json").version')"; \ | ||
echo "exports.default = '$${VERSION}';" > lib/version.js && \ | ||
touch lib | ||
|
||
node_modules: | ||
npm ci && \ | ||
touch node_modules | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf lib/ | ||
|
||
.PHONY: distclean | ||
distclean: clean | ||
rm -rf node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,141 @@ | ||
# wscat | ||
|
||
WebSocket cat. | ||
wscat2 [![Build Status](https://travis-ci.org/jnordberg/wscat.svg?branch=master)](https://travis-ci.org/jnordberg/wscat) | ||
====== | ||
|
||
## Installation | ||
Unix-style WebSocket cat (or netcat for websockets). | ||
|
||
This module needs to be installed globally so use the `-g` flag when installing: | ||
|
||
Installation | ||
------------ | ||
|
||
``` | ||
npm install -g wscat2 | ||
``` | ||
|
||
|
||
Usage | ||
----- | ||
|
||
``` | ||
$ wscat -h | ||
usage: wscat [-h] [-v] [-l PORT] [-b] [-H HEADER] [-n] [-k] [-d] [-s SUBP] [address] | ||
|
||
Positional arguments: | ||
address | ||
|
||
Optional arguments: | ||
-h, --help Show this help message and exit. | ||
-v, --version Show program's version number and exit. | ||
-l PORT, --listen PORT | ||
Start a websocket server on PORT. | ||
-b, --binary Use binary WebSockets. | ||
-H HEADER, --header HEADER | ||
Specify a custom HTTP request header. May be given | ||
multiple times. | ||
-n, --no-check Do not check for unauthorized certificates. | ||
-k, --keep-open Do not close the socket after EOF. | ||
-d, --deflate Use per-message deflate. | ||
-s SUBP, --subprotocol SUBP | ||
WebSocket subprotocol | ||
``` | ||
|
||
|
||
Examples | ||
-------- | ||
|
||
If you ever used `nc`, `wscat` works pretty much the same. | ||
|
||
### Connect to a server | ||
|
||
``` | ||
$ wscat echo.websocket.org | ||
Hello | ||
Hello | ||
Who's there? | ||
Who's there? | ||
^D | ||
|
||
``` | ||
|
||
### Chat | ||
|
||
Server: | ||
|
||
``` | ||
$ wscat -l 12345 | ||
Hi there! | ||
Hi! | ||
It's nice to speak to someone who just dosn't repeat everything I say back at me. | ||
Yeah! Isn't it?! | ||
Sorry, gotta run... | ||
^D | ||
|
||
``` | ||
|
||
Client: | ||
|
||
``` | ||
$ wscat localhost:12345 | ||
Hi there! | ||
Hi! | ||
It's nice to speak to someone who just dosn't repeat everything I say back at me. | ||
Yeah! Isn't it?! | ||
Sorry, gotta run... | ||
``` | ||
|
||
### Transfer a file | ||
|
||
Server: | ||
|
||
``` | ||
$ wscat -b -l 12345 < ~/Desktop/mycat.jpg | ||
``` | ||
|
||
Client: | ||
|
||
``` | ||
npm install -g wscat | ||
$ wscat -b localhost:12345 > igotacat.jpg | ||
``` | ||
|
||
## Usage | ||
Note that you can have the client send the file as well, after the connection has been setup `wscat` does not differentiate between server/client. | ||
|
||
### Get your bitcoin on | ||
|
||
``` | ||
$ wscat -c ws://echo.websocket.org | ||
connected (press CTRL+C to quit) | ||
> hi there | ||
< hi there | ||
> are you a happy parrot? | ||
< are you a happy parrot? | ||
$ echo '{"op":"unconfirmed_sub"}' | wscat -k wss://ws.blockchain.info/inv | ||
``` | ||
|
||
## License | ||
The `-k` option is used to keep the socket open after the command has been sent, allowing us to read the continuous stream of Bitcoin transactions. | ||
|
||
MIT | ||
|
||
Developing | ||
---------- | ||
|
||
This node.js program is written in TypeScript and has a compile step that you can run with `make lib`. For developing it is convenient to install the `ts-node` and `typescript` modules globally (`npm i -g ..`), this will allow you to directly execute the programs entry-point: `./src/cli.ts`. | ||
|
||
Use `make test` to run the tests and lint check and `make lint` to run the linter in formatter mode. | ||
|
||
|
||
License | ||
------- | ||
|
||
[BSD 3-Clause](https://tldrlegal.com/license/bsd-3-clause-license-(revised)) | ||
|
||
--- | ||
|
||
``` | ||
|
||
/\_/\ /\_/\ | ||
/ 0 0 \ / o o \ | ||
====v==== ====C==== __ __ | ||
\ W / \ V / _( )_( )_ | ||
| | _ | | .-=(_ WEB _) | ||
/ ___ \ / / ___ \ / (__ __) | ||
/ / \ \ | / / \ \ | (__) | ||
(((-----)))-' (((-----)))-' | ||
/ / | ||
( ___ ___ / | ||
\__.=|___|E 3__|=.__/ | ||
/ ^ | ||
|
||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be
wscat
, no?