Giter Site home page Giter Site logo

aioshadowsocks's Introduction

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) {}
}

aioshadowsocks's People

Contributors

dependabot-preview[bot] avatar ehco1996 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aioshadowsocks's Issues

关于节点的默认udp转发状态?

使用aioshadowsocks创建的节点无法正常使用clubhouse,具体表现为进入房间后无法收发语音;是不是默认情况节点的UDP转发没开?感觉可能与UDP有关。
测试了下,在客户端关闭udp转发就正常了,请问下如何配置开启udp转发?

另外看到这个Ehco1996/django-sspanel#470
是不是就是我说的这个功能?希望能早点看到实现。

aioshadowsocks对接出现问题

QQ截图20190923073057.png
QQ截图20190923073107.png

作者大大这个是在那块出问题了

现在的Django-sspanel不支持这个shadowsocksr-deprecated分支后端了吗

很久没搞了 感觉变化很大。

带宽占用问题

在没有人使用节点的情况下会出现高带宽占用的问题,软件会把整个服务器的下行带宽占满,直到手动kill才会停止
QQ图片20200816170214

arm版本

您好,能不能麻烦给一个arm的docker镜像?

这个目前同时支持ss/ssr吗?

还有就是目前支持那些东西了,有API开放了吗?如果我拿来做panel的后端,功能都能实现了吗?API完善了吗...😂😂😂

aioss run_ss_server 启动错误

root@123:/usr# aioss run_ss_server
正在创建<Model: User>内存数据库
Start grpc Server on 127.0.0.1:5000
flush_metrics_to_remote error: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
sync error: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
flush_metrics_to_remote error: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
sync error: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE
flush_metrics_to_remote error: [Errno 104] Connection reset by peer

aioss方式启动的时候,好像启动不起来?

启动就这个问题,我其实不太了解python,只是简单的了解,这个如何解决?

D:\Desktop\新建文件夹 (2)\aioshadowsocks>aioss run_ss_server
[INFO]2021-01-16 22:30:04,173 _init_memory_db line:81 正在创建<Model: User>内存数据库
Traceback (most recent call last):
File "c:\users\administrator\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main
return run_code(code, main_globals, None,
File "c:\users\administrator\appdata\local\programs\python\python38\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scripts\aioss.exe_main
.py", line 7, in
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\shadowsocks_main
.py", line 7, in main
fire.Fire(App)
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\fire\core.py", line 138, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\fire\core.py", line 463, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\fire\core.py", line 672, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\shadowsocks\app.py", line 144, in run_ss_server
self._prepare()
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\shadowsocks\app.py", line 97, in _prepare
self.loop.add_signal_handler(signal.SIGTERM, self._shutdown)
File "c:\users\administrator\appdata\local\programs\python\python38\lib\asyncio\events.py", line 536, in add_signal_handler
raise NotImplementedError
NotImplementedError

现在翻不出去了?还是怎么回事?(2021/1/18)出现 <class 'asyncio.exceptions.TimeoutError'>

一切正常配置面板并且成功启动,手机也正确链接上节点,但是好像翻不出,在同一台服务器上搭建的shadowsocks可以正常过墙。
主要出现的错误就是aioshadowsocks | [WARNING]2021-01-18 03:22:55,184 _handle_stage_init line:142 connection failed, <class 'asyncio.exceptions.TimeoutError'> e: play.googleapis.com:443
能及时告知一下是怎么回事吗,最近研究你的项目几天了,对你的项目也有大致的了解了。

CentOS 7 安装失败

ERROR: Could not find a version that satisfies the requirement aioshadowsocks (from versions: none)

自编译安装Python 3.10.4 / 自带Python 2.7.5; pip3 22.0.4

客户端连接上就报错了

docker 版本没问题 但是普通版客户端连接上就报错了

TIM图片20191022025952

vultr的centos小鸡

yum install -y wget
yum install -y python3-devel
yum install -y git
systemctl stop firewalld.service
systemctl disable firewalld.service
export SS_API_ENDPOINT="http://防偷窥/api/user_ss_config/1/?token=admin"
wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
git clone https://github.com/Ehco1996/aioshadowsocks.git
cd aioshadowsocks
pip3 install -r requirements.txt
python3 server.py

【讨论】去除 gRPC 改用 rpc.py

因为工作原因前段时间也用了 gRPC,感觉在 Python3 里很不好用,各种问题。然后自己写了一个 RPC 框架代替 gRPC 在 Python3 里用。看了一眼你的依赖,里面有 httpx,改用 rpc.py 也不会额外增加大量依赖。https://github.com/abersheeran/rpc.py

这个 issue 可以当作是推广,毕竟我确实发自己项目了。但更多是看了你的源代码,感觉 aioshadowsocks 的 gRPC 部分太冗余、繁琐了。

如有冒犯,可删除此 Issue。

服务器最小资源请求

请问服务器的最小资源请求是多少?

chacha20-ietf-poly1305 可能 1C 512M 的带不动,但是可以启动,几个小时后就把整个服务器搞垮。

作者大大可以排查一下是不是有内存泄漏。

docker启动时报错

ehco | 2022-09-03T09:09:57.187Z fatal invalid listen:

请问下,就在SS启动的视频那我看了好多遍,始终没太弄懂这启动的顺序是怎么样的?

如何支持NAT1

请问怎么在配置文档可以配置NAT1
自己之前配置的ss-libev版本可以支持NAT1 但是aio版无法使用NAT1,只有NAT4

用户数据过多peewee无法插入

生成了一批用户,好像大于999提示sqlite3.OperationalError: too many SQL variables

[ERROR]2021-03-28 02:10:09,142 default_exception_handler line:1703 Task exception was never retrieved
future: <Task finished name='Task-1' coro=<ProxyMan.start_and_check_ss_server() done, defined at /root/aioshadowsocks/shadowsocks/proxyman.py:95> exception=OperationalError('too many SQL variables')>
Traceback (most recent call last):
  File "/usr/local/python3/lib/python3.8/site-packages/peewee.py", line 3144, in execute_sql
    cursor.execute(sql, params or ())
sqlite3.OperationalError: too many SQL variables

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.