From 57f55bf347951397c29ab0aedc9766e84079f753 Mon Sep 17 00:00:00 2001 From: Falseen Date: Mon, 20 Feb 2017 19:38:24 +0800 Subject: [PATCH] remove ss_header from tcprelay.py and update the "header_length" to udprelay.py 1. Remove unnecessary "add ss_header" from tcprelay.py 2. update "data[7:]" to "data[header_length:]" --- shadowsocks/tcprelay.py | 12 ------------ shadowsocks/udprelay.py | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index c83e6da..d45dbe5 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -256,12 +256,6 @@ class TCPRelayHandler(object): else: self._data_to_write_to_remote.append(data) return - if self.is_tunnel: - # add ss header to data - tunnel_remote = self.tunnel_remote - tunnel_remote_port = self.tunnel_remote_port - data = common.add_header(tunnel_remote, - tunnel_remote_port, data) if self._ota_enable_session: data = self._ota_chunk_data_gen(data) data = self._encryptor.encrypt(data) @@ -504,12 +498,6 @@ class TCPRelayHandler(object): def _handle_stage_stream(self, data): if self._is_local: - if self.is_tunnel: - # add ss header to data - tunnel_remote = self.tunnel_remote - tunnel_remote_port = self.tunnel_remote_port - data = common.add_header(tunnel_remote, - tunnel_remote_port, data) if self._ota_enable_session: data = self._ota_chunk_data_gen(data) data = self._encryptor.encrypt(data) diff --git a/shadowsocks/udprelay.py b/shadowsocks/udprelay.py index 7f405af..c603150 100644 --- a/shadowsocks/udprelay.py +++ b/shadowsocks/udprelay.py @@ -283,7 +283,7 @@ class UDPRelay(object): addrtype, dest_addr, dest_port, header_length = header_result if self.is_tunnel: # remove ss header - response = data[7:] + response = data[header_length:] else: response = b'\x00\x00\x00' + data client_addr = self._client_fd_to_server_addr.get(sock.fileno())