|
@@ -14,7 +14,12 @@ def override_blacklist(*ip_addresses):
|
|
net_socket.DISALLOWED_IPS = frozenset(
|
|
net_socket.DISALLOWED_IPS = frozenset(
|
|
ipaddress.ip_network(six.text_type(ip)) for ip in ip_addresses
|
|
ipaddress.ip_network(six.text_type(ip)) for ip in ip_addresses
|
|
)
|
|
)
|
|
- func(*args, **kwargs)
|
|
|
|
- net_socket.DISALLOWED_IPS = disallowed_ips
|
|
|
|
|
|
+ try:
|
|
|
|
+ func(*args, **kwargs)
|
|
|
|
+ finally:
|
|
|
|
+ net_socket.DISALLOWED_IPS = disallowed_ips
|
|
|
|
+ # We end up caching these disallowed ips on this function, so
|
|
|
|
+ # make sure we clear the cache as part of cleanup
|
|
|
|
+ net_socket.is_ipaddress_allowed.cache_clear()
|
|
return wrapper
|
|
return wrapper
|
|
return decorator
|
|
return decorator
|