From fcfd1b5e10536c24cf4fb81cee3fdbd81df157cb Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Mon, 19 Dec 2022 21:48:01 +0100 Subject: [PATCH] Ability to configure extra proxies via the UI (#1235) --- changedetectionio/content_fetcher.py | 10 +- changedetectionio/forms.py | 16 ++ changedetectionio/model/App.py | 7 +- changedetectionio/run_proxy_tests.sh | 25 ++ .../styles/scss/parts/_extra_proxies.scss | 17 ++ .../static/styles/scss/styles.scss | 7 +- changedetectionio/static/styles/styles.css | 257 +++++++++--------- changedetectionio/store.py | 42 ++- changedetectionio/templates/settings.html | 15 + .../tests/proxy_list/squid-auth.conf | 48 ++++ .../tests/proxy_list/squid-passwords.txt | 1 + .../proxy_list/test_select_custom_proxy.py | 51 ++++ 12 files changed, 351 insertions(+), 145 deletions(-) create mode 100644 changedetectionio/static/styles/scss/parts/_extra_proxies.scss create mode 100644 changedetectionio/tests/proxy_list/squid-auth.conf create mode 100644 changedetectionio/tests/proxy_list/squid-passwords.txt create mode 100644 changedetectionio/tests/proxy_list/test_select_custom_proxy.py diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index b941a0a7..12a3b0a1 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -243,6 +243,14 @@ class base_html_playwright(Fetcher): if proxy_override: self.proxy = {'server': proxy_override} + if self.proxy: + # Playwright needs separate username and password values + from urllib.parse import urlparse + parsed = urlparse(self.proxy.get('server')) + if parsed.username: + self.proxy['username'] = parsed.username + self.proxy['password'] = parsed.password + def screenshot_step(self, step_n=''): # There's a bug where we need to do it twice or it doesnt take the whole page, dont know why. @@ -370,7 +378,7 @@ class base_html_playwright(Fetcher): context.close() browser.close() print ("Content Fetcher > Content was empty") - raise EmptyReply(url=url, status_code=None) + raise EmptyReply(url=url, status_code=response.status) # Bug 2(?) Set the viewport size AFTER loading the page self.page.set_viewport_size({"width": 1280, "height": 1024}) diff --git a/changedetectionio/forms.py b/changedetectionio/forms.py index 88c846ae..b111f1ef 100644 --- a/changedetectionio/forms.py +++ b/changedetectionio/forms.py @@ -426,6 +426,13 @@ class watchForm(commonSettingsForm): return result +class SingleExtraProxy(Form): + + # maybe better to set some