From 26f72c6fb072499c18f024befacbf2dee975f202 Mon Sep 17 00:00:00 2001 From: swee Date: Sun, 12 Jan 2025 22:37:07 -0800 Subject: [PATCH] Update server.py --- server.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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: