Example #1
0
// makeDbRules aggregates all rules from given iptables table and converts them
// into a format acceptible by firewall store.
func makeDbRules(iptables *iptsave.IPtables) ([]*IPtablesRule, error) {

	var res []*IPtablesRule

	// This function operates on "filter" table.
	table := iptables.TableByName("filter")
	if table == nil {
		return nil, fmt.Errorf("In createNewDbRules() firewall doesn't have filter table")
	}

	for _, chain := range table.Chains {
		chainRules := chain2rules(*chain)
		res = append(res, chainRules...)
	}

	return res, nil
}