require "/usr/lib/firewall/firewall-lib.pl";
require "${General::swroot}/location-functions.pl";
require "${General::swroot}/ipblocklist-functions.pl";
+require "${General::swroot}/ipset-functions.pl";
# Set to one to enable debugging mode.
my $DEBUG = 0;
&main();
sub main {
- # Get currently used ipset sets.
- @ipset_used_sets = &ipset_get_sets();
-
# Flush all chains.
&flush();
run("/usr/sbin/firewall-policy");
# Cleanup not longer needed ipset sets.
- &ipset_cleanup();
+ &IPSet::Functions::cleanup_ipsets();
#Reload firewall.local if present
if ( -f '/etc/sysconfig/firewall.local'){
run("$IPSET restore -f $file");
}
}
-
-sub ipset_cleanup () {
- # Reload the array of used sets.
- @ipset_used_sets = &ipset_get_sets();
-
- # Loop through the array of used sets.
- foreach my $set (@ipset_used_sets) {
- # Check if this set is still in use.
- #
- # In this case an entry in the loaded sets hash exists.
- unless($ipset_loaded_sets{$set}) {
- # Entry does not exist, so this set is not longer
- # used and can be destroyed.
- run("$IPSET destroy $set");
- }
- }
-}