Skip to content

Commit

Permalink
Merge pull request #464 from mariux64/mxrouter-add-ipash
Browse files Browse the repository at this point in the history
mxrouterctl: Implement hash:net ipset
  • Loading branch information
donald authored May 13, 2025
2 parents 1ae815d + f8ae5d9 commit ccaa47a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions mxrouter/mxrouterctl
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,22 @@ 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;
}
Expand Down

0 comments on commit ccaa47a

Please sign in to comment.