From e2bae5874cc63ec171c0a47c9a61d85ed01d3bf7 Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Tue, 19 Jul 2016 15:43:02 +0800 Subject: [PATCH] catch decode error --- shadowsocks/tcprelay.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index e1898fc..387a2bb 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -468,10 +468,16 @@ class TCPRelayHandler(object): data = self._handel_protocol_error(self._client_address, ogn_data) header_result = parse_header(data) connecttype, remote_addr, remote_port, header_length = header_result - common.connect_log('%s connecting %s:%d from %s:%d' % + try: + common.connect_log('%s connecting %s:%d from %s:%d' % ((connecttype == 0) and 'TCP' or 'UDP', common.to_str(remote_addr), remote_port, self._client_address[0], self._client_address[1])) + except Exception as e: + common.connect_log('%s connecting %s:%d from %s:%d' % + ((connecttype == 0) and 'TCP' or 'UDP', + binascii.hexlify(remote_addr), remote_port, + self._client_address[0], self._client_address[1])) self._remote_address = (common.to_str(remote_addr), remote_port) self._remote_udp = (connecttype != 0) # pause reading