AV-98-fork

A fork of https://tildegit.org/solderpunk/AV-98
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 6c3813225962db3958fdb2e508df1ac68392db28
parent 4408963c69e3907ea91e6e101feae9f3e1c28e32
Author: Björn Wärmedal <bjorn.warmedal@storytel.com>
Date:   Wed, 25 Aug 2021 08:03:12 +0200

Added https proxy setting, similar to gopher proxy. Also bumped version number.

Diffstat:
Mav98.py | 18++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/av98.py b/av98.py @@ -51,7 +51,7 @@ try: except ModuleNotFoundError: _HAS_CRYPTOGRAPHY = False -_VERSION = "1.0.2dev" +_VERSION = "1.0.4dev" _MAX_REDIRECTS = 5 _MAX_CACHE_SIZE = 10 @@ -274,6 +274,7 @@ class GeminiClient(cmd.Cmd): "auto_follow_redirects" : True, "gopher_proxy" : None, "tls_mode" : "tofu", + "http_proxy": None, "cache" : False } @@ -316,8 +317,15 @@ class GeminiClient(cmd.Cmd): # Don't try to speak to servers running other protocols if gi.scheme in ("http", "https"): - webbrowser.open_new_tab(gi.url) - return + if not self.options.get("http_proxy",None): + webbrowser.open_new_tab(gi.url) + return + else: + print("Do you want to try to open this link with a http proxy?") + resp = input("(Y)/N ") + if resp.strip().lower() in ("n","no"): + webbrowser.open_new_tab(gi.url) + return elif gi.scheme == "gopher" and not self.options.get("gopher_proxy", None): print("""AV-98 does not speak Gopher natively. However, you can use `set gopher_proxy hostname:port` to tell it about a @@ -543,7 +551,9 @@ you'll be able to transparently follow links to Gopherspace!""") # For Gopher requests, use the configured proxy host, port = self.options["gopher_proxy"].rsplit(":", 1) self._debug("Using gopher proxy: " + self.options["gopher_proxy"]) - + elif gi.scheme in ("http", "https"): + host, port = self.options["http_proxy"].rsplit(":",1) + self._debug("Using http proxy: " + self.options["http_proxy"]) # Do DNS resolution addresses = self._get_addresses(host, port)