Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ipaddress import ip_address, ip_network
- allowed_networks = [
- "10.255.255.0/24",
- "10.254.254.0/25",
- ]
- def is_ip_allowed(client_ip):
- try:
- ip = ip_address(client_ip)
- for network in allowed_networks:
- if ip in ip_network(network):
- return True
- except ValueError:
- return False
- return False
- client_ip = ak_client_ip
- return is_ip_allowed(client_ip)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement