Commit a80c126a authored by Vitaly Lipatov's avatar Vitaly Lipatov

gateway: bound API ipset checks

parent 7446a750
...@@ -39,11 +39,14 @@ def is_loopback_host(host): ...@@ -39,11 +39,14 @@ def is_loopback_host(host):
def ipset_test(setname, ip): def ipset_test(setname, ip):
"""Check if IP is in ipset. Returns True if found.""" """Check if IP is in ipset. Returns True if found."""
result = subprocess.run( try:
['ipset', 'test', setname, ip], result = subprocess.run(
stdout=subprocess.PIPE, stderr=subprocess.PIPE ['ipset', 'test', setname, ip],
) stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=5
return result.returncode == 0 )
return result.returncode == 0
except (OSError, subprocess.SubprocessError):
return False
def check_ip(ip_str): def check_ip(ip_str):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment