some changes

This commit is contained in:
Your Name
2021-01-24 03:52:56 +01:00
parent fe2353acb2
commit 78b29a1187
5 changed files with 112 additions and 19 deletions

View File

@@ -2,7 +2,11 @@
import threading
import time, random, string, re, copy
from geoip import geolite2
try:
from geoip import geolite2
geolite = True
except:
geolite = False
from config import Config
@@ -24,7 +28,7 @@ def socks4_resolve(srvname, server_port):
if srv in cached_dns:
srv = cached_dns[srvname]
if config.watchd.debug:
_log("using cached ip (%s) for %s (proxy: %s)"%(srv, srvname, self.proxy), "debug")
_log("using cached ip (%s) for %s"%(srv, srvname), "debug")
else:
dns_fail = False
try:
@@ -129,7 +133,7 @@ class WorkerJob():
if re.match('^(:|NOTICE)', recv, re.IGNORECASE):
duration = (time.time() - duration)
if not self.country or self.country == 'unknown' or self.country == 'N/A':
if geolite and not self.country or self.country == 'unknown' or self.country == 'N/A':
match = geolite2.lookup(self.proxy.split(':')[0])
if match is not None: self.country = match.country
else: self.country = 'N/A'
@@ -270,8 +274,9 @@ class Proxywatchd():
if len(rows) < config.watchd.threads and config.watchd.oldies:
## disable tor safeguard for old proxies
if self.tor_safeguard: self.tor_safeguard = False
q += ' LIMIT ?'
rows = self.mysqlite.execute(q, (config.watchd.max_fail, config.watchd.max_fail*2, config.watchd.checktime, config.watchd.oldies_checktime, time.time(), config.watchd.threads*config.watchd.oldies_multi)).fetchall()
#q += ' LIMIT ?'
#rows = self.mysqlite.execute(q, (config.watchd.max_fail, config.watchd.max_fail*2, config.watchd.checktime, config.watchd.oldies_checktime, time.time(), config.watchd.threads*config.watchd.oldies_multi)).fetchall()
rows = self.mysqlite.execute(q, (config.watchd.max_fail, config.watchd.max_fail*3, config.watchd.checktime, config.watchd.oldies_checktime, time.time())).fetchall()
return rows
def prepare_jobs(self):