From 38c754bf6f8ea88c86ad7cfd9bf3eb26ad65a5e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=C3=A1n=20C=20McCord?= Date: Wed, 1 Nov 2023 18:56:47 -0400 Subject: [PATCH 1/2] allow unknown country IPs to continue being processed --- plugin.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugin.go b/plugin.go index 0ece473..3ff5beb 100644 --- a/plugin.go +++ b/plugin.go @@ -170,10 +170,6 @@ func (p Plugin) CheckAllowed(ip string) (allow bool, country string, err error) return false, ip, fmt.Errorf("lookup of %s failed: %w", ip, err) } - if country == "-" { - return p.allowPrivate, country, nil - } - if country != "-" { for _, item := range p.blockedCountries { if item == country { From ce7b0b52cfbd80632eb675b36d9347928d4516f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=C3=A1n=20C=20McCord?= Date: Wed, 1 Nov 2023 19:04:21 -0400 Subject: [PATCH 2/2] fix default allows for the privateIP functionality to work --- plugin_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin_test.go b/plugin_test.go index f9359d0..5293252 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -106,8 +106,8 @@ func TestPlugin_ServeHTTP(t *testing.T) { Enabled: true, DatabaseFilePath: dbFilePath, AllowedCountries: []string{}, - AllowPrivate: true, DisallowedStatusCode: http.StatusOK, + DefaultAllow: true, } plugin, err := New(context.TODO(), &noopHandler{}, cfg, pluginName) @@ -157,6 +157,7 @@ func TestPlugin_ServeHTTP(t *testing.T) { AllowedCountries: []string{}, AllowPrivate: false, DisallowedStatusCode: http.StatusForbidden, + DefaultAllow: false, } plugin, err := New(context.TODO(), &noopHandler{}, cfg, pluginName)