[release] v0.4.0-unstable4

This commit is contained in:
Yann Stepienik 2023-05-06 19:32:49 +01:00
parent ac6fbe64e7
commit 7e37cfb996
2 changed files with 12 additions and 6 deletions

View file

@ -1,6 +1,6 @@
{
"name": "cosmos-server",
"version": "0.4.0-unstable3",
"version": "0.4.0-unstable4",
"description": "",
"main": "test-server.js",
"bugs": {

View file

@ -5,6 +5,7 @@ import (
"net/http"
"time"
"net"
"fmt"
"github.com/mxk/go-flowrate/flowrate"
"github.com/oschwald/geoip2-golang"
@ -188,15 +189,20 @@ func EnsureHostname(next http.Handler) http.Handler {
hostnames := GetAllHostnames()
isOk := false
for _, hostname := range hostnames {
if r.Host != hostname + port {
Error("Invalid Hostname " + r.Host + "for request. Expecting " + hostname, nil)
w.WriteHeader(http.StatusBadRequest)
http.Error(w, "Bad Request: Invalid hostname.", http.StatusBadRequest)
return
if r.Host == hostname + port {
isOk = true
}
}
if !isOk {
Error("Invalid Hostname " + r.Host + " for request. Expecting one of " + fmt.Sprintf("%v", hostnames), nil)
w.WriteHeader(http.StatusBadRequest)
http.Error(w, "Bad Request: Invalid hostname.", http.StatusBadRequest)
return
}
next.ServeHTTP(w, r)
})
}