From c02d122be33a768289ad8f69ca4a84def957a6e4 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 1 Aug 2013 15:54:07 +0200 Subject: [PATCH] fix encoding issue --- src/common/socks5.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/socks5.py b/src/common/socks5.py index e4fbdfb4c..3670bdf47 100644 --- a/src/common/socks5.py +++ b/src/common/socks5.py @@ -815,8 +815,10 @@ class Socks5: Connect request by domain name, sid sha, instead of domain name (jep 0096) """ - buff = struct.pack('!BBBBB%dsBB' % len(msg), - 0x05, command, 0x00, 0x03, len(msg), msg.encode('utf-8'), 0, 0) + if isinstance(msg, str): + msg = msg.encode('utf-8') + buff = struct.pack('!BBBBB%dsBB' % len(msg), 0x05, command, 0x00, 0x03, + len(msg), msg, 0, 0) return buff def _parse_request_buff(self, buff):