Add support for http/https -> gemini proxy
This commit is contained in:
parent
129c56c1d4
commit
24e1380e83
18
av98.py
18
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue