|
@@ -10,15 +10,15 @@ urllib.parse.uses_netloc.append("gemini")
|
|
|
|
|
|
class GeminiClient():
|
|
|
def __init__(self):
|
|
|
- self.name = "geminiclient"
|
|
|
+ pass # later, TOFU tracking can be added via instantiation of the GeminiClient object
|
|
|
|
|
|
- def request(url):
|
|
|
- # This works for gemini://domain.tld/path for now; not gemini://domain.tld:port/path
|
|
|
+ def request(self,url):
|
|
|
parsed = urllib.parse.urlparse(url)
|
|
|
- addresses = socket.getaddrinfo(parsed.netloc, port, family=0, type=socket.SOCK_STREAM)
|
|
|
+ addresses = socket.getaddrinfo(parsed.hostname, parsed.port or 1965, family=0, type=socket.SOCK_STREAM)
|
|
|
|
|
|
# We don't do the CA cert verification
|
|
|
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
|
|
|
+ # We could implement it later but for now we won't
|
|
|
+ context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
|
|
context.check_hostname = False
|
|
|
context.verify_mode = ssl.CERT_NONE
|
|
|
context.minimum_version = ssl.TLSVersion.TLSv1_2
|
|
@@ -38,6 +38,6 @@ class GeminiClient():
|
|
|
# knowledge of earlier failures.
|
|
|
raise err
|
|
|
|
|
|
- s.sendall((parsed.netloc+parsed.path+parsed.params+parsed.query+"\r\n").encode("UTF-8"))
|
|
|
+ s.sendall((url+"\r\n").encode("UTF-8"))
|
|
|
return s.makefile(mode = "rb")
|
|
|
|