Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root@er-x:~# cat /root/parse-set.sh
- parse_ipset() {
- if [ -x /sbin/fw4 ]; then
- local domainlist=${1%/*}
- local setlist=${1##*/}
- local nftsets=""
- IFS=,
- for set in $setlist; do
- local family=$(nft -t list set inet fw4 "$set" 2>&1 | sed -nre 's#^.+ipv([46])_addr.*$#\1#p')
- nftsets="${nftsets:+$nftsets,}${family:+$family#}inet#fw4#$set"
- done
- IFS=$' \t\n'
- echo "--nftset=$domainlist/$nftsets"
- else
- echo "--ipset=$1"
- fi
- }
- parse_ipset "/example.org/yahoo.com/google.com/set1,set2,set3"
- root@er-x:~# sh /root/parse-set.sh
- --nftset=/example.org/yahoo.com/google.com/4#inet#fw4#set1,6#inet#fw4#set2,inet#fw4#set3
- root@er-x:~#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement