clowwindy 11 years ago
parent
commit
fb674c6b52
  1. 12
      shadowsocks/server.py

12
shadowsocks/server.py

@ -103,9 +103,17 @@ class Socks5Server(SocketServer.StreamRequestHandler):
self.server.method) self.server.method)
sock = self.connection sock = self.connection
iv_len = self.encryptor.iv_len() iv_len = self.encryptor.iv_len()
data = sock.recv(iv_len)
if iv_len > 0 and not data:
sock.close()
return
if iv_len: if iv_len:
self.decrypt(sock.recv(iv_len)) self.decrypt(data)
addrtype = ord(self.decrypt(sock.recv(1))) data = sock.recv(1)
if not data:
sock.close()
return
addrtype = ord(self.decrypt(data))
if addrtype == 1: if addrtype == 1:
addr = socket.inet_ntoa(self.decrypt(self.rfile.read(4))) addr = socket.inet_ntoa(self.decrypt(self.rfile.read(4)))
elif addrtype == 3: elif addrtype == 3:

Loading…
Cancel
Save