From 0504fb43cf24dd804d4d6e810771e422d087e458 Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Thu, 19 Nov 2015 22:21:59 +0800 Subject: [PATCH] fix a ipv6 bug in mysql mode --- server_pool.py | 3 +++ shadowsocks/obfsplugin/verify.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server_pool.py b/server_pool.py index 4b4663c..002ddfe 100644 --- a/server_pool.py +++ b/server_pool.py @@ -52,6 +52,9 @@ class ServerPool(object): self.config = shell.get_config(False) shell.print_shadowsocks() self.dns_resolver = asyncdns.DNSResolver() + if not self.config.get('dns_ipv6', False): + asyncdns.IPV6_CONNECTION_SUPPORT = False + self.mgr = asyncmgr.ServerMgr() self.tcp_servers_pool = {} diff --git a/shadowsocks/obfsplugin/verify.py b/shadowsocks/obfsplugin/verify.py index 1c939ae..5c54c78 100644 --- a/shadowsocks/obfsplugin/verify.py +++ b/shadowsocks/obfsplugin/verify.py @@ -332,7 +332,7 @@ class verify_sha1(verify_base): if sha1data != self.recv_buf[head_size:head_size + 10]: logging.error('server_post_decrype data uncorrect auth HMAC-SHA1') return b'E' - out_buf = to_bytes(chr(ord(self.recv_buf[0]) & 0xF)) + self.recv_buf[1:head_size] + out_buf = to_bytes(chr(ord(self.recv_buf[0]) & 0xEF)) + self.recv_buf[1:head_size] self.recv_buf = self.recv_buf[head_size + 10:] self.has_recv_header = True while len(self.recv_buf) > 2: @@ -345,7 +345,7 @@ class verify_sha1(verify_base): if sha1data != self.recv_buf[2:12]: raise Exception('server_post_decrype data uncorrect chunk HMAC-SHA1') - self.recv_id += 1 + self.recv_id = (self.recv_id + 1) & 0xFFFFFFFF out_buf += data self.recv_buf = self.recv_buf[length:]