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

Merge wscat2 #30

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 Feb 15, 2015
ffab4de
Merge pull request #1 from jnordberg/better-usage
jnordberg Jun 27, 2015
ff1074a
Merge pull request #2 from dstillman/show-close-code
jnordberg Jun 27, 2015
2ceccd9
Merge branch 'bare-hostname'
jnordberg Jun 27, 2015
5c159ce
Don't use negative exit codes
jnordberg Jun 27, 2015
6e2fdb2
Add --retry option
jnordberg Jun 27, 2015
7367281
Merge remote-tracking branch 'origin/feature/retry'
jnordberg Mar 28, 2016
fff05a7
Add .gitignore
jnordberg Mar 28, 2016
e8732bc
Merge remote-tracking branch 'esphen/message-option'
jnordberg Mar 28, 2016
40b1a05
Update dependencies
jnordberg Mar 28, 2016
8ba68ff
Rename module
jnordberg Mar 28, 2016
22ae25a
Added new behaviours for better debugging
jonmilley Apr 26, 2016
e47afae
Fix keepalive timeout being interpreted as milliseconds
May 13, 2016
c365d2b
1.1.0
May 13, 2016
d2f3adc
Fix installation instructions
Apr 21, 2017
dbf095d
Merge pull request #4 from robinzimmermann/master
jnordberg Apr 21, 2017
835b4ad
Out with the old
jnordberg Apr 25, 2017
94b3df0
In with the new
jnordberg Apr 25, 2017
32854de
Add license and readme
jnordberg Apr 25, 2017
919914d
Travis!
jnordberg Apr 25, 2017
0952e79
Fix tests
jnordberg Apr 25, 2017
41bdb21
Only test against node 6 and 7
jnordberg Apr 25, 2017
665e565
Add travis badge
jnordberg Apr 25, 2017
8446bc9
WebSocket Subprotocol (#5)
ArtiomL Dec 7, 2017
ac2d4b5
Improve build script
jnordberg Nov 20, 2018
b831ab7
Add Developing section to README
jnordberg Nov 20, 2018
c18dd57
Update dependencies
jnordberg Nov 20, 2018
0eceaf6
Fix version in build script
jnordberg Nov 20, 2018
c65e8c9
Version 2.0.1
jnordberg Nov 20, 2018
d25ff92
Test against node 6, 8, 10 and 11
jnordberg Nov 20, 2018
98f3bcf
partway
FGasper May 12, 2019
0c4bf8f
further
FGasper May 12, 2019
8d6d804
add -n option, too
FGasper May 12, 2019
e9bb636
Update dependencies
jnordberg May 14, 2019
a5f1050
Skip undefined in WebSocket constructor
jnordberg May 14, 2019
363d9b4
Version 2.1.0
jnordberg May 14, 2019
ab062d2
Update usage
jnordberg May 14, 2019
73d25da
Drop support for node 6 and add node 12
jnordberg May 14, 2019
ac1f565
Add rawmode option to stdin
May 21, 2019
ff6ddd1
Version 2.2.0
jnordberg May 22, 2019
b928155
Add -c/--report-close option so caller can know WebSocket exit status.
FGasper May 30, 2019
87f4ed7
Version 2.3.0
jnordberg May 30, 2019
272f058
Add -R/--send-resize option to optionally send resize events as text …
Jun 25, 2019
37cb7fa
Update dependencies
jnordberg Jul 1, 2019
2b00221
Version 2.4.0
jnordberg Jul 1, 2019
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
lib
test/testfile*
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js
node_js:
- "8"
- "10"
- "11"
- "12"
11 changes: 11 additions & 0 deletions LICENSE
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.
21 changes: 0 additions & 21 deletions LICENSE.md

This file was deleted.

37 changes: 37 additions & 0 deletions Makefile
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/
143 changes: 129 additions & 14 deletions README.md
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)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be wscat, no?

======

## 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__|=.__/
/ ^

```
Loading