From f296751def517160174975a604a7f5faf2f4382b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=B4=E5=A8=83=E9=85=B1?= Date: Tue, 14 Feb 2017 21:36:38 +0800 Subject: [PATCH] bandwidth limit of the user --- config.json | 1 + shadowsocks/eventloop.py | 2 +- shadowsocks/tcprelay.py | 42 ++++++++++++++++++++++++++++++++-------- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/config.json b/config.json index 0d0d13e..ef4c79e 100644 --- a/config.json +++ b/config.json @@ -14,6 +14,7 @@ "obfs": "tls1.2_ticket_auth_compatible", "obfs_param": "", "speed_limit_per_con": 0, + "speed_limit_per_user": 0, "dns_ipv6": false, "connect_verbose_info": 0, diff --git a/shadowsocks/eventloop.py b/shadowsocks/eventloop.py index e36f858..6e2f22f 100644 --- a/shadowsocks/eventloop.py +++ b/shadowsocks/eventloop.py @@ -53,7 +53,7 @@ EVENT_NAMES = { } # we check timeouts every TIMEOUT_PRECISION seconds -TIMEOUT_PRECISION = 5 +TIMEOUT_PRECISION = 2 class KqueueLoop(object): diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 7f2d3c9..fcaadb0 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -133,6 +133,7 @@ class TCPRelayHandler(object): self._client_address = local_sock.getpeername()[:2] self._accept_address = local_sock.getsockname()[:2] self._user = None + self._user_id = server._listen_port # TCP Relay works as either sslocal or ssserver # if is_local, this is sslocal @@ -238,6 +239,7 @@ class TCPRelayHandler(object): def _update_user(self, user): self._user = user + self._user_id = struct.unpack('