From d92c103c438fafc1c29e2398dae2e2eec3900286 Mon Sep 17 00:00:00 2001 From: cage Date: Wed, 24 Mar 2021 16:12:32 +0100 Subject: [PATCH] - [gemini] when resolving host try UTF8 encoded name first and punycoded last. --- src/gemini/client.lisp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gemini/client.lisp b/src/gemini/client.lisp index 90eef75..f2ca636 100644 --- a/src/gemini/client.lisp +++ b/src/gemini/client.lisp @@ -326,6 +326,14 @@ debug-gemini-request) (apply #'misc:dbg (text-utils:strcat "[gemini] " (first data)) (rest data))) +(defun open-tls-socket (host port) + (flet ((open-socket (hostname) + (usocket:socket-connect hostname + port + :element-type '(unsigned-byte 8)))) + (or (ignore-errors (open-socket host)) + (open-socket (idn:host-unicode->ascii host))))) + (defun request (host path &key (query nil) (port +gemini-default-port+) @@ -339,9 +347,8 @@ :fragment (percent-encode-fragment fragment))) (ctx (cl+ssl:make-context :verify-mode cl+ssl:+ssl-verify-none+))) (cl+ssl:with-global-context (ctx :auto-free-p t) - (when-let* ((socket (usocket:socket-connect (idn:host-unicode->ascii host) - port - :element-type '(unsigned-byte 8))) + + (when-let* ((socket (open-tls-socket host port)) (stream (usocket:socket-stream socket)) (ssl-stream (cl+ssl:make-ssl-client-stream stream :certificate client-certificate