[release] v0.4.0-unstable4
This commit is contained in:
parent
ac6fbe64e7
commit
7e37cfb996
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cosmos-server",
|
"name": "cosmos-server",
|
||||||
"version": "0.4.0-unstable3",
|
"version": "0.4.0-unstable4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "test-server.js",
|
"main": "test-server.js",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
"net"
|
"net"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/mxk/go-flowrate/flowrate"
|
"github.com/mxk/go-flowrate/flowrate"
|
||||||
"github.com/oschwald/geoip2-golang"
|
"github.com/oschwald/geoip2-golang"
|
||||||
|
@ -188,15 +189,20 @@ func EnsureHostname(next http.Handler) http.Handler {
|
||||||
|
|
||||||
hostnames := GetAllHostnames()
|
hostnames := GetAllHostnames()
|
||||||
|
|
||||||
|
isOk := false
|
||||||
for _, hostname := range hostnames {
|
for _, hostname := range hostnames {
|
||||||
if r.Host != hostname + port {
|
if r.Host == hostname + port {
|
||||||
Error("Invalid Hostname " + r.Host + "for request. Expecting " + hostname, nil)
|
isOk = true
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
http.Error(w, "Bad Request: Invalid hostname.", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
next.ServeHTTP(w, r)
|
||||||
})
|
})
|
||||||
}
|
}
|
Loading…
Reference in a new issue