refactor core modules, integrate network stats
This commit is contained in:
12
config.py
12
config.py
@@ -6,6 +6,8 @@ class Config(ComboParser):
|
||||
def load(self):
|
||||
super(Config, self).load()
|
||||
self.torhosts = [ str(i).strip() for i in self.common.tor_hosts.split(',') ]
|
||||
# threads config = per-host value, multiply by Tor host count
|
||||
self.watchd.threads = self.watchd.threads * len(self.torhosts)
|
||||
#with open('servers.txt', 'r') as handle:
|
||||
with open(self.watchd.source_file, 'r') as handle:
|
||||
self.servers = [x.strip() for x in handle.readlines() if len(x.strip()) > 0]
|
||||
@@ -39,6 +41,8 @@ class Config(ComboParser):
|
||||
errors.append('watchd.threads must be >= 1')
|
||||
if self.ppf.threads < 1:
|
||||
errors.append('ppf.threads must be >= 1')
|
||||
if self.scraper.threads < 1:
|
||||
errors.append('scraper.threads must be >= 1')
|
||||
|
||||
# Validate max_fail
|
||||
if self.watchd.max_fail < 1:
|
||||
@@ -47,7 +51,7 @@ class Config(ComboParser):
|
||||
errors.append('ppf.max_fail must be >= 1')
|
||||
|
||||
# Validate checktype
|
||||
valid_checktypes = {'irc', 'http', 'judges', 'ssl'}
|
||||
valid_checktypes = {'irc', 'head', 'judges', 'ssl'}
|
||||
if self.watchd.checktype not in valid_checktypes:
|
||||
errors.append('watchd.checktype must be one of: %s' % ', '.join(sorted(valid_checktypes)))
|
||||
|
||||
@@ -81,6 +85,7 @@ class Config(ComboParser):
|
||||
self.add_item(section, 'tor_hosts', str, '127.0.0.1:9050', 'comma-separated list of tor proxy address(es)', True)
|
||||
self.add_item(section, 'timeout_connect', int, 10, 'connection timeout in seconds (default: 10)', False)
|
||||
self.add_item(section, 'timeout_read', int, 15, 'read timeout in seconds (default: 15)', False)
|
||||
self.add_item(section, 'profiling', bool, False, 'enable cProfile profiling (default: False)', False)
|
||||
|
||||
section = 'watchd'
|
||||
self.add_item(section, 'outage_threshold', float, 4.0, 'mininum success percentage required to not drop check results', False)
|
||||
@@ -90,7 +95,7 @@ class Config(ComboParser):
|
||||
self.add_item(section, 'timeout', int, 15, 'timeout for blocking operations (connect/recv/...) for proxy checks in seconds', False)
|
||||
self.add_item(section, 'submit_after', int, 200, 'min. number of tested proxies for DB write', False)
|
||||
self.add_item(section, 'debug', bool, False, 'whether to print additional debug info', False)
|
||||
self.add_item(section, 'use_ssl', int, 0, 'whether to use SSL and port 6697 to connect to targets (slower)', False)
|
||||
self.add_item(section, 'use_ssl', int, 1, 'whether to use SSL (1=always, 0=never, 2=random)', False)
|
||||
self.add_item(section, 'checktime', int, 1800, 'base checking interval for proxies in db in seconds', False)
|
||||
self.add_item(section, 'perfail_checktime', int, 3600, 'additional checking interval for proxies in db in seconds per experienced failure', False)
|
||||
self.add_item(section, 'database', str, 'proxies.sqlite', 'filename of database', True)
|
||||
@@ -101,7 +106,7 @@ class Config(ComboParser):
|
||||
self.add_item(section, 'stale_days', int, 30, 'days after which dead proxies are removed (default: 30)', False)
|
||||
self.add_item(section, 'stats_interval', int, 300, 'seconds between status reports (default: 300)', False)
|
||||
self.add_item(section, 'tor_safeguard', bool, True, 'enable tor safeguard (default: True)', False)
|
||||
self.add_item(section, 'checktype', str, 'ssl', 'check type: irc, http, judges, or ssl', False)
|
||||
self.add_item(section, 'checktype', str, 'ssl', 'check type: irc, head, judges, or ssl', False)
|
||||
|
||||
section = 'httpd'
|
||||
self.add_item(section, 'listenip', str, '127.0.0.1', 'address for the httpd to listen to (default: 127.0.0.1)', True)
|
||||
@@ -122,6 +127,7 @@ class Config(ComboParser):
|
||||
|
||||
section = 'scraper'
|
||||
self.add_item(section, 'enabled', bool, True, 'enable search engine scraper (default: True)', False)
|
||||
self.add_item(section, 'threads', int, 3, 'number of scraper threads (default: 3)', False)
|
||||
self.add_item(section, 'debug', bool, False, 'scraper: whether to print additional debug info', False)
|
||||
self.add_item(section, 'query', str, 'psw', 'build query using Proxies, Search, Websites', False)
|
||||
self.add_item(section, 'backoff_base', int, 30, 'base backoff delay in seconds (default: 30)', False)
|
||||
|
||||
Reference in New Issue
Block a user