[Ferm] @join()
Kiss Gabor (Bitman)
kissg at ssg.ki.iif.hu
Tue Jul 18 15:29:39 CEST 2017
Folks,
May I suggest a patch to ferm that implements a @join() function?
--- /usr/sbin/ferm.orig 2013-07-01 21:15:43.000000000 +0200
+++ /usr/sbin/ferm 2016-03-08 15:05:49.578355830 +0100
@@ -1285,6 +1285,10 @@
error('No domain specified') unless defined $domain;
my @ips = ipfilter($domain, to_array($params[0]));
return \@ips;
+ } elsif ($token eq '@join') {
+ my @params = get_function_params();
+ error('Usage: @join(separator, array)') unless @params == 2;
+ return join($params[0], to_array($params[1]));
} else {
error("unknown ferm built-in function");
}
I had to create it when I decided to set up IP sets from
list variables:
@def &IPSET($name, $type, $members) = {
@hook pre "(echo create -exist $name $type; echo flush $name; echo $members | xargs -d' ' -P4 -I{} echo 'add $name {}') | ipset - >/dev/null";
}
@def $address_list = (192.168.20.0/24 192.168.23.0/24);
&IPSET('foobar', 'hash:net', @join(' ', $address_list));
So I had to transform lists into plain strings somehow.
Regards
Gabor
--
"Virgil Brigman back on the air" (Abyss)
More information about the Ferm
mailing list