diff --git a/proxywatchd.py b/proxywatchd.py index 39f1ffc..e5f4511 100644 --- a/proxywatchd.py +++ b/proxywatchd.py @@ -47,6 +47,20 @@ class WorkerJob(): sock.connect() sock.send('%s\n' % random.choice(['NICK', 'USER', 'JOIN', 'MODE', 'PART', 'INVITE', 'KNOCK', 'WHOIS', 'WHO', 'NOTICE', 'PRIVMSG', 'PING', 'QUIT'])) return sock, proto, duration, torhost, srv, 0 + except rocksock.RocksockException as e: + et = e.get_errortype() + err = e.get_error() + fp = e.get_failedproxy() + + sock.disconnect() + + if et == rocksock.RS_ET_OWN: + if fp == 1 and \ + err == rocksock.RS_E_REMOTE_DISCONNECTED or \ + err == rocksock.RS_E_HIT_TIMEOUT: + # proxy is not online, so don't waste time trying all possible protocols + break + except KeyboardInterrupt as e: raise(e) except: sock.disconnect() @@ -126,7 +140,7 @@ class WorkerThread(): class Proxywatchd(): def stop(self): - _log('\rRequesting proxywatchd to halt (%d thread(s))' % len([item for item in self.threads if True])) + _log('Requesting proxywatchd to halt (%d thread(s))' % len([item for item in self.threads if True])) self.stopping.set() def _cleanup(self): @@ -250,7 +264,7 @@ if __name__ == '__main__': w.start() w.run() except KeyboardInterrupt as e: - raise e + pass finally: w.stop() w.finish()