in blocky-client.py [0:0]
def iptables(ip, action):
""" Runs an iptables action on an IP (-A, -C or -D), returns true if
succeeded, false otherwise """
try:
exe = IPTABLES_EXEC
if ':' in ip:
exe = IP6TABLES_EXEC
subprocess.check_call([
ENV_EXEC,
exe,
action, "INPUT",
"-s", ip,
"-j", "DROP",
"-m", "comment",
"--comment",
"Banned by Blocky/3.0"
], stderr=open(os.devnull, 'wb'))
except subprocess.CalledProcessError as err: # iptables error, expected result variant
print(err.output)
return False
except OSError as err:
print("%s not found or inaccessible: %s" % (exe, err))
return False
return True