diff --git a/mujson_mgr.py b/mujson_mgr.py index cda7ea7..d986ca5 100644 --- a/mujson_mgr.py +++ b/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 diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 859e92c..1349f62 100644 --- a/shadowsocks/tcprelay.py +++ b/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