Skip to main content

No project description provided

Project description

SOCKS5-WebSocket 代理

基于 WebSocket 的 SOCKS5 代理工具,用于网络穿透和流量转发。

原理

本地应用 <--SOCKS5--> 客户端 <--WebSocket--> 服务端 <--TCP--> 目标服务器
  • 客户端:在本地启动 SOCKS5 服务器,将流量通过 WebSocket 转发到远程服务端
  • 服务端:接收 WebSocket 连接,代理访问目标服务器
  • 使用 WebSocket 连接池(默认 8 个连接)提升并发性能
  • 通过密码和消息签名保证连接安全

安装

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"
  },
  "local": {
    "host": "127.0.0.1",
    "port": 1080
  },
  "log_level": "INFO"
}

4. 启动客户端

wsocks_client -c config_client.json

5. 配置代理

在浏览器或应用中设置 SOCKS5 代理:

  • 服务器:127.0.0.1
  • 端口:1080

配置参数说明

服务端参数

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

客户端参数

参数 说明 默认值
server.url 服务端地址 -
server.password 连接密码 -
server.ws_pool_size WebSocket 连接池大小 8
local.port 本地 SOCKS5 端口 1080

常见问题

无法连接服务端

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

上传速度慢

  • 增加 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

wsocks-0.0.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wsocks-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.3 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-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a23133ed76ab02f688066c910da4713f6b3b17b4b39758aa51677896c15e1fd9
MD5 eb604c3b79faa5fc4039fcf49f01a46e
BLAKE2b-256 9d9bc1fc0e061804fa890d1c5d58b2cbbb34a9910391cb26e0679860c3b83a19

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