From 4048abaeff828fd47ea8b6f65324d8e384f19257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=B4=E5=A8=83=E9=85=B1?= Date: Fri, 13 Jan 2017 21:52:17 +0800 Subject: [PATCH] refine user transfer --- shadowsocks/tcprelay.py | 6 ++++-- shadowsocks/udprelay.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index abbb966..da0565c 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -1108,7 +1108,8 @@ class TCPRelay(object): else: if user not in self.server_user_transfer_ul: self.server_user_transfer_ul[user] = 0 - self.server_user_transfer_ul[user] += transfer + self.server_user_transfer_ul[user] += transfer + self.server_transfer_ul + self.server_transfer_ul = 0 def add_transfer_d(self, user, transfer): if user is None: @@ -1116,7 +1117,8 @@ class TCPRelay(object): else: if user not in self.server_user_transfer_dl: self.server_user_transfer_dl[user] = 0 - self.server_user_transfer_dl[user] += transfer + self.server_user_transfer_dl[user] += transfer + self.server_transfer_dl + self.server_transfer_dl = 0 def update_stat(self, port, stat_dict, val): newval = stat_dict.get(0, 0) + val diff --git a/shadowsocks/udprelay.py b/shadowsocks/udprelay.py index 994fdee..9ee5ccf 100644 --- a/shadowsocks/udprelay.py +++ b/shadowsocks/udprelay.py @@ -1008,7 +1008,8 @@ class UDPRelay(object): else: if user not in self.server_user_transfer_ul: self.server_user_transfer_ul[user] = 0 - self.server_user_transfer_ul[user] += transfer + self.server_user_transfer_ul[user] += transfer + self.server_transfer_ul + self.server_transfer_ul = 0 def add_transfer_d(self, user, transfer): if user is None: @@ -1016,7 +1017,8 @@ class UDPRelay(object): else: if user not in self.server_user_transfer_dl: self.server_user_transfer_dl[user] = 0 - self.server_user_transfer_dl[user] += transfer + self.server_user_transfer_dl[user] += transfer + self.server_transfer_dl + self.server_transfer_dl = 0 def _close_client_pair(self, client_pair): client, uid = client_pair