# wstcp-server

> WebSocket TCP forwarding command-line server

Latest version **1.0.1** (published 2024-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install wstcp-server
pnpm add wstcp-server
yarn add wstcp-server
bun add wstcp-server
```

Provides the command `wstcp-server`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-03-31 |
| First published | 2019-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 9.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Peter Kuma |
| Maintainers | peterkuma |
| Keywords | websocket, tcp, forwarding, tunnel, server |

## Links

- npm: https://www.npmjs.com/package/wstcp-server
- npm.io page: https://npm.io/package/wstcp-server

## Dependencies (5)

- [wstcp](https://npm.io/package/wstcp.md) ^1.0.7
- [bunyan](https://npm.io/package/bunyan.md) ^1.8.1
- [lodash](https://npm.io/package/lodash.md) ^4.12.0
- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [bunyan-prettystream](https://npm.io/package/bunyan-prettystream.md) ^0.1.3

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2024-03-31
- 1.0.0 — 2019-11-05

## README

wstcp-server
============

WebSocket TCP forwarding command-line server.

[wstcp](https://github.com/peterkuma/wstcp)
is a client and server implementation of TCP forwarding over WebSocket.
wstcp supports local and remote port forwarding, similar to OpenSSH.

Also see [wstcp-client](https://github.com/peterkuma/wstcp-client).

![Diagram](https://raw.githubusercontent.com/peterkuma/wstcp/master/diagram.png)

Install
-------

    npm install wstcp-server

`wstcp-server` program will be installed in the bin directory.

### Windows

Install as a Windows service:

    npm install -g node-windows
    npm run winservice_install

Uninstall
---------

### Windows

Uninstall the Windows service:

    npm run winservice_uninstall

Usage
-----

Run from console:

    wstcp-server config.json

where `config.json` is a config file (see below).

Example
-------

    {
      "port": 10000,
      "log": "wstcp-server.log",
      "clients": {
        "client-1": {
          "key": "1234",
          "port": 10001,
          "remote": "true"
        },
        "client-2": {
          "key": "1234",
          "port": 10002,
          "remote": "true"
        }
      }
    }

will start listening on port 10000 for WebSocket connections from clients,
authenticated as `client-1` or `client-2` with key `1234`.
Incoming TCP connections on port 10001 will be forwarded to `client-1`,
and incoming TCP connections on port 10002 will be forwarded to `client-2`.

Configuration
-------------

- `port`: WebSocket port to listen on.
- `hostname`: WebSocket hostname to listen on (default: `::`).
- `log`: Log file path (default: *none*).
    Relative paths are resolved relative to the config file.
- `client`: List of clients.
    - *key*: Client name.
    - *value*:
        - `key`: Client authentication key.
        - `port`: TCP forwarding port.
        - `remote`: Remote TCP forwarding (default: `false`).

Remote forwarding (`remote: true`) means wstcp-client listens for incoming
TCP connections and forwards them to wstcp-server. Local forwarding
(`remote: false`) means incoming TCP connections are forwarded from wstcp-server
to wstcp-client.

SSL
---

wstcp-server does not support SSL (wss), but one can use nginx as a HTTPS
proxy. For example, this nginx configuration will pass `wss://` requests
to a local wstcp-server instance at `ws://localhost:10000`.

```
location / {
	proxy_pass http://localhost:10000;
	proxy_http_version 1.1;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "upgrade";
}
```

Changelog
---------

### 1.0.1 (2024-03-31)

- Require latest version of wstcp.

### 1.0.0 (2021-07-10)

- Initial release.

License
-------

[MIT](LICENSE.md)

---
_Source: https://npm.io/package/wstcp-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
