[release] v0.10.0-unstable12

This commit is contained in:
Yann Stepienik 2023-08-30 14:30:28 +01:00
parent 2e728b3ac3
commit 0af998d06c
3 changed files with 25 additions and 1 deletions

View file

@ -1,6 +1,6 @@
{
"name": "cosmos-server",
"version": "0.10.0-unstable11",
"version": "0.10.0-unstable12",
"description": "",
"main": "test-server.js",
"bugs": {

View file

@ -260,4 +260,27 @@ func IsValidHostname(hostname string) bool {
}
return false
}
func Restrictions(RestrictToConstellation bool) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// check if the request is coming from the constellation IP range 192.168.201.0/24
if RestrictToConstellation {
ip, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
http.Error(w, "Invalid request", http.StatusBadRequest)
return
}
if !strings.HasPrefix(ip, "192.168.201.") && !strings.HasPrefix(ip, "192.168.202.") {
http.Error(w, "Access denied", http.StatusForbidden)
return
}
}
next.ServeHTTP(w, r)
})
}
}

View file

@ -181,6 +181,7 @@ type ProxyRouteConfig struct {
DisableHeaderHardening bool
VerboseForwardHeader bool
AddionalFilters []AddionalFiltersConfig
RestrictToConstellation bool
}
type EmailConfig struct {