This commit is contained in:
Gitea 2019-02-21 19:13:58 -05:00
parent aea9d2d9d2
commit ea5b3bea5f

28
blockinst.sh Normal file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
### Takes a list of instances (one per line), resolves their IPs,
### and creates a file with the IP as the name in a specified dir.
### Be sure to toss the relevant config in your CaddyFile
###
### ipfilter / {
### rule block
### prefix_dir blocks # folder relative to working dir
### blockpage www/blocked.html # optional block page
### }
###
# blocklist location
filename="$HOME/.config/blocked.txt"
while read domain; do
rawip=$(dig +short $domain @192.168.2.2 | grep '^[.0-9]*$')
if [ -z "$rawip" ]
then
echo "$domain: missing"
else
for ip in $rawip; do
echo "$domain: $ip"
echo "$domain" > $HOME/.config/caddy/blocks/$ip
done
fi
done < $filename