e-badips 549 B

123456789101112131415161718
  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. curl -f -s -S -m 60 -o $tmp "https://www.badips.com/get/list/${banservice}/${banlevel}?age=${rangecheck}"
  9. while read -r ip ; do
  10. ipset -! add ${banset} ${ip} timeout $banttl
  11. done < $tmp
  12. curl -f -s -S -m 60 -o $tmp "http://api.blocklist.de/getlast.php?time=3600&service=all"
  13. while read -r ip ; do
  14. ipset -! add ${banset} ${ip} timeout $banttl
  15. done < $tmp