Browse Source

sendback an empty packet if auth success

dev
破娃酱 8 years ago
parent
commit
ada4eab628
  1. 12
      shadowsocks/obfsplugin/auth.py

12
shadowsocks/obfsplugin/auth.py

@ -544,6 +544,8 @@ class auth_sha1_v2(verify_base):
return (buf, False) return (buf, False)
self.recv_buf += buf self.recv_buf += buf
out_buf = b'' out_buf = b''
sendback = False
if not self.has_recv_header: if not self.has_recv_header:
if len(self.recv_buf) < 6: if len(self.recv_buf) < 6:
return (b'', False) return (b'', False)
@ -580,8 +582,8 @@ class auth_sha1_v2(verify_base):
return self.not_match_return(self.recv_buf) return self.not_match_return(self.recv_buf)
self.recv_buf = self.recv_buf[length:] self.recv_buf = self.recv_buf[length:]
self.has_recv_header = True self.has_recv_header = True
sendback = True
sendback = False
while len(self.recv_buf) > 2: while len(self.recv_buf) > 2:
length = struct.unpack('>H', self.recv_buf[:2])[0] length = struct.unpack('>H', self.recv_buf[:2])[0]
if length >= 8192 or length < 7: if length >= 8192 or length < 7:
@ -965,6 +967,8 @@ class auth_sha1_v4(verify_base):
return (buf, False) return (buf, False)
self.recv_buf += buf self.recv_buf += buf
out_buf = b'' out_buf = b''
sendback = False
if not self.has_recv_header: if not self.has_recv_header:
if len(self.recv_buf) <= 6: if len(self.recv_buf) <= 6:
return (b'', False) return (b'', False)
@ -1004,8 +1008,8 @@ class auth_sha1_v4(verify_base):
return self.not_match_return(self.recv_buf) return self.not_match_return(self.recv_buf)
self.recv_buf = self.recv_buf[length:] self.recv_buf = self.recv_buf[length:]
self.has_recv_header = True self.has_recv_header = True
sendback = True
sendback = False
while len(self.recv_buf) > 4: while len(self.recv_buf) > 4:
crc = struct.pack('<H', binascii.crc32(self.recv_buf[:2]) & 0xFFFF) crc = struct.pack('<H', binascii.crc32(self.recv_buf[:2]) & 0xFFFF)
if crc != self.recv_buf[2:4]: if crc != self.recv_buf[2:4]:
@ -1201,6 +1205,8 @@ class auth_aes128(verify_base):
return (buf, False) return (buf, False)
self.recv_buf += buf self.recv_buf += buf
out_buf = b'' out_buf = b''
sendback = False
if not self.has_recv_header: if not self.has_recv_header:
if len(self.recv_buf) < 30: if len(self.recv_buf) < 30:
return (b'', False) return (b'', False)
@ -1239,8 +1245,8 @@ class auth_aes128(verify_base):
return self.not_match_return(self.recv_buf) return self.not_match_return(self.recv_buf)
self.recv_buf = self.recv_buf[length:] self.recv_buf = self.recv_buf[length:]
self.has_recv_header = True self.has_recv_header = True
sendback = True
sendback = False
while len(self.recv_buf) > 4: while len(self.recv_buf) > 4:
crc = struct.pack('<H', binascii.crc32(self.recv_buf[:2]) & 0xFFFF) crc = struct.pack('<H', binascii.crc32(self.recv_buf[:2]) & 0xFFFF)
if crc != self.recv_buf[2:4]: if crc != self.recv_buf[2:4]:

Loading…
Cancel
Save