diff --git a/.traefik.yml b/.traefik.yml index bfa630d..c33bb0e 100644 --- a/.traefik.yml +++ b/.traefik.yml @@ -3,5 +3,7 @@ type: middleware import: github.com/nscuro/traefik-plugin-geoblock summary: Description of what my plugin is doing testData: + enabled: true database_file: IP2LOCATION-LITE-DB1.IPV6.BIN - allowed_countries: [ "CH", "DE" ] \ No newline at end of file + allowed_countries: [ "CH", "DE" ] + allow_private: true \ No newline at end of file diff --git a/README.md b/README.md index 85cda6e..b5ea7c8 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ http: geoblock: plugin: geoblock: + enabled: true database_file: /plugins-local/src/github.com/nscuro/traefik-plugin-geoblock/IP2LOCATION-LITE-DB1.IPV6.BIN allowed_countries: [ "AT", "CH", "DE" ] allow_private: true diff --git a/plugin.go b/plugin.go index a09c24f..818dda5 100644 --- a/plugin.go +++ b/plugin.go @@ -12,6 +12,7 @@ import ( ) type Config struct { + Enabled bool `yaml:"enabled"` DatabaseFilePath string `yaml:"database_file"` AllowedCountries []string `yaml:"allowed_countries"` AllowPrivate bool `yaml:"allow_private"` @@ -43,6 +44,11 @@ func New(_ context.Context, next http.Handler, cfg *Config, name string) (http.H } func (p Plugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) { + if !p.cfg.Enabled { + p.next.ServeHTTP(rw, req) + return + } + ips := p.GetRemoteIPs(req) for _, ip := range ips {