setup-ngxblocker: change resolver

* use ifconfig.co for ip resolution

  fixes https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/issues/178
This commit is contained in:
Stuart Cardall 2018-06-06 18:39:30 +00:00
parent a9ef73b12b
commit 5d494bdd63
No known key found for this signature in database
GPG key ID: AEB857F1C891D0C6

View file

@ -108,21 +108,16 @@ find_vhosts() {
}
whitelist_ips() {
local ip= conf=$BOTS_DIR/whitelist-ips.conf col_size=$1
local ip= conf=$BOTS_DIR/whitelist-ips.conf
mkdir -p $BOTS_DIR
if [ -n "$(which dig)" ]; then
ip=$(dig +short myip.opendns.com @resolver1.opendns.com)
if ! grep "$ip" $conf >/dev/null 2>&1; then
printf "\n%-17s %-15s %-s\n" "Whitelisting ip:" "$ip" "=> $conf"
if [ "$DRY_RUN" = "N" ]; then
printf "%-23s %-s\n" "$ip" "0;" >> $conf
fi
ip=$(curl -s ifconfig.co)
if ! grep "$ip" $conf >/dev/null 2>&1; then
printf "\n%-17s %-15s %-s\n" "Whitelisting ip:" "$ip" "=> $conf"
if [ "$DRY_RUN" = "N" ]; then
printf "%-23s %-s\n" "$ip" "0;" >> $conf
fi
else
printf "%-10s %-${col_size}s %-s\n" \
"WARN:" "dig binary missing" "=> install bind-tools to whitelist external ip address"
fi
}
@ -435,7 +430,7 @@ main() {
check_nginx_directives
# whitelisting
whitelist_ips $col_size
whitelist_ips
if [ -d $WWW ]; then
whitelist_domains