Browse Source

fix connections stat

mgr help info
dev
BreakWa11 9 years ago
parent
commit
3d1d38aa0f
  1. 1
      mujson_mgr.py
  2. 7
      shadowsocks/tcprelay.py

1
mujson_mgr.py

@ -147,6 +147,7 @@ Options:
-O PROTOCOL protocol plugin, default: auth_sha1_v2_compatible
-o OBFS obfs plugin, default: tls1.2_ticket_auth_compatible
-t TRANSFER max transfer for G bytes, default: 1048576, can be float point number
-f FORBID set forbidden ports. Example (ban 1~79 and 81~100): -f "1-79,81-100"
General options:
-h, --help show this help message and exit

7
shadowsocks/tcprelay.py

@ -994,14 +994,11 @@ class TCPRelay(object):
self._stat_counter[self._listen_port] = {}
newval = self._stat_counter[self._listen_port].get(local_addr, 0) + val
logging.debug('port %d addr %s connections %d' % (self._listen_port, local_addr, newval))
self._stat_counter[self._listen_port][local_addr] = newval
self.update_stat(self._listen_port, self._stat_counter[self._listen_port], val)
if newval <= 0:
if local_addr in self._stat_counter[self._listen_port]:
del self._stat_counter[self._listen_port][local_addr]
if len(self._stat_counter[self._listen_port]) == 0:
del self._stat_counter[self._listen_port]
else:
self._stat_counter[self._listen_port][local_addr] = newval
self.update_stat(self._listen_port, self._stat_counter[self._listen_port], val)
newval = self._stat_counter.get(0, 0) + val
self._stat_counter[0] = newval

Loading…
Cancel
Save