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

Way to add subnets on ip addresses to ignore #70

Closed
davidgomezcol opened this issue Oct 16, 2020 · 7 comments
Closed

Way to add subnets on ip addresses to ignore #70

davidgomezcol opened this issue Oct 16, 2020 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@davidgomezcol
Copy link

Python version
3.8

Django version
1.11

Package version
0.14.0

Current behavior (bug description)
Is there a way to add the subnets to the ip addresses to ignore when maintenance mode is active?

to something like this? because i tried this way and it's not working for me:

MAINTENANCE_MODE_IGNORE_URLS = ('192.168.0.0/32',)

Expected behavior
192.168.0.0/32

@davidgomezcol davidgomezcol added the bug Something isn't working label Oct 16, 2020
@fabiocaccamo
Copy link
Owner

@davidgomezcol as documentation says:

# list of urls that will not be affected by the maintenance-mode
# urls will be used to compile regular expressions objects
MAINTENANCE_MODE_IGNORE_URLS = ()

So you just need to "prepare" your url for regex usage:

MAINTENANCE_MODE_IGNORE_URLS = ('192\.168\.0\.0\/32',)

@davidgomezcol
Copy link
Author

Great! thank you very much! didn't mean to put this as a bug, but github didn't give me another option. Thank you for you quick reply..

@fabiocaccamo
Copy link
Owner

Don't worry!

@davidgomezcol
Copy link
Author

davidgomezcol commented Oct 21, 2020

Hello!.. I'm adding my ip addresses like this.. but it doesn't seem to work.. i'm still having 503's after this.. and there's a bunch of them.. i'm just sharing you a little.. there's about of 200 ip addresses that i need to add there..
MAINTENANCE_MODE_IGNORE_IP_ADDRESSES = ( '31\.186\.232\.0\/24', '34\.90\.192\.162', '37\.230\.97\.9', '63\.251\.76\.0\/25',)

I tested both ways and is not working for me... --- > MAINTENANCE_MODE_IGNORE_URLS

@fabiocaccamo
Copy link
Owner

Sorry, but there is some confusion here:

  • MAINTENANCE_MODE_IGNORE_URLS check a match in the url path, excluding the domain name.
  • MAINTENANCE_MODE_IGNORE_IP_ADDRESSES check a match in the client ip returned by MAINTENANCE_MODE_GET_CLIENT_IP_ADDRESS (see the README).

So, in your case you should add ip-addresses to MAINTENANCE_MODE_IGNORE_IP_ADDRESSES (without escaping them) and write your own custom MAINTENANCE_MODE_GET_CLIENT_IP_ADDRESS function.

@davidgomezcol
Copy link
Author

I'm using django-ipware to get the user ip address.. the problem is that i have is with this kind of ip addresses 23.64.0.0/14 that could be a bunch of them, so if django-ipware grabs the ip address for example 23.67.255.255 that would be in the list of ip address from 23.64.0.0/14. I thought that probably this could have an internal function that handles that kind of situation, where can be a added this way.. i have a large list of ip addresses that i need to add like that..

@fabiocaccamo
Copy link
Owner

You should write your own function wrapping ipware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants