Advertisement
Guest User

Untitled

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