Browse Source

add crc verify

dev
breakwa11 9 years ago
parent
commit
f9cdf2090f
  1. 5
      shadowsocks/obfsplugin/http_simple.py

5
shadowsocks/obfsplugin/http_simple.py

@ -238,12 +238,15 @@ class random_head(object):
if self.has_sent_header: if self.has_sent_header:
return buf return buf
self.has_sent_header = True self.has_sent_header = True
return os.urandom(common.ord(os.urandom(1)[0]) % 96 + 1) return os.urandom(common.ord(os.urandom(1)[0]) % 96 + 4)
def server_decode(self, buf): def server_decode(self, buf):
if self.has_recv_header: if self.has_recv_header:
return (buf, True, False) return (buf, True, False)
crc = binascii.crc32(buf) & 0xffffffff
if crc != 0xffffffff:
return (buf, True, False)
self.has_recv_header = True self.has_recv_header = True
# (buffer_to_recv, is_need_decrypt, is_need_to_encode_and_send_back) # (buffer_to_recv, is_need_decrypt, is_need_to_encode_and_send_back)
return (b'', False, True) return (b'', False, True)

Loading…
Cancel
Save