X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfatables%2Fexec.py;h=4afcb48e493b6b9a554933add22c5e4a88e7f6b0;hb=4e0677d9cbb7a3a1ba2c979f8087f32e530c9e03;hp=fcff3aa1c242e30e92c0a2a6e1c30b594c256ed3;hpb=c36efa8afed156cc5c25bc61dfd8987fed0010d1;p=sfa.git diff --git a/sfatables/exec.py b/sfatables/exec.py index fcff3aa1..4afcb48e 100644 --- a/sfatables/exec.py +++ b/sfatables/exec.py @@ -13,18 +13,64 @@ from sfatables.commands.List import * from sfatables.xmlrule import * class SFATablesRules: - sorted_rule_list = None - def __init__(self, chain_name): + self.sorted_rule_list = [] chain_dir_path = "%s/%s"%(sfatables_config,chain_name) rule_list = List().get_rule_list(chain_dir_path) for rule_number in rule_list: - self.sorted_rule_list.append(XMLRule(rule_number)) + self.sorted_rule_list.append(XMLRule(chain_name, rule_number)) return def apply(self, rspec): intermediate_rspec = rspec for rule in self.sorted_rule_list: - intermediate_rspec = rule.apply(intermediate_rspec) + intermediate_rspec = rule.apply_interpreted(intermediate_rspec) return intermediate_rspec + +def main(): + incoming = SFATablesRules('INCOMING') + outgoing = SFATablesRules('OUTGOING') + + rspec = """ + + + plc.princeton.sapan + + + + + hrn + plc + + + whitelist + plc.princeton + + + blacklist + plc.tp + + + + + + + + + + + + + """ + + + print "%d rules loaded for INCOMING chain\n"%len(incoming.sorted_rule_list) + print "%d rules loaded for OUTGOING chain\n"%len(outgoing.sorted_rule_list) + + newrspec = incoming.apply(rspec) + print newrspec + return + +if __name__=="__main__": + main()