diff --git a/server.py b/server.py index a80053f..795cfe9 100644 --- a/server.py +++ b/server.py @@ -1,5 +1,6 @@ #!/usr/bin/python3 import asyncio, traceback, socket, ssl +from urllib.parse import urlparse from flask import Flask, request, redirect from hypercorn.config import Config from hypercorn.asyncio import serve @@ -34,8 +35,9 @@ def relay(): title = "Something went wrong..." try: gsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - gemsocket = ssl.create_default_context().wrap_socket(gsocket) - gemsocket.connect((url, 1965)) + fulladdr = "gemini://" + url + gemsocket = ssl.create_default_context().wrap_socket(gsocket, server_hostname=urlparse(fulladdr).hostname) + gemsocket.connect((urlparse(fulladdr).hostname, 1965)) gemsocket.send(bytes("gemini://" + url + "\r\n", "UTF-8")) received = "" while True: