diff --git a/mxrouter/mxrouterctl b/mxrouter/mxrouterctl index f16b2d0..eaa0810 100755 --- a/mxrouter/mxrouterctl +++ b/mxrouter/mxrouterctl @@ -342,16 +342,25 @@ sub reload_ipsets { my $tmp="$name-TMP"; warn "read ipset $name from $filename\n"; system('ipset','create',$tmp,$type,@options) and exit 1; - $type eq 'hash:ip' or die "read ipset type $type from file not implemented\n"; open my $in,'<',$filename or die "$filename: $!\n"; - while (<$in>) { - s/#.*//; - /^\s*(\d+\.\d+\.\d+\.\d+)\s*$/ or next; - system('ipset','add',$tmp,$1) and exit 1; - } + if ($type eq 'hash:ip') { + while (<$in>) { + s/#.*//; + /^\s*(\d+\.\d+\.\d+\.\d+)\s*$/ or next; + system('ipset','add',$tmp,$1) and exit 1; + } + } elsif ($type eq 'hash:net') { + while (<$in>) { + s/#.*//; + /^\s*(\d+\.\d+\.\d+\.\d+\/\d+)\s*$/ or next; + system('ipset', 'add', $tmp, $1) and exit 1; + } + } else { + die "read ipset type $type from file not implemented\n"; + } system('ipset','swap',$name,$tmp) and exit 1; system('ipset','destroy',$tmp) and exit 1; - } + } } our %radvd; # ( 'net03' => 'AdvSendAdvert on;prefix 2a02:d480:e08:20::/64;' , ...)