Skip to main content

A websocket-based socks5 proxy.

Project description

websocks

通过 websocket 转发本地 socks5 代理服务器接收到的 TCP 数据。

协议设计

实现了使用 Websocket 进行网络穿透(续)中的设计。

使用说明

websocks 分两个部分: clientserver

首先需要使用 pip install websocks 安装。

然后可以使用启动命令:

  • 启动服务端使用: websocks server -U USERNAME:PASSWORD 127.0.0.1 8765

  • 启动客户端使用: websocks client -s USERNAME:PASSWORD@HOST:PORT 0.0.0.0 3128

在启动服务端后,应使用 nginx 等反向代理服务器进行反向代理,并配置 SSL 证书(可参考Wiki)。如果能够配置 CDN 代理 websocket 连接,那是最好的。

在启动客户端后,可使用 proxifier 等工具将本地 TCP 走 websocks 的代理。websocks 并不会愚蠢的把你所有数据流量都通过远程服务器发送,所以尽可放心。

通过 docker 启动

如果你的PC/服务器上没有安装 Python3.6+,并且你并不想安装,那么可以使用 docker 去启动 websocks。

本仓库有 docker 的自动构建,点此查看:hub.docker

以下分别为服务端和客户端的 docker-compose.yml 样例。

version: '3.3'
services:
  websocks:
    image: abersheeran/websocks
    command: websocks server -U USERNAME:PASSWORD 0.0.0.0 8765
    ports:
      - "8765:8765"
    restart: always
version: '3.3'
services:
  websocks:
    image: abersheeran/websocks
    command: websocks client -s USERNAME:PASSWORD@HOST:PORT 0.0.0.0 3128
    ports:
      - "3128:3128"
    restart: always

如果你不懂 docker,也没关系,你只需要安装好 docker 与 docker-compose。然后在任意路径创建 docker-compose.yml 文件,写入如上内容并将一些需要你自己填写的部分替换。最后在同一目录下执行 docker-compose up -d,服务将能启动。

需要更新时,使用 docker-compose pull + docker-compose up -d 两条命令即可。

代理与否

由于 GFWList 是不断变化的,并且对于不同地区的网络屏蔽力度不同。所以 websocks 的代理策略由两部分组成

  1. 名单: 使用 GFWlist 作为黑名单。自身编写了一个白名单 whitelist。欢迎对白名单做出贡献

  2. 自动连接: 由上所知,不同的网络环境下,需要加速的 Host 是不同的。所以当一个 Host 不在名单中时,会首先使用本地网络环境连接,超时后则转为使用代理连接。并且会将 Host 记录在内存里,下次访问直接使用代理。重新启动 websocks 后,此记录失效。

但如果你有全部代理的需求,可以在启动客户端时指定选项-p PROXY

将要做的

客户端:

  • 支持流量、网速、延迟等统计数据

  • web 端界面用于管理客户端与服务器

服务端:

  • 支持多用户. 支持流量统计.

  • 提供 websocket 接口用于管理

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

websocks-0.1.0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

websocks-0.1.0-py2.py3-none-any.whl (12.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file websocks-0.1.0.tar.gz.

File metadata

  • Download URL: websocks-0.1.0.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for websocks-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e92b12ec084fb8b2a5de0582379b0c9cb1e17c456a8e1e3384abb08186971f41
MD5 23b87e66129d545a6a61fe15f2b8437f
BLAKE2b-256 dfa2a8f43da43ece45e6801983c0785162dceff523803bd291a4d0fcbc632f10

See more details on using hashes here.

File details

Details for the file websocks-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: websocks-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for websocks-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9663157100e94206b3331cb750efbcc21068353329310d0e60a0979fad2b8298
MD5 0d1547b1f3d625d051d135f50d1a2a58
BLAKE2b-256 7e3e1a4b6c2331e57e7123b08371955ca6c34e2772c0df87e14e3f828bdf047a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page