-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: tlsa action: blob revision: path_from: test.py revision_from: refs/heads/trunk: path_to: revision_to:
/ test.py
refs/heads/trunk:/test.py #!/usr/bin/env python3 import socket import sys import tlsa import ssl ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) ctx.load_default_certs() ctx.verify_mode = ssl.CERT_REQUIRED ctx.check_hostname = True t = tlsa.TLSA() #host = "cosmic.voyage" #works #host = "gemini.thebackupbox.net" #fails because it is set in my /etc/hosts file host = "astrobotany.mozz.us" port = 1965 try: conn = t.connect_verify(host, 1965, debug=True, secure=True) #if secure=False, we'll accept TLSA records that aren't DNSSEC signed except tlsa.DNSLookupError as e: #this will happen if DNSSEC doesn't exist, so we'd have to go through extra effort to accept TLSA without DNSSEC print("No TLSA record. Fallling back to not checking DNSSEC or TLSA.") s=socket.create_connection((host,port)) conn = ctx.wrap_socket(s,server_hostname=host) except Exception as e: print("errrrrr") raise e sys.exit(1) conn.send("gemini://{}/\r\n".format(host).encode()) buf = b"" d = conn.recv(4) while d != b"": buf += d d = conn.recv(4) try: sys.stdout.write(buf.decode()) buf=b"" except: #failed to decode. a utf-8 sequence probably was at the end and wasn't finished. pass
-- Response ended
-- Page fetched on Sun Jun 2 10:55:12 2024