From 7dddf07da49f5c245caa0bfd0fc58615bc4815cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=B4=E5=A8=83=E9=85=B1?= Date: Wed, 26 Jul 2017 10:20:17 +0800 Subject: [PATCH] fix overhead --- shadowsocks/obfsplugin/obfs_tls.py | 2 ++ shadowsocks/tcprelay.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/shadowsocks/obfsplugin/obfs_tls.py b/shadowsocks/obfsplugin/obfs_tls.py index 73199ab..7f1f233 100644 --- a/shadowsocks/obfsplugin/obfs_tls.py +++ b/shadowsocks/obfsplugin/obfs_tls.py @@ -193,6 +193,8 @@ class tls_ticket_auth(plain.plain): def decode_error_return(self, buf): self.handshake_status = -1 + if self.overhead > 0: + self.server_info.overhead -= self.overhead self.overhead = 0 if self.method in ['tls1.2_ticket_auth', 'tls1.2_ticket_fastauth']: return (b'E'*2048, False, False) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 506e1ce..78b3257 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -858,6 +858,10 @@ class TCPRelayHandler(object): if self._encrypt_correct: try: obfs_decode = self._obfs.server_decode(data) + if self._stage == STAGE_INIT: + self._overhead = self._obfs.get_overhead(self._is_local) + self._protocol.get_overhead(self._is_local) + server_info = self._protocol.get_server_info() + server_info.overhead = self._overhead except Exception as e: shell.print_exception(e) logging.error("exception from %s:%d" % (self._client_address[0], self._client_address[1]))