Browse Source

http_simple: fix no response in some case

verify_simple: check package size minimum 7 bytes
dev
BreakWa11 9 years ago
parent
commit
877f0470c5
  1. 3
      shadowsocks/obfsplugin/http_simple.py
  2. 12
      shadowsocks/obfsplugin/verify_simple.py

3
shadowsocks/obfsplugin/http_simple.py

@ -171,8 +171,9 @@ class http_simple(plain.plain):
return (b'', True, False)
datas = buf.split(b'\r\n\r\n', 1)
if datas and len(datas) > 1:
if datas:
ret_buf = self.get_data_from_http_header(buf)
if len(datas) > 1:
ret_buf += datas[1]
if len(ret_buf) >= 15:
self.has_recv_header = True

12
shadowsocks/obfsplugin/verify_simple.py

@ -126,7 +126,7 @@ class verify_simple(verify_base):
out_buf = b''
while len(self.recv_buf) > 2:
length = struct.unpack('>H', self.recv_buf[:2])[0]
if length >= 8192:
if length >= 8192 or length < 7:
self.raw_trans = True
self.recv_buf = b''
if self.decrypt_packet_num == 0:
@ -167,7 +167,7 @@ class verify_simple(verify_base):
out_buf = b''
while len(self.recv_buf) > 2:
length = struct.unpack('>H', self.recv_buf[:2])[0]
if length >= 8192:
if length >= 8192 or length < 7:
self.raw_trans = True
self.recv_buf = b''
if self.decrypt_packet_num == 0:
@ -223,7 +223,7 @@ class verify_deflate(verify_base):
out_buf = b''
while len(self.recv_buf) > 2:
length = struct.unpack('>H', self.recv_buf[:2])[0]
if length >= 32768:
if length >= 32768 or length < 6:
self.raw_trans = True
self.recv_buf = b''
if self.decrypt_packet_num == 0:
@ -255,7 +255,7 @@ class verify_deflate(verify_base):
out_buf = b''
while len(self.recv_buf) > 2:
length = struct.unpack('>H', self.recv_buf[:2])[0]
if length >= 32768:
if length >= 32768 or length < 6:
self.raw_trans = True
self.recv_buf = b''
if self.decrypt_packet_num == 0:
@ -424,7 +424,7 @@ class auth_simple(verify_base):
out_buf = b''
while len(self.recv_buf) > 2:
length = struct.unpack('>H', self.recv_buf[:2])[0]
if length >= 8192:
if length >= 8192 or length < 7:
self.raw_trans = True
self.recv_buf = b''
if self.decrypt_packet_num == 0:
@ -465,7 +465,7 @@ class auth_simple(verify_base):
out_buf = b''
while len(self.recv_buf) > 2:
length = struct.unpack('>H', self.recv_buf[:2])[0]
if length >= 8192:
if length >= 8192 or length < 7:
self.raw_trans = True
self.recv_buf = b''
if self.decrypt_packet_num == 0:

Loading…
Cancel
Save