From 57433bccb9d5d9c6b51bd281d79b04975acfa251 Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Wed, 25 Nov 2015 16:38:08 +0800 Subject: [PATCH] fix transfer upload size calculation. avoid flow attack --- shadowsocks/tcprelay.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 93ff9ff..e9492f0 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -275,7 +275,9 @@ class TCPRelayHandler(object): if self._is_local: pass else: - if sock == self._local_sock and self._encrypt_correct and (self._obfs is not None): + if sock == self._remote_sock: + self._server.server_transfer_ul += len(data) + elif self._encrypt_correct and (self._obfs is not None): obfs_encode = self._obfs.server_encode(data) data = obfs_encode if data: @@ -614,7 +616,6 @@ class TCPRelayHandler(object): return if not data: return - self._server.server_transfer_ul += len(data) if self._stage == STAGE_STREAM: if self._is_local: if self._encryptor is not None: