mirror of
https://github.com/azukaar/Cosmos-Server.git
synced 2026-01-08 21:29:40 -06:00
[release] v0.4.0-unstable4
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cosmos-server",
|
||||
"version": "0.4.0-unstable3",
|
||||
"version": "0.4.0-unstable4",
|
||||
"description": "",
|
||||
"main": "test-server.js",
|
||||
"bugs": {
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user