1
0
Fork 0

Accept requests where the URL has a FQDN hostname with a trailing dot. Closes #20.

This commit is contained in:
Solderpunk 2023-01-29 12:29:01 +01:00
parent a41898b012
commit 733e518392

View file

@ -49,7 +49,12 @@ func handleGeminiRequest(conn net.Conn, config Config, accessLogEntries chan Log
}
// Reject requests for content from other servers
if strings.ToLower(URL.Hostname()) != config.Hostname || (URL.Port() != "" && URL.Port() != strconv.Itoa(config.Port)) {
requestedHost := strings.ToLower(URL.Hostname())
// Trim trailing . from FQDNs
if strings.HasSuffix(requestedHost, ".") {
requestedHost = requestedHost[:len(requestedHost)-1]
}
if requestedHost != config.Hostname || (URL.Port() != "" && URL.Port() != strconv.Itoa(config.Port)) {
conn.Write([]byte("53 No proxying to other hosts or ports!\r\n"))
log.Status = 53
return