iptables-converter - python classes

iptables_converter.py:

convert iptables commands within a script into a correspondig iptables-save script

default filename to read is rules, to read some other
file, append: -s filename

output is written to stdout for maximum flexibilty

Author: Johannes Hubertz <johannes@hubertz.de> Date: 2013-08-09 version: 0.9 License: GNU General Public License version 3 or later

Have Fun!

class iptables_converter.Chains(name, tables)

this is for one type of tables

put_into_fgr(content)

fill this line into this tabular

reset()

name is one of filter, nat, raw, mangle, tables is a list of tables in that table-class

class iptables_converter.Tables(fname='reference-one')

some chaingroups in tables are predef: filter, nat, mangle, raw

put_into_tables(line)

put line into matching Chains-object

read_file(fname)

read file into Tables-object

reset(fname)

all predefined Chains aka lists are setup as new here

table_printout()

printout nonempty tabulars in fixed sequence

iptables_converter.main()

main parses options, filnames and the like one option (-s) may be given: input-filename if none given, it defaults to: rules

class iptables_converter.Chains(name, tables)

this is for one type of tables

put_into_fgr(content)

fill this line into this tabular

reset()

name is one of filter, nat, raw, mangle, tables is a list of tables in that table-class

class iptables_converter.Tables(fname='reference-one')

some chaingroups in tables are predef: filter, nat, mangle, raw

put_into_tables(line)

put line into matching Chains-object

read_file(fname)

read file into Tables-object

reset(fname)

all predefined Chains aka lists are setup as new here

table_printout()

printout nonempty tabulars in fixed sequence

class iptables_converter_tests.Chains_Test(methodName='runTest')

some tests for class Chain

test_01_create_a_chain_object()

create a Filter group, f.e. filter

test_02_prove_policies()

check 3 valid policies, 1 exception

test_03_tables_names()

3 cases OK, 1 Exception

test_04_flush()

flush filter group, 2 rules and an invalid chain

test_05_new_chain()

create a new chain in filtergroup, create an exsiting chain should fail

test_06_insert_rule_fail()

insert a rule into an empty chain fails

test_07_insert_rule_fail()

insert a rule into a non_existing chain fails

test_08_insert_rule_works()

insert a rule into a nonempty chain works at start

test_09_append_rule()

append a rule to a chain

test_10_remove_predef_chain()

try to remove a prefined chain

test_12_remove_chain()

try to remove an existing chain

test_13_illegal_command()

try an ilegal command

class iptables_converter_tests.Tables_Test(methodName='runTest')

Tables: some first tests for the class

test_01_create_a_tables_object()

create a Tables object, check chains

test_02_nat_prerouting()

nat PREROUTING entry

test_03_mangle_table()

mangle INPUT entry

test_04_raw_table()

raw OUTPUT entry

test_05_not_existing_chain()

INPUT to not existing chain

test_06_read_not_existing_file()

read non existing file

test_07_reference_one()

read default file: reference-one, check chains

test_08_read_empty_file()

read empty file (in relation to iptables-commands)

Previous topic

iptables-converter - tests

This Page