Make test of request URL hostname against configured hostname case insensitive. Closes #29.

This commit is contained in:
Solderpunk 2023-01-28 19:22:31 +01:00
parent 16ed9e5cff
commit f05bab2b73
2 changed files with 4 additions and 1 deletions

View File

@ -76,6 +76,9 @@ func getConfig(filename string) (Config, error) {
return config, err
}
// Force hostname to lowercase
config.Hostname = strings.ToLower(config.Hostname)
// Validate pseudo-enums
switch config.DirectorySort {
case "Name", "Size", "Time":

View File

@ -49,7 +49,7 @@ func handleGeminiRequest(conn net.Conn, config Config, accessLogEntries chan Log
}
// Reject requests for content from other servers
if URL.Hostname() != config.Hostname || (URL.Port() != "" && URL.Port() != strconv.Itoa(config.Port)) {
if strings.ToLower(URL.Hostname()) != 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