PascalMinder / geoblock

Traefik middleware plugin - Deny requests based on country of origin
105 stars 9 forks source link

Deny all requests #13

Closed ezruneko closed 2 years ago

ezruneko commented 2 years ago

The plugins seems ok last months but today reject all the requests.

Configuration:

time="2022-03-28T21:42:57+02:00" level=error msg="2022/03/28 21:42:57 allow local IPs:  false" plugin=plugin-GeoBlock module=github.com/PascalMinder/GeoBlock
time="2022-03-28T21:42:57+02:00" level=error msg="2022/03/28 21:42:57 log local requests:  false" module=github.com/PascalMinder/GeoBlock plugin=plugin-GeoBlock
time="2022-03-28T21:42:57+02:00" level=error msg="2022/03/28 21:42:57 log allowed requests:  false" plugin=plugin-GeoBlock module=github.com/PascalMinder/GeoBlock
time="2022-03-28T21:42:57+02:00" level=error msg="2022/03/28 21:42:57 log api requests:  true" plugin=plugin-GeoBlock module=github.com/PascalMinder/GeoBlock
time="2022-03-28T21:42:57+02:00" level=error msg="2022/03/28 21:42:57 API uri:  https://get.geojs.io/v1/ip/country/{ip}" plugin=plugin-GeoBlock module=github.com/PascalMinder/GeoBlock
time="2022-03-28T21:42:57+02:00" level=error msg="2022/03/28 21:42:57 cache size:  15" plugin=plugin-GeoBlock module=github.com/PascalMinder/GeoBlock
time="2022-03-28T21:42:57+02:00" level=error msg="2022/03/28 21:42:57 force monthly update:  false" plugin=plugin-GeoBlock module=github.com/PascalMinder/GeoBlock
time="2022-03-28T21:42:57+02:00" level=error msg="2022/03/28 21:42:57 allow unknown countries:  false" plugin=plugin-GeoBlock module=github.com/PascalMinder/GeoBlock
time="2022-03-28T21:42:57+02:00" level=error msg="2022/03/28 21:42:57 unknown country api response:  nil" plugin=plugin-GeoBlock module=github.com/PascalMinder/GeoBlock
time="2022-03-28T21:42:57+02:00" level=error msg="2022/03/28 21:42:57 allowed countries:  [AL║DZ║AS║AD║AO║AI║AQ║AG║AR║AM║AW║AU║AT║AZ║BS║BH║BD║BB║BY║BE║BZ║BJ║BM║BT║BO║BQ║BA║BW║BV║IO║BN║BG║BF║BI║CV║CM║CA║KY║CF║TD║CL║CX║CC║CO║KM║CD║CG║CK║CR║HR║CU║CW║CY║CZ║CI║DK║DJ║DM║DO║EC║EG║SV║GQ║ER║EE║SZ║ET║FK║FO║FJ║FI║FR║GF║PF║TF║GA║GM║GE║DE║GH║GI║GR║GL║GD║GP║GU║GT║GG║GN║GW║GY║HT║HM║VA║HN║HU║IS║IN║ID║IE║IM║IL║IT║JM║JP║JE║JO║KZ║KE║KI║KP║KR║KW║KG║LV║LB║LS║LR║LY║LI║LT║LU║MO║MG║MW║MY║MV║ML║MT║MH║MQ║MR║MU║YT║MX║FM║MC║MN║ME║MS║MA║MZ║NA║NR║NP║NL║NC║NZ║NI║NE║NG║NU║NF║MP║false║OM║PK║PW║PS║PA║PG║PY║PE║PH║PN║PL║PT║PR║QA║MK║RO║RW║RE║BL║SH║KN║LC║MF║PM║VC║WS║SM║ST║SA║SN║RS║SC║SL║SX║SK║SI║SB║SO║ZA║GS║SS║ES║LK║SR║SJ║SE║CH║SY║TW║TJ║TZ║TH║TL║TG║TK║TO║TT║TM║TC║TV║UG║GB║UM║US║UY║UZ║VU║VE║VG║VI║WF║EH║YE║ZM║ZW║AX║nil]" plugin=plugin-GeoBlock module=github.com/PascalMinder/GeoBlock

An example request:

time="2022-03-28T21:43:18+02:00" level=error msg="2022/03/28 21:43:18 Country [ES] for ip 31.221.208.128 fetched from https://get.geojs.io/v1/ip/country/31.221.208.128" plugin=plugin-GeoBlock module=github.com/PascalMinder/GeoBlock
time="2022-03-28T21:43:18+02:00" level=error msg="2022/03/28 21:43:18 Added to database:  {ES 2022-03-28 21:43:18.635651633 +0200 CEST m=+23.583747524}" plugin=plugin-GeoBlock module=github.com/PascalMinder/GeoBlock
time="2022-03-28T21:43:18+02:00" level=error msg="2022/03/28 21:43:18 geoblock-plugin@file: request denied [31.221.208.128] for country [ES]" plugin=plugin-GeoBlock module=github.com/PascalMinder/GeoBlock

In the traefik.yml

experimental:
    plugins:
        GeoBlock:
            moduleName: "github.com/PascalMinder/GeoBlock"
            version: "v0.2.1"

Thank you!

PascalMinder commented 2 years ago

Hey, thanks for the issue. I have experienced something similar to you on Friday. If I add more than one country to the allow list, the plugin blocks all the requests. I'll look into it tomorrow. You might want to go back one version.

PascalMinder commented 2 years ago

It appears to me that the YAML file, especially the country array, is not properly parsed to a string array. But I do not yet know why. Since it is basically a built-in function of go.

PascalMinder commented 2 years ago

Ok, the problem is with version 2.6.2 of Traefik. If I install version 2.6.1, it works as expected. I opened an issue with Traefik: https://github.com/traefik/traefik/issues/8901