Skip to main content

No project description provided

Project description

SOCKS5/HTTP WebSocket 代理

基于 WebSocket 的高性能代理工具,支持 SOCKS5 和 HTTP CONNECT 协议,用于网络穿透和流量转发。

原理

本地应用 <--SOCKS5/HTTP--> 客户端 <--WebSocket--> 服务端 <--TCP--> 目标服务器
  • 客户端:在本地启动代理服务器(支持 SOCKS5 和 HTTP CONNECT),将流量通过 WebSocket 转发到远程服务端
  • 服务端:接收 WebSocket 连接,代理访问目标服务器
  • 单端口自动识别协议类型(SOCKS5 / HTTP CONNECT)
  • 使用 WebSocket 连接池,提升并发性能
  • 通过密码和消息签名保证连接安全

与v2ray性能对比

同一服务器节点对比, 参考 speed_test 目录

安装

pip install wsocks

使用方法

1. 服务端配置

编辑 config_server.json

{
  "server": {
    "host": "0.0.0.0",
    "port": 8888,
    "path": "/ws",
    "password": "your-password-here"
  },
  "log_level": "INFO"
}

2. 启动服务端

在有公网 IP 的服务器上运行:

wsocks_server -c config_server.json

3. 客户端配置

编辑 config_client.json

{
  "server": {
    "url": "ws://your-server.com:8888/ws",
    "password": "your-password-here",
    "compression": false,
    "ws_pool_size": 8,
    "heartbeat_enabled": true,
    "heartbeat_min": 20,
    "heartbeat_max": 50
  },
  "local": {
    "host": "127.0.0.1",
    "port": 1080
  },
  "udp": {
    "enabled": false,
    "timeout": 60
  },
  "log_level": "INFO"
}

推荐自行配置使用wss

4. 启动客户端

wsocks_client -c config_client.json

5. 配置代理

支持两种代理方式(同一端口自动识别):

SOCKS5 代理

  • 服务器:127.0.0.1
  • 端口:1080

HTTP 代理

  • 服务器:http://127.0.0.1:1080

配置参数说明

服务端参数

参数 说明 默认值
host 监听地址 0.0.0.0
port 监听端口 8888
password 连接密码 -
timeout 连接超时(秒) 30
max_connections 最大并发连接数 1000

客户端参数

参数 说明 默认值
server.url 服务端地址 -
server.password 连接密码 -
server.compression 启用数据压缩 false
server.ws_pool_size WebSocket 连接池大小 8
server.heartbeat_enabled 启用应用层随机心跳 true
server.heartbeat_min 心跳最小间隔(秒) 20
server.heartbeat_max 心跳最大间隔(秒) 50
local.port 本地代理端口(支持 SOCKS5 / HTTP) 1080
udp.enabled 启用 UDP 转发(SOCKS5 UDP Associate) false
udp.timeout UDP 会话超时时间(秒) 60

常见问题

无法连接服务端

  • 检查服务端是否运行
  • 确认防火墙端口已开放
  • 验证密码是否一致

上传速度慢

  • 增加 ws_pool_size(建议 8-32)

连接频繁断开

  • 调整 ping_intervalping_timeout
  • 增加服务端 timeout

安全建议

  • 修改默认密码,使用强密码
  • 务必使用 WSS(WebSocket over TLS)
  • 配置防火墙限制访问 IP

许可证

MIT License

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

wsocks-1.0.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

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

wsocks-1.0.0-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file wsocks-1.0.0.tar.gz.

File metadata

  • Download URL: wsocks-1.0.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.20 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for wsocks-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c61a2dd6f260e2a6872d2def3d5e86f0edc3d682253d6c344b6a5bccb700e073
MD5 d20cf58fa14aca5c3891f4516c7a7ce0
BLAKE2b-256 3523e8bc04499576b2d359d7ebbccf14017517703a374707127dda82bffb3439

See more details on using hashes here.

File details

Details for the file wsocks-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: wsocks-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.20 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for wsocks-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72bfec23935f7dcca4818bff0efdda5600cccc9fff9a0f47391e4397d8e39c38
MD5 ed70419d4db48741f9f22dff597a4af7
BLAKE2b-256 fc1a25d24f0dc33b336ebdb9818dca80b77a20b9ffd6c11f9af6a76710dd5e39

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