v-list-firewall 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. # info: list iptables rules
  3. # options: [FORMAT]
  4. #
  5. # The function of obtaining the list of all iptables rules.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. format=${1-shell}
  11. # Includes
  12. source $VESTA/func/main.sh
  13. #----------------------------------------------------------#
  14. # Action #
  15. #----------------------------------------------------------#
  16. # Defining config
  17. conf=$VESTA/data/firewall/rules.conf
  18. # Defining fileds to select
  19. fields="\$RULE \$ACTION \$PROTOCOL \$PORT \$IP \$COMMENT"
  20. fields="$fields \$RULE \$SUSPENDED \$TIME \$DATE"
  21. # Listing domains
  22. case $format in
  23. json) json_list ;;
  24. plain) nohead=1; shell_list ;;
  25. shell) fields="\$ACTION \$PROTOCOL \$PORT \$IP";
  26. shell_list | column -t ;;
  27. *) check_args '1' '0' 'USER [FORMAT]'
  28. esac
  29. #----------------------------------------------------------#
  30. # Vesta #
  31. #----------------------------------------------------------#
  32. exit