Skip to content
This repository has been archived by the owner on Jul 3, 2022. It is now read-only.
Aber edited this page Sep 8, 2021 · 24 revisions

Install

需在版本大于 3.7 的 Python 上安装。Windows/MacOS/Linux 均可。

pip install -U websocks --user

或者直接从 Github 上安装最新版本(不稳定)

pip install -U git+https://github.com/abersheeran/websocks --user

如果你需要使用带可视化界面的客户端,需要额外安装:PySimpleGUIWx

Command

Client

> websocks client --help
Usage: websocks client [OPTIONS] [ADDRESS]...

  Create a http server as websocks client

Options:
  -P, --proxy-policy [AUTO|PROXY|DIRECT|BLACK|WHITE]
                                  AUTO: auto judge; PROXY: always proxy;
                                  DIRECT: always direct; BLACK: only proxy
                                  black rules;

  -T, --tcp-server TEXT           websocket url with username and password
                                  [required]

  -R, --rulefile FILE             rule file absolute path
  -NS, --nameserver TEXT          set dns servers
  --help                          Show this message and exit.
  • -P: 决定 websocks client 的代理策略,默认为 AUTO。PROXY 模式为全部代理,此情况下任何经过 websocks client 的网络流量都会通过远程服务器转发。AUTO 模式则更适合普通上网需求,请参考代理策略

  • -R 除 websocks 默认的黑白名单文件外,还可以指定自己的代理规则文件以适应不同网络环境。一般来说,不需要使用此选项。

  • -T 指定远程服务器,格式为 [ws|wss]://USERNAME:PASSWORD@HOST:PORT(/PATH),一般来说 /PATH 参数可忽略,但若把 websocks 服务端部署在指定的 URL 下,则可使用此参数。

  • -NS 此选项可令客户端使用指定 DNS 服务器用于解析域名,默认使用当前系统所使用的 DNS 服务器。

除上述选项外,还有命令行参数 ADDRESS,由于 websocks client 默认监听 127.0.0.1:3128,在某些情况下可能不适用,可以使用此参数更改监听的地址。例如 websocks client -S wss://USERNAME:PASSWORD@HOST:PORT 0.0.0.0 9999

Server

> websocks server --help
Usage: websocks server [OPTIONS] [ADDRESS]...

Options:
  -U, --userpass TEXT  USERNAME:PASSWORD  [required]
  --help               Show this message and exit.
  • -U 指定服务器允许的用户名密码。允许多次使用以启用多个用户:websocks server -U USERNAME:PASSWORD -U OTHERUSER:PASSWORD

websocks client 相同,websocks server 也允许使用 ADDRESS 参数更改默认的监听地址 0.0.0.0 8765

Check

> websocks check --help
Usage: websocks check [OPTIONS] HOST

  Check whether the host needs pass proxy

Options:
  -R, --rulefile FILE  rule file absolute path
  --help               Show this message and exit.

Check 命令可以帮助你测试代理规则文件对某一个域名的判断。例如 websocks check baidu.com

Download

> websocks download --help
Usage: websocks download [OPTIONS] [gfw|white]...

  Download rule file in local

Options:
  --help  Show this message and exit.

Download 命令用于更新 GFWList 仓库中的黑名单,以及 websocks 仓库中的白名单。

Security

应使用 nginx、caddy 等反向代理服务器进行反向代理(使用 WebSocket 的反向代理配置即可),并配置 TLS 证书

TODO

客户端:

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

  • 提供 web 界面用于管理

服务端:

  • 支持流量统计.

  • 提供 web 界面用于管理

Clone this wiki locally