diff --git a/config.ini.sample b/config.ini.sample index ecb72a6..f3a4bff 100644 --- a/config.ini.sample +++ b/config.ini.sample @@ -1,10 +1,10 @@ [global] tor_host = 127.0.0.1:9050 database = proxylist.sqlite -proxy_max_fail = 5 [watcherd] proxy_file = false +max_fail = 5 threads = 10 timeout = 15 submit_after = 200 diff --git a/config.py b/config.py index 78d58b8..32d7102 100644 --- a/config.py +++ b/config.py @@ -2,6 +2,9 @@ from ConfigParser import SafeConfigParser _loaded = False +class phantom(): + def __init__(self): pass + def load(): if _loaded: return global database, maxfail, search, torhosts, watchd_threads, checktime, timeout, read_timeout, submit_after, use_ssl, url_checktime, url_perfail_checktime @@ -11,27 +14,34 @@ def load(): parser.read('config.ini') database = parser.get('global', 'database') - maxfail = parser.getint('global', 'proxy_max_fail') - - search = parser.getboolean('proxyfind', 'search') - + #maxfail = parser.getint('global', 'proxy_max_fail') torhosts = [ str(i).strip() for i in parser.get('global', 'tor_host').split(',') ] - watchd_threads = parser.getint('watcherd', 'threads') - timeout = parser.getint('watcherd', 'timeout') - submit_after = parser.getint('watcherd', 'submit_after') - use_ssl = parser.getboolean('watcherd', 'use_ssl') + + global _watchd + _watchd = phantom() + _watchd.threads = parser.getint('watcherd', 'threads') + _watchd.timeout = parser.getint('watcherd', 'timeout') + _watchd.submit_after = parser.getint('watcherd', 'submit_after') + _watchd.use_ssl = parser.getboolean('watcherd', 'use_ssl') + _watchd.debug = parser.getboolean('watcherd', 'debug') + _watchd.maxfail = parser.getint('watcherd', 'max_fail') + + global _leechd + _leechd = phantom() + _leechd.checktime = parser.get('proxyfind', 'checktime') + _leechd.perfail_checktime = parser.get('proxyfind', 'perfail_checktime') + _leechd.search = parser.getboolean('proxyfind', 'search') + global watchd_debug watchd_debug = parser.getboolean('watcherd', 'debug') - url_checktime = parser.get('proxyfind', 'checktime') - url_perfail_checktime = parser.get('proxyfind', 'perfail_checktime') # allow overriding select items from the commandline import argparse aparse = argparse.ArgumentParser() - aparse.add_argument('--watchd_threads', help="how many proxy checker threads to spin up, 0==none, default: 10", type=int, default=watchd_threads, required=False) + aparse.add_argument('--watchd_threads', help="how many proxy checker threads to spin up, 0==none, default: 10", type=int, default=_watchd.threads, required=False) args = aparse.parse_args() - watchd_threads = args.watchd_threads + _watchd.threads = args.watchd_threads global servers with open('servers.txt', 'r') as handle: diff --git a/ppf.py b/ppf.py index ab0e600..30c5809 100755 --- a/ppf.py +++ b/ppf.py @@ -162,7 +162,7 @@ if __name__ == '__main__': sqlite.commit() import_from_file('import.txt', sqlite) - if config.search: + if config._leechd.search: ## load search terms with open('search_terms.txt', 'r') as f: search_terms = [ i.strip() for i in f.read().split('\n') if len(i.strip()) ] @@ -173,7 +173,7 @@ if __name__ == '__main__': empty = [ urignore.append(i.split('/')[2]) for i in searx_instances ] # start proxy watcher - if config.watchd_threads > 0: + if config._watchd.threads > 0: watcherd = proxywatchd.Proxywatchd() watcherd.start() else: @@ -183,11 +183,11 @@ if __name__ == '__main__': while True: try: ## any site that needs to be checked ? - rows = [ [i[0],i[1],i[2]] for i in sqlite.execute('SELECT url,hash,error FROM uris WHERE (check_time+?+(error*?)