Skip to main content

aioshadowsocks

用 asyncio 重写 shadowsocks

Publish Docker

视频安装教程

  • 面板视频安装教程: 地址

  • 后端对接视频教程: 地址

  • 隧道对接视频教程: 地址

使用

  • 安装
pip install aioshadowsocks
  • 多用户配置

aioshadowsocks 将json作为配置文件, 会读取当前目录下 userconfigs.json 作为默认的配置文件

{
    "users": [
        {
            "user_id": 1,
            "port": 2345,
            "method": "none",
            "password": "hellotheworld1",
            "transfer": 104857600,
            "speed_limit": 0
        },
        {
            "user_id": 2,
            "port": 2346,
            "method": "chacha20-ietf-poly1305",
            "password": "hellotheworld2",
            "transfer": 104857600,
            "speed_limit": 384000
        }
    ]
}

同时也支持从http服务器读取配置文件,这时需要注入环境变量 SS_API_ENDPOINT 作为读取配置的api地址

  • 注入环境变量

export SS_API_ENDPOINT="https://xxx/com"

  • 启动ss服务器
aioss run_ss_server

Docker Version

  1. install docker
curl -sSL https://get.docker.com/ | sh
  1. install docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  1. apply executable permissions
sudo chmod +x /usr/local/bin/docker-compose
  1. run server
docker-compose up

为什么要重写shadowsocks

主要想通过这个项目的推进来深入了解 asyncio

另外我的一个项目: django-sspanel 依赖 shadowsocksr

但该项目已经停止开发了,所以决定重新造个轮子

主要功能

  • tcp/udp 代理
  • 流量统计
  • 速率控制
  • 开放了grpc接口(类似ss-manager)
  • 单端口多用户(利用AEAD加密在不破坏协议的情况下实现)
  • prometheus/grafana metrics监控 (dashboard在项目的static/grafana/文件夹下)

监控dashboard

性能测试

Shadowsocks本身是一个IO密集行的应用,但是由于加入了AEAD加密,使得SS本身变成了CPU密集行的应用 而Python本身是不太适合CPU密集的场景的,所以在AEAD模式中的表现不佳 PS: 当然,其实是我代码写的烂,python不背锅

  • Steam-Cipher-None(不加密 高IO)

  • AEAD-Cipher-CHACHA-20(加密 高CPU)

rpc proto

syntax = "proto3";

package aioshadowsocks;

// REQ
message UserIdReq { int32 user_id = 1; }
message PortReq { int32 port = 1; }

message UserReq {
  int32 user_id = 1;
  int32 port = 2;
  string method = 3;
  string password = 4;
  bool enable = 5;
}

// RES
message Empty {}

message User {
  int32 user_id = 1;
  int32 port = 2;
  string method = 3;
  string password = 4;
  bool enable = 5;
  int32 speed_limit = 6;
  int32 access_order = 7;
  bool need_sync = 8;
  repeated string ip_list = 9;
  int32 tcp_conn_num = 10;
  int64 upload_traffic = 11;
  int64 download_traffic = 12;
}

// service
service ss {
  rpc CreateUser(UserReq) returns (User) {}
  rpc UpdateUser(UserReq) returns (User) {}
  rpc GetUser(UserIdReq) returns (User) {}
  rpc DeleteUser(UserIdReq) returns (Empty) {}
}

Metadata

Release files for aioshadowsocks 0.1.8

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

Source distribution (sdist)

Source distribution for aioshadowsocks 0.1.8
File Size Uploaded Provenance Actions
aioshadowsocks-0.1.8.tar.gz 38.7 kB Without provenance Details for aioshadowsocks-0.1.8.tar.gz

Built distribution (wheel)

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

Total release size: 92.1 kB

Release files / aioshadowsocks-0.1.8.tar.gz

Download URL aioshadowsocks-0.1.8.tar.gz
Size 38.7 kB
Tags Source
SHA-256 checksum
How to use checksums
44ec1f43edbc60895cb8169b1a0fede0763d2ffd77e94255506e55da1f7dfdba
BLAKE2b-256 checksum
How to use checksums
c730f74829a7aef3dc0f67e3ca2eace1f7dec0cb7231464e98af52cb1750c0ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.8 CPython/3.9.2 Darwin/21.1.0

Release files / aioshadowsocks-0.1.8-py3-none-any.whl

Download URL aioshadowsocks-0.1.8-py3-none-any.whl
Size 53.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62cdaef404036dae333f29101c2e2c4d66306748b5b35b535e124eb13089e91e
BLAKE2b-256 checksum
How to use checksums
89ee84002d857646c7ec7a13aef53c9591f6438c67f287f79e43c0cb7e79cc6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.8 CPython/3.9.2 Darwin/21.1.0

Security for aioshadowsocks 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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