add warning for missing dig binary

* skip whitelisting public ip if dig binary is unavailable

* fixes https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/issues/346
This commit is contained in:
Stuart Cardall 2020-02-06 21:01:09 +00:00
parent 7b6ad028f7
commit 13ad4132f9
No known key found for this signature in database
GPG key ID: AEB857F1C891D0C6

View file

@ -116,6 +116,10 @@ whitelist_ips() {
mkdir -p $BOTS_DIR
if [ -z $(find_binary dig) ]; then
return
fi
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"
@ -306,6 +310,11 @@ check_depends() {
exit 1
fi
# required for whitelisting public ip
if [ -z $(find_binary dig) ]; then
printf "${BOLDYELLOW}WARN${RESET}: $0 optionally requires: 'dig' => ${BOLDWHITE}cannot whitelist public ip address.${RESET}\n"
fi
# install-ngxblocker downloads missing scripts / includes as part of the update process
if [ ! -x $INSTALLER ]; then
printf "${BOLDRED}ERROR${RESET}: $0 requires: '$INSTALLER' => ${BOLDWHITE}cannot update includes.${RESET}\n"