|
|
@ -177,35 +177,38 @@ class SSLDaemon:
|
|
|
|
while self.select_inputs:
|
|
|
|
while self.select_inputs:
|
|
|
|
readable, writable, error = select.select(self.select_inputs, self.select_outputs, self.select_inputs)
|
|
|
|
readable, writable, error = select.select(self.select_inputs, self.select_outputs, self.select_inputs)
|
|
|
|
|
|
|
|
|
|
|
|
for sock in readable:
|
|
|
|
if len(readable) > 0:
|
|
|
|
try:
|
|
|
|
for sock in readable:
|
|
|
|
if sock is bindsocket:
|
|
|
|
try:
|
|
|
|
newsocket, fromaddr = bindsocket.accept()
|
|
|
|
if sock is bindsocket:
|
|
|
|
connstream = ssl.wrap_socket(newsocket,
|
|
|
|
newsocket, fromaddr = bindsocket.accept()
|
|
|
|
server_side=True,
|
|
|
|
connstream = ssl.wrap_socket(newsocket,
|
|
|
|
certfile=cert_path,
|
|
|
|
server_side=True,
|
|
|
|
keyfile=key_path,
|
|
|
|
certfile=cert_path,
|
|
|
|
ssl_version=ssl.PROTOCOL_TLSv1)
|
|
|
|
keyfile=key_path,
|
|
|
|
|
|
|
|
ssl_version=ssl.PROTOCOL_TLSv1)
|
|
|
|
new_client = Client(connstream)
|
|
|
|
|
|
|
|
|
|
|
|
new_client = Client(connstream)
|
|
|
|
self.select_inputs.append(connstream)
|
|
|
|
|
|
|
|
self.select_outputs.append(connstream)
|
|
|
|
self.select_inputs.append(connstream)
|
|
|
|
self.client_map[connstream.fileno()] = new_client
|
|
|
|
self.select_outputs.append(connstream)
|
|
|
|
self.client_list.append(new_client)
|
|
|
|
self.client_map[connstream.fileno()] = new_client
|
|
|
|
else:
|
|
|
|
self.client_list.append(new_client)
|
|
|
|
data = sock.recv(1024)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if data:
|
|
|
|
|
|
|
|
cur_client = self.client_map[sock.fileno()]
|
|
|
|
|
|
|
|
cur_client.process_data(data)
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.select_inputs = remove_from_list(self.select_inputs, sock)
|
|
|
|
data = sock.recv(1024)
|
|
|
|
print "NOTICE: Client disconnected"
|
|
|
|
|
|
|
|
except ssl.SSLError, err:
|
|
|
|
if data:
|
|
|
|
if err.args[0] == ssl.SSL_ERROR_WANT_READ:
|
|
|
|
cur_client = self.client_map[sock.fileno()]
|
|
|
|
select.select([sock], [], [])
|
|
|
|
cur_client.process_data(data)
|
|
|
|
elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE:
|
|
|
|
else:
|
|
|
|
select.select([], [sock], [])
|
|
|
|
self.select_inputs = remove_from_list(self.select_inputs, sock)
|
|
|
|
else:
|
|
|
|
print "NOTICE: Client disconnected"
|
|
|
|
raise
|
|
|
|
except ssl.SSLError, err:
|
|
|
|
|
|
|
|
if err.args[0] == ssl.SSL_ERROR_WANT_READ:
|
|
|
|
|
|
|
|
select.select([sock], [], [])
|
|
|
|
|
|
|
|
elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE:
|
|
|
|
|
|
|
|
select.select([], [sock], [])
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
raise
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
time.sleep(0.010)
|
|
|
|