cloudflare: validate new ip before saving
This commit is contained in:
parent
dce18d1911
commit
953a356724
@ -33,6 +33,16 @@ function check_internet_access() {
|
|||||||
function check_new_ip() {
|
function check_new_ip() {
|
||||||
local new_ip
|
local new_ip
|
||||||
new_ip="$(curl -s ${IP_URL})"
|
new_ip="$(curl -s ${IP_URL})"
|
||||||
|
if [[ "$new_ip" =~ ^([0-9]{1,3})[.]([0-9]{1,3})[.]([0-9]{1,3})[.]([0-9]{1,3})$ ]]
|
||||||
|
then
|
||||||
|
for (( i=1; i<${#BASH_REMATCH[@]}; ++i ))
|
||||||
|
do
|
||||||
|
(( ${BASH_REMATCH[$i]} <= 255 )) || { "${SEND_TELEGRAM}" "Bad IP from curl. ${new_ip}" >&2; exit 1; }
|
||||||
|
done
|
||||||
|
else
|
||||||
|
"${SEND_TELEGRAM}" "Bad IP from curl. ${new_ip}" >&2
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
if [[ "${new_ip}" == "${CACHED_PUBLIC_IP}" ]]; then
|
if [[ "${new_ip}" == "${CACHED_PUBLIC_IP}" ]]; then
|
||||||
info "Public IP has not changed from ${new_ip}. Exiting..."
|
info "Public IP has not changed from ${new_ip}. Exiting..."
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user