Browse Source

refine user transfer

dev
破娃酱 8 years ago
parent
commit
4048abaeff
  1. 6
      shadowsocks/tcprelay.py
  2. 6
      shadowsocks/udprelay.py

6
shadowsocks/tcprelay.py

@ -1108,7 +1108,8 @@ class TCPRelay(object):
else: else:
if user not in self.server_user_transfer_ul: if user not in self.server_user_transfer_ul:
self.server_user_transfer_ul[user] = 0 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): def add_transfer_d(self, user, transfer):
if user is None: if user is None:
@ -1116,7 +1117,8 @@ class TCPRelay(object):
else: else:
if user not in self.server_user_transfer_dl: if user not in self.server_user_transfer_dl:
self.server_user_transfer_dl[user] = 0 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): def update_stat(self, port, stat_dict, val):
newval = stat_dict.get(0, 0) + val newval = stat_dict.get(0, 0) + val

6
shadowsocks/udprelay.py

@ -1008,7 +1008,8 @@ class UDPRelay(object):
else: else:
if user not in self.server_user_transfer_ul: if user not in self.server_user_transfer_ul:
self.server_user_transfer_ul[user] = 0 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): def add_transfer_d(self, user, transfer):
if user is None: if user is None:
@ -1016,7 +1017,8 @@ class UDPRelay(object):
else: else:
if user not in self.server_user_transfer_dl: if user not in self.server_user_transfer_dl:
self.server_user_transfer_dl[user] = 0 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): def _close_client_pair(self, client_pair):
client, uid = client_pair client, uid = client_pair

Loading…
Cancel
Save