From 24e1380e834849e208ae2c8be7a69038885d1e8d Mon Sep 17 00:00:00 2001 From: rmgr Date: Tue, 8 Sep 2020 19:05:24 +0930 Subject: [PATCH] Add support for http/https -> gemini proxy --- av98.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/av98.py b/av98.py index f74b532..058d35f 100755 --- a/av98.py +++ b/av98.py @@ -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,16 @@ 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 +552,10 @@ 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)