[firewall4] On modifie des fonctions de manipulation de la structure interne de la classe pare feu pour mieux correspondre à iptables

This commit is contained in:
Valentin Samir 2013-04-06 14:51:40 +02:00
parent c0e19b7247
commit 7882a04669

View file

@ -100,20 +100,7 @@ class firewall_base(object) :
if not chain: if not chain:
for chain in self.chain_list[table]: for chain in self.chain_list[table]:
self.delete(table, chain) self.delete(table, chain)
self.clear(table, chain)
def flush(self, table=None, chain=None):
if not table:
for table in tables:
self.flush(table, chain)
if not chain:
for chain in self.chain_list[table]:
self.flush(table, chain)
self.clear(table, chain)
self.chain_list[table].append(chain)
self.rules_list[table][chain]=[]
def clear(self, table, chain):
if not chain in self.chain_list[table]: if not chain in self.chain_list[table]:
return return
if not chain in default_chains: if not chain in default_chains:
@ -122,7 +109,18 @@ class firewall_base(object) :
else: else:
self.rules_list[table][chain]=[] self.rules_list[table][chain]=[]
def restore(self, noflush=False, table=None, chains=[]): def flush(self, table=None, chain=None):
if not table:
for table in tables:
self.flush(table, chain)
if not chain:
for chain in self.chain_list[table]:
self.flush(table, chain)
if not chain in self.chain_list[table]:
self.chain_list[table].append(chain)
self.rules_list[table][chain]=[]
def restore(self, table=None, chains=[], noflush=False):
str=self.format(chains) str=self.format(chains)
f=open('/tmp/ipt_rules', 'w') f=open('/tmp/ipt_rules', 'w')
f.write(str) f.write(str)