Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2022
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. root@er-x:~# cat /root/parse-set.sh
  2. parse_ipset() {
  3. if [ -x /sbin/fw4 ]; then
  4. local domainlist=${1%/*}
  5. local setlist=${1##*/}
  6. local nftsets=""
  7.  
  8. IFS=,
  9. for set in $setlist; do
  10. local family=$(nft -t list set inet fw4 "$set" 2>&1 | sed -nre 's#^.+ipv([46])_addr.*$#\1#p')
  11. nftsets="${nftsets:+$nftsets,}${family:+$family#}inet#fw4#$set"
  12. done
  13. IFS=$' \t\n'
  14.  
  15. echo "--nftset=$domainlist/$nftsets"
  16. else
  17. echo "--ipset=$1"
  18. fi
  19. }
  20.  
  21. parse_ipset "/example.org/yahoo.com/google.com/set1,set2,set3"
  22. root@er-x:~# sh /root/parse-set.sh
  23. --nftset=/example.org/yahoo.com/google.com/4#inet#fw4#set1,6#inet#fw4#set2,inet#fw4#set3
  24. root@er-x:~#
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement