From 9b9f097adbf39d7908931203e9d8966748900bde Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Sun, 14 Sep 2014 11:09:44 +0200 Subject: Implementing https rewrite support #71 * parsing XML-Files which contain target, exclusions and rules * convert regex if required (is a little hack, probably does not work for all rules) * check if target rule apply for http url, and use the rules to rewrite it * add pice of code, to check if domain name has not changed during rewrite (should be rewritten, using publicsuffix instead of little hack) --- searx/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'searx/__init__.py') diff --git a/searx/__init__.py b/searx/__init__.py index 375a5414a..0acc61447 100644 --- a/searx/__init__.py +++ b/searx/__init__.py @@ -1,5 +1,6 @@ from os import environ from os.path import realpath, dirname, join, abspath +from searx.https_rewrite import load_https_rules try: from yaml import load except: @@ -15,6 +16,13 @@ if 'SEARX_SETTINGS_PATH' in environ: else: settings_path = join(searx_dir, 'settings.yml') +if 'SEARX_HTTPS_REWRITE_PATH' in environ: + https_rewrite_path = environ['SEARX_HTTPS_REWRITE_PATH'] +else: + https_rewrite_path = join(searx_dir, 'https_rules') with open(settings_path) as settings_yaml: settings = load(settings_yaml) + +# loade https rules +load_https_rules(https_rewrite_path) -- cgit v1.2.3 From 0616d26feb0f96b3d4fd6b2744ae0288c9fed96b Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Sun, 14 Sep 2014 14:17:12 +0200 Subject: improve https rewriting --- searx/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'searx/__init__.py') diff --git a/searx/__init__.py b/searx/__init__.py index 0acc61447..d4fc7f0bb 100644 --- a/searx/__init__.py +++ b/searx/__init__.py @@ -24,5 +24,7 @@ else: with open(settings_path) as settings_yaml: settings = load(settings_yaml) -# loade https rules -load_https_rules(https_rewrite_path) +# load https rules only if https rewrite is enabled +if settings.get('server', {}).get('https_rewrite'): + # loade https rules + load_https_rules(https_rewrite_path) -- cgit v1.2.3 From 5740cfbf1cb468af74d0e7e1c9358ce702eb4f59 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Sun, 19 Oct 2014 12:41:04 +0200 Subject: [fix] pep8 part II. --- searx/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'searx/__init__.py') diff --git a/searx/__init__.py b/searx/__init__.py index c4c363bf8..46685817a 100644 --- a/searx/__init__.py +++ b/searx/__init__.py @@ -28,7 +28,8 @@ except: searx_dir = abspath(dirname(__file__)) engine_dir = dirname(realpath(__file__)) -# if possible set path to settings using the enviroment variable SEARX_SETTINGS_PATH +# if possible set path to settings using the +# enviroment variable SEARX_SETTINGS_PATH if 'SEARX_SETTINGS_PATH' in environ: settings_path = environ['SEARX_SETTINGS_PATH'] # otherwise using default path -- cgit v1.2.3