diff --git a/config.py b/config.py index ed29ece..d939da4 100644 --- a/config.py +++ b/config.py @@ -29,6 +29,11 @@ class Config(ComboParser): self.add_item(section, 'source_file', str, 'servers.txt', 'server/url list to read from (default: servers.txt)', False) self.add_item(section, 'tor_safeguard', bool, True, 'enable tor safeguard (default: True)', 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) + self.add_item(section, 'port', int, 8081, 'port for the httpd to listen to (default: 8081)', True) + self.add_item(section, 'enabled', bool, False, 'start httpd (default: False)', True) + section = 'ppf' self.add_item(section, 'debug', bool, False, 'whether to print additional debug info', False) self.add_item(section, 'search', bool, True, 'whether to use searx search engine to find new proxy lists', False) diff --git a/dbs.py b/dbs.py index 9fa2d4f..c3a09ba 100644 --- a/dbs.py +++ b/dbs.py @@ -17,6 +17,7 @@ def create_table_if_not_exists(sqlite, dbname): elif dbname == 'uris': sqlite.execute("""CREATE TABLE IF NOT EXISTS uris ( url TEXT, + content_type TEXT, check_time INT, error INT, stale_count INT, diff --git a/ppf.py b/ppf.py index e1f67c0..bb2cdb5 100755 --- a/ppf.py +++ b/ppf.py @@ -10,6 +10,7 @@ import fetch import sys from bs4 import BeautifulSoup import re +import threading config = Config() @@ -107,6 +108,99 @@ def import_proxies_from_file(proxydb, fn): return 0 return 1 +def serve_loop(hs, done): + client_threads = [] + while not done.is_set(): + c = hs.wait_client() + + evt_done = threading.Event() + cthread = threading.Thread(target=httpsrv_client_thread, args=(c,evt_done)) + cthread.daemon = True + cthread.start() + + ctrm = [] + for ct, ct_done in client_threads: + if ct_done.is_set(): + ctrm.append((ct,ct_done)) + ct.join() + + if len(ctrm): + client_threads = [ x for x in client_threads if not x in ctrm ] + + client_threads.append((cthread, evt_done)) + +def forbidden_page(): + return ( + '\n' + '
\n' + ' \n' + '