e-badips 719 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. ((EUID == 0 )) || { echo "Need root"; exit 1; }
  3. set -euo pipefail
  4. CONFD=/etc/e-router
  5. source $CONFD/config
  6. tmp=$(mktemp)
  7. trap "/bin/rm -f ${tmp}" EXIT SIGHUP SIGINT SIGTERM
  8. if curl -f -s -S -m 60 -o $tmp "https://www.badips.com/get/list/${banservice}/${banlevel}?age=${rangecheck}" ; then
  9. while read -r ip ; do
  10. [[ "$ip" =~ ^[0-9]{1,}.[0-9]{1,}.[0-9]{1,}.[0-9]{1,}$ ]] && ipset -! add ${banset} ${ip} timeout $banttl
  11. done < $tmp
  12. fi
  13. if curl -f -s -S -m 60 -o $tmp "http://api.blocklist.de/getlast.php?time=7200&service=all" ; then
  14. while read -r ip ; do
  15. [[ "$ip" =~ ^[0-9]{1,}.[0-9]{1,}.[0-9]{1,}.[0-9]{1,}$ ]] && ipset -! add ${banset} ${ip} timeout $banttl
  16. done < $tmp
  17. fi