do not perform ssl_check when successive_success=0

aestetics
This commit is contained in:
Your Name
2021-07-03 20:11:46 +02:00
parent f6c3347eb4
commit a0bc4e4502

View File

@@ -71,12 +71,12 @@ class WorkerJob():
if checktype == 'irc': if checktype == 'irc':
srvname = random.choice(config.servers).strip() srvname = random.choice(config.servers).strip()
use_ssl = random.choice([0,1]) if config.watchd.use_ssl == 2 else config.watchd.use_ssl use_ssl = random.choice([0,1]) if config.watchd.use_ssl == 2 else config.watchd.use_ssl
if (self.consecutive_success % 3) == 0: use_ssl = 1 if self.consecutive_success > 0 and (self.consecutive_success % 3) == 0: use_ssl = 1
server_port = 6697 if use_ssl else 6667 server_port = 6697 if use_ssl else 6667
elif checktype == 'http': elif checktype == 'http':
srvname = random.choice( ['www.facebook.com', 'www.reddit.com', 'www.twitter.com'] ) srvname = random.choice( ['www.facebook.com', 'www.reddit.com', 'www.twitter.com'] )
use_ssl = random.choice([0,1]) if config.watchd.use_ssl == 2 else config.watchd.use_ssl use_ssl = random.choice([0,1]) if config.watchd.use_ssl == 2 else config.watchd.use_ssl
if (self.consecutive_success % 3) == 0: use_ssl = 1 if self.consecutive_success > 0 and (self.consecutive_success % 3) == 0: use_ssl = 1
server_port = 443 if use_ssl else 80 server_port = 443 if use_ssl else 80
protos = ['http', 'socks5', 'socks4'] if self.proto is None else [self.proto] protos = ['http', 'socks5', 'socks4'] if self.proto is None else [self.proto]
@@ -106,7 +106,7 @@ class WorkerJob():
sock.send('NICK\n') sock.send('NICK\n')
elif checktype == 'http': elif checktype == 'http':
sock.send('HEAD / HTTP/1.0\r\nHost: %s\r\n\r\n' % srvname) sock.send('HEAD / HTTP/1.0\r\nHost: %s\r\n\r\n' % srvname)
return sock, proto, duration, torhost, srvname, 0 return sock, proto, duration, torhost, srvname, 0, use_ssl
except rocksock.RocksockException as e: except rocksock.RocksockException as e:
if config.watchd.debug: if config.watchd.debug:
_log("proxy failed: %s://%s: %s"%(proto, self.proxy, e.get_errormessage()), 'debug') _log("proxy failed: %s://%s: %s"%(proto, self.proxy, e.get_errormessage()), 'debug')
@@ -142,13 +142,13 @@ class WorkerJob():
except KeyboardInterrupt as e: except KeyboardInterrupt as e:
raise(e) raise(e)
return None, None, None, None, None, fail_inc return None, None, None, None, None, fail_inc, use_ssl
def run(self): def run(self):
self.checktime = int(time.time()) self.checktime = int(time.time())
checktype = config.watchd.checktype checktype = config.watchd.checktype
sock, proto, duration, tor, srv, failinc = self.connect_socket(checktype) sock, proto, duration, tor, srv, failinc, is_ssl = self.connect_socket(checktype)
if not sock: if not sock:
self.failcount += failinc self.failcount += failinc
return return
@@ -174,7 +174,7 @@ class WorkerJob():
self.total_duration += int(duration*1000) self.total_duration += int(duration*1000)
torstats = "" if len(config.torhosts)==1 else ' tor: %s;'%tor torstats = "" if len(config.torhosts)==1 else ' tor: %s;'%tor
recvstats = "".join([x if x in string.printable and ord(x) > 32 else '.' for x in recv]) recvstats = "".join([x if x in string.printable and ord(x) > 32 else '.' for x in recv])
_log('%s://%s (%s) d: %.2f sec(s);%s srv: %s; recv: %s' % (proto, self.proxy, self.country, duration, torstats, srv, recvstats), 'xxxxx') _log('%s://%s (%s) d: %.2f sec(s);%s srv: %s; ssl: %s; recv: %s' % (proto, self.proxy, self.country, duration, torstats, srv, str(is_ssl), recvstats[:50]), 'xxxxx')
else: else:
self.failcount += 1 self.failcount += 1
self.consecutive_success = 0 self.consecutive_success = 0