MCPcopy Index your code
hub / github.com/sshuttle/sshuttle / ipt_chain_exists

Function ipt_chain_exists

sshuttle/linux.py:13–27  ·  view source on GitHub ↗
(family, table, name)

Source from the content-addressed store, hash-verified

11
12
13def ipt_chain_exists(family, table, name):
14 if family == socket.AF_INET6:
15 cmd = 'ip6tables'
16 elif family == socket.AF_INET:
17 cmd = 'iptables'
18 else:
19 raise Exception('Unsupported family "%s"' % family_to_string(family))
20 argv = [cmd, '-w', '-t', table, '-nL']
21 try:
22 output = ssubprocess.check_output(argv, env=get_env())
23 for line in output.decode('ASCII', errors='replace').split('\n'):
24 if line.startswith('Chain %s ' % name):
25 return True
26 except ssubprocess.CalledProcessError as e:
27 raise Fatal('%r returned %d' % (argv, e.returncode))
28
29
30def ipt(family, table, *args):

Callers 2

restore_firewallMethod · 0.90
restore_firewallMethod · 0.90

Calls 3

family_to_stringFunction · 0.90
get_envFunction · 0.90
FatalClass · 0.90

Tested by

no test coverage detected