Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iximiuz/wsmux
wsmux - a simple WebSocket tunnel server
https://github.com/iximiuz/wsmux
go golang port-forwarding tunnel websocket
Last synced: 3 months ago
JSON representation
wsmux - a simple WebSocket tunnel server
- Host: GitHub
- URL: https://github.com/iximiuz/wsmux
- Owner: iximiuz
- License: apache-2.0
- Created: 2024-03-03T13:57:59.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-09-15T17:31:59.000Z (5 months ago)
- Last Synced: 2024-09-16T17:12:51.267Z (5 months ago)
- Topics: go, golang, port-forwarding, tunnel, websocket
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 18
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wsmux - a simple WebSocket tunnel server
Start an HTTP server that accepts incoming WebSocket connections and bidirectionally forwards data between the established connection and a TCP destination reachable from the server.
Define the destination address at runtime with an elegant protocol:```
ws:///tunnels/${base64(':')}'
```The primary goal of this project is to provide a handy library.
The `wsmux` binary was added for demonstration purposes (but can potentially be used as a standalone tool as well).Usage:
```sh
# Server - listen for incoming WebSocket connections and tunnel ports
wsmux serve [-addr [host]:]# Client - forward local port to remote destination via wsmux server
wsmux proxy -server -local-port [-local-host ] -remote-port [-remote-host ]
```Example:
```sh
# On the server, prepare the targets (e.g., nginx & httpbin)
$ docker run --rm -p 127.0.0.1:3000:80 nginx:alpine
$ docker run --rm -p 127.0.0.1:5000:80 kennethreitz/httpbin# On the server again, start the wsmux server
$ wsmux serve -addr 0.0.0.0:8080
Starting wsmux server on 0.0.0.0:8080# On the client, start the wsmux clients to forward local ports to the targets
$ wsmux proxy -server ws://0.0.0.0:8080 -local-port 3001 -remote-port 3000
Starting wsmux client on localhost:3001 -> localhost:3000 via ws://0.0.0.0:8080$ wsmux proxy -server ws://0.0.0.0:8080 -local-port 5001 -remote-port 5000
Starting wsmux client on localhost:5001 -> localhost:5000 via ws://0.0.0.0:8080# Now, you can access the nginx server on http://localhost:3001
$ curl http://localhost:3001Welcome to nginx!
...# ...and httpbin on http://localhost:5001
$ curl localhost:5001
httpbin.org
...
```