oops
This commit is contained in:
parent
aea9d2d9d2
commit
ea5b3bea5f
28
blockinst.sh
Normal file
28
blockinst.sh
Normal 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
|
Loading…
Reference in a new issue