Skip to main content

wstan

PyPI PyPI

Tunneling TCP/UDP connections in WebSocket to circumvent firewall. It's light and can run on some PaaS (SSL supported).

User-Agent(SOCKS/HTTP) <--> (wstan)Client <-- Internet --> (wstan)Server <--> Target

Features

  • Encryption
  • Proxy support (using HTTP CONNECT; test yours)
  • Display error message in browser (plain HTTP only)
  • SOCKSv4/v5 and HTTP (slower) in the same port

WARN: Do not rely it on security when not using SSL

Usage

usage: wstan [-h] [-g] [-c | -s] [-d] [-z] [-i INI] [-y PROXY] [-a ADDR] [-p PORT] [--pool-size POOL_SIZE]
             [--pool-max-idle POOL_MAX_IDLE] [-t TUN_ADDR] [-r TUN_PORT] [--x-forward]
             [uri] [key]

positional arguments:
  uri                   URI of server
  key                   password or generated key

options:
  -h, --help            show this help message and exit
  -g, --gen-key         generate a 16 byte base64 key and exit
  -c, --client          run as client (default, also act as SOCKS/HTTP server)
  -s, --server          run as server
  -d, --debug
  -z, --compatible      useful when server is behind WS proxy
  -i INI, --ini INI     load config file

client options:
  -y PROXY, --proxy PROXY
                        use HTTP proxy to connect to wstan server (host:port)
  -a ADDR, --addr ADDR  listen address of SOCKS/HTTP server (defaults localhost)
  -p PORT, --port PORT  listen port of SOCKS/HTTP server (defaults 1080)
  --pool-size POOL_SIZE
                        max size of connection pool (defaults 16)
  --pool-max-idle POOL_MAX_IDLE
                        max idle timeout of connection pool in sec (defaults 300)

server options:
  -t TUN_ADDR, --tun-addr TUN_ADDR
                        listen address of server, overrides URI
  -r TUN_PORT, --tun-port TUN_PORT
                        listen port of server, overrides URI
  --x-forward           use X-Forwarded-For as client IP address when behind proxy

Setup:

# generate a key using "wstan -g"
wstan ws://yourserver.com KEY -s  # server
wstan ws://yourserver.com KEY  # client
# a proxy server is listening at localhost:1080 now (at client side)

Setup for OpenShift v3:

  1. Generate a key
  2. Pull Docker image and set environment variable KEY
  3. Add default route
  4. http://xxx.openshiftapps.com will return 200 if everything goes right; Run client wstan ws://xxx.openshiftapps.com KEY

It's a reinvented wheel

Details

Original Goal: make active probing against server side more difficult while still keeping low latency of connection establishment and being stateless (inspired by shadowsocks).

Weakness: can't prevent MITM attack; client can't detect fake server (may receive garbage data); replay attack detection may fail

Tech Detail:

  • request frame has HMAC and timestamp (data frame has nothing), and all frames are encrypted using AES-128-CTR
  • server will save encryption nonce and timestamp when receiving valid request (to detect replay attack)
  • the first request frame will be encoded into URI of WS handshake (to achieve low latency)
  • it has a connection pool

Release files for wstan 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wstan 0.5.1
File Size Uploaded
wstan-0.5.1.tar.gz 382.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wstan 0.5.1
File Interpreter ABI Platform
wstan-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 779.3 kB

Release files / wstan-0.5.1.tar.gz

Download URL wstan-0.5.1.tar.gz
Size 382.9 kB
Tags Source
SHA-256 checksum
How to use checksums
64b7ef0e5ab16801c2b34224cc9ed2d8c0cde6bda4f9748df33c8b011131bed5
BLAKE2b-256 checksum
How to use checksums
5761ffba7ca31bd05499409d8b5b29ef07dd127d72c7f0268dc6d229f962209c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / wstan-0.5.1-py3-none-any.whl

Download URL wstan-0.5.1-py3-none-any.whl
Size 396.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
371084aab3bda1c87a0ec49d7fbab683e6bd5439fde0e64981d3cccbf88a44c0
BLAKE2b-256 checksum
How to use checksums
60c7436c8768560d7491b9f9dd9ea6154cb7f7109feb26b2609bffec41519323
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.1

1 release file

0.4

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3

1 release file

0.2.1

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page