Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitelisting by subnet does not work #70

Open
delameter opened this issue Jun 8, 2023 · 4 comments
Open

Whitelisting by subnet does not work #70

delameter opened this issue Jun 8, 2023 · 4 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers kind/bug/confirmed Something isn't working

Comments

@delameter
Copy link

Hello. Plugin's config reading fails with an error "not valid".

Prerequisites:

Traefik version 2.9.5
fail2ban version v0.6.6

middlewares.yml:

http:
  middlewares:
    mw-fail2ban:
      plugin:
        fail2ban:
          rules:
            bantime: 1h
            findtime: 1s
            enabled: true
            maxretry: 50
            ports:
              - 443
          blacklist:
            ip: []
          whitelist:
            ip:
              - 192.168.1.0/24

The result:

$ docker-compose up traefik 
Starting dup-traefik ... done
Attaching to dup-traefik
dup-traefik   | time="2023-06-08T20:05:41+03:00" level=info msg="Configuration loaded from flags."
dup-traefik   | IPChecking: 2023/06/08 20:05:42 restricted.go:51: &{%!e(string=CIDR address) %!e(string=║24║192.168.1.0/24)}
dup-traefik   | IPChecking: 2023/06/08 20:05:42 restricted.go:51: Error: ║24║192.168.1.0/24 not valid

Suggestions

After looking through ipChecking.go I can assume that the problem is around line 46 -- according to docs, net.ParseIP does not expect a subnet in an input string, that's what net.ParseCIDR is for.

@delameter
Copy link
Author

delameter commented Jun 8, 2023

um...

dup-traefik   | IPChecking: 2023/06/08 20:21:34 restricted.go:51: ║24║192.168.1.3 is not a valid IP or IP/Net
dup-traefik   | IPChecking: 2023/06/08 20:21:34 restricted.go:51: Error: ║24║192.168.1.3 not valid
dup-traefik   | IPChecking: 2023/06/08 20:23:05 restricted.go:51: ║24║1.1.1.1 is not a valid IP or IP/Net
dup-traefik   | IPChecking: 2023/06/08 20:23:05 restricted.go:51: Error: ║24║1.1.1.1 not valid

maybe I'm doing something wrong

@tomMoulard
Copy link
Owner

Hello @delameter,

Thanks for your interest in this Traefik plugin!

This is not due to how this Plugin parses IPs, but more on how Traefik deserialize yaml.
Instead of using an IP list, can you try just to give it as a string list?

From:

          whitelist:
            ip:
              - 192.168.1.0/24

To:

          whitelist:
            ip: 192.168.1.0/24

Does that fixes your issue?

@delameter
Copy link
Author

That helped, thanks.

Maybe consider updating the docs then? I took the configuration example from there and this one also didnt work properly.

testData:
  blacklist:
    files:
      - "tests/test-ipfile.txt"
    ip:
      - "::1"
      - "127.0.0.1"

@tomMoulard
Copy link
Owner

Yes, you are right. This should be fixed!

@tomMoulard tomMoulard added kind/bug/confirmed Something isn't working documentation Improvements or additions to documentation good first issue Good for newcomers labels Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers kind/bug/confirmed Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants