From 4c27911e8f2a7217ed8646dba7f6bf0ae9780924 Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Tue, 30 Jun 2020 17:27:53 +0200 Subject: [PATCH] Check that request port matches configured server port. Should fix #9. --- handler.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/handler.go b/handler.go index c914012..3353193 100644 --- a/handler.go +++ b/handler.go @@ -60,9 +60,8 @@ func handleGeminiRequest(conn net.Conn, config Config, accessLogEntries chan Log } // Reject requests for content from other servers - requestHostname := strings.Split(URL.Host, ":")[0] // Shave off port - if requestHostname != config.Hostname { - conn.Write([]byte("53 No proxying to other hosts!\r\n")) + if URL.Hostname() != config.Hostname || (URL.Port() != "" && URL.Port() != config.Port) { + conn.Write([]byte("53 No proxying to other hosts or ports!\r\n")) log.Status = 53 return }