add and use combining class
This commit is contained in:
@@ -26,7 +26,7 @@ class WorkerJob():
|
||||
def connect_socket(self):
|
||||
srv = random.choice(config.servers).strip()
|
||||
protos = ['http', 'socks5', 'socks4'] if self.proto is None else [self.proto]
|
||||
server_port = 6697 if config.use_ssl else 6667
|
||||
server_port = 6697 if config._watchd.use_ssl else 6667
|
||||
|
||||
fail_inc = 1
|
||||
|
||||
@@ -39,12 +39,12 @@ class WorkerJob():
|
||||
]
|
||||
|
||||
try:
|
||||
sock = rocksock.Rocksock(host=srv, port=server_port, ssl=config.use_ssl, proxies=proxies, timeout=config.timeout)
|
||||
sock = rocksock.Rocksock(host=srv, port=server_port, ssl=config._watchd.use_ssl, proxies=proxies, timeout=config._watchd.timeout)
|
||||
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:
|
||||
if config.watchd_debug:
|
||||
if config._watchd.debug:
|
||||
_log("proxy failed: %s://%s: %s"%(proto, self.proxy, e.get_errormessage()), 'debug')
|
||||
|
||||
et = e.get_errortype()
|
||||
@@ -203,14 +203,14 @@ class Proxywatchd():
|
||||
self.mysqlite.commit()
|
||||
self._close_db()
|
||||
|
||||
self.submit_after = config.submit_after # number of collected jobs before writing db
|
||||
self.submit_after = config._watchd.submit_after # number of collected jobs before writing db
|
||||
self.jobs = []
|
||||
self.collected = []
|
||||
|
||||
def prepare_jobs(self):
|
||||
self._prep_db()
|
||||
q = 'SELECT proxy,proto,failed,success_count,total_duration FROM proxylist WHERE failed<? and tested<? ORDER BY RANDOM()' # ' LIMIT ?'
|
||||
rows = self.mysqlite.execute(q, (config.maxfail, time.time())).fetchall()
|
||||
rows = self.mysqlite.execute(q, (config._watchd.maxfail, time.time())).fetchall()
|
||||
for row in rows:
|
||||
job = WorkerJob(row[0], row[1], row[2], row[3], row[4])
|
||||
self.jobs.append(job)
|
||||
@@ -256,7 +256,7 @@ class Proxywatchd():
|
||||
return ret
|
||||
|
||||
def start(self):
|
||||
if config.watchd_threads == 1 and _run_standalone:
|
||||
if config._watchd.threads == 1 and _run_standalone:
|
||||
return self._run()
|
||||
else:
|
||||
return self._run_background()
|
||||
@@ -273,7 +273,7 @@ class Proxywatchd():
|
||||
def _run(self):
|
||||
_log('starting...', 'watchd')
|
||||
|
||||
for i in range(config.watchd_threads):
|
||||
for i in range(config._watchd.threads):
|
||||
threadid = ''.join( [ random.choice(string.letters) for x in range(5) ] )
|
||||
wt = WorkerThread(threadid)
|
||||
if self.in_background:
|
||||
|
||||
Reference in New Issue
Block a user