add a try/except

This commit is contained in:
Yann Leboulanger 2012-08-22 14:49:44 +02:00
parent f832900d2b
commit 5178543517
1 changed files with 22 additions and 17 deletions

View File

@ -1140,26 +1140,31 @@ class Socks5Server(Socks5):
self.disconnect() self.disconnect()
return return
self.idlequeue.remove_timeout(self.fd) self.idlequeue.remove_timeout(self.fd)
if self.state == 2: # send reply with desired auth type try:
self.send_raw(self._get_auth_response()) if self.state == 2: # send reply with desired auth type
elif self.state == 4: # send positive response to the 'connect' self.send_raw(self._get_auth_response())
self.send_raw(self._get_request_buff(self.sha_msg, 0x00)) elif self.state == 4: # send positive response to the 'connect'
elif self.state == 7: self.send_raw(self._get_request_buff(self.sha_msg, 0x00))
if self.file_props.paused: elif self.state == 7:
self.file_props.continue_cb = self.continue_paused_transfer if self.file_props.paused:
self.idlequeue.plug_idle(self, False, False) self.file_props.continue_cb = self.continue_paused_transfer
return self.idlequeue.plug_idle(self, False, False)
result = self.start_transfer() # send return
self.queue.process_result(result, self) result = self.start_transfer() # send
if result is None or result <= 0: self.queue.process_result(result, self)
if result is None or result <= 0:
self.disconnect()
return
self.idlequeue.set_read_timeout(self.fd, STALLED_TIMEOUT)
elif self.state == 8:
self.disconnect() self.disconnect()
return return
self.idlequeue.set_read_timeout(self.fd, STALLED_TIMEOUT) else:
elif self.state == 8: self.disconnect()
self.disconnect() except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
OpenSSL.SSL.WantX509LookupError), e:
log.info('caught SSL exception, ignored')
return return
else:
self.disconnect()
if self.state < 5: if self.state < 5:
self.state += 1 self.state += 1
# unplug and plug this time for reading # unplug and plug this time for reading