Geogate kill switch
This commit is contained in:
parent
77bbea38cc
commit
2682512dd3
|
@ -1,6 +1,7 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
// GeoIP gating rules. TODO: make dynamically configurable.
|
// GeoIP gating rules. TODO: make dynamically configurable.
|
||||||
|
var GeoGateEnabled bool
|
||||||
|
|
||||||
// GeoIP database path (standard location on Fedora/Debian)
|
// GeoIP database path (standard location on Fedora/Debian)
|
||||||
const GeoIPPath = "/usr/share/GeoIP/GeoLite2-City.mmdb"
|
const GeoIPPath = "/usr/share/GeoIP/GeoLite2-City.mmdb"
|
||||||
|
|
|
@ -14,6 +14,10 @@ import (
|
||||||
// GeoGate: block access to the site based on the user's location (due to local laws or regulations).
|
// GeoGate: block access to the site based on the user's location (due to local laws or regulations).
|
||||||
func GeoGate(handler http.Handler) http.Handler {
|
func GeoGate(handler http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if !config.GeoGateEnabled {
|
||||||
|
handler.ServeHTTP(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Flash errors to admins.
|
// Flash errors to admins.
|
||||||
onError := func(err error) {
|
onError := func(err error) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user