mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-04-11 21:29:29 +02:00
#371 sanaity check on public ip data
This commit is contained in:
parent
f80e32b95d
commit
e9efa4bd65
@ -69,6 +69,19 @@ if [ ${existsHDD} -gt 0 ]; then
|
||||
# try to determine publicIP and if not possible use localIP as placeholder
|
||||
# https://github.com/rootzoll/raspiblitz/issues/312#issuecomment-462675101
|
||||
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
|
||||
|
||||
# sanity check on IP data
|
||||
# see https://github.com/rootzoll/raspiblitz/issues/371#issuecomment-472416349
|
||||
echo "-> sanity check of IP data: ${freshPublicIP}"
|
||||
if [[ $freshPublicIP =~ ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ ]]; then
|
||||
echo "OK IPv6"
|
||||
elif [[ $freshPublicIP =~ ^([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
|
||||
echo "OK IPv4"
|
||||
else
|
||||
echo "FAIL - not an IPv4 or IPv6 address"
|
||||
freshPublicIP=""
|
||||
fi
|
||||
|
||||
if [ ${#freshPublicIP} -eq 0 ]; then
|
||||
localIP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
|
||||
echo "WARNING: No publicIP information at all yet - working with placeholder : ${localIP}"
|
||||
|
@ -67,7 +67,7 @@ do
|
||||
|
||||
# every 15min - not too often
|
||||
# because its a ping to external service
|
||||
recheckPublicIP=$((($counter % 9)+1))
|
||||
recheckPublicIP=$((($counter % 900)+1))
|
||||
updateDynDomain=0
|
||||
if [ ${recheckPublicIP} -eq 1 ]; then
|
||||
echo "*** RECHECK PUBLIC IP ***"
|
||||
|
@ -310,6 +310,19 @@ if [ ${configExists} -eq 1 ]; then
|
||||
# wait otherwise looking for publicIP fails
|
||||
sleep 5
|
||||
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
|
||||
|
||||
# sanity check on IP data
|
||||
# see https://github.com/rootzoll/raspiblitz/issues/371#issuecomment-472416349
|
||||
echo "-> sanity check of IP data: ${freshPublicIP}"
|
||||
if [[ $freshPublicIP =~ ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ ]]; then
|
||||
echo "OK IPv6"
|
||||
elif [[ $freshPublicIP =~ ^([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
|
||||
echo "OK IPv4"
|
||||
else
|
||||
echo "FAIL - not an IPv4 or IPv6 address"
|
||||
freshPublicIP=""
|
||||
fi
|
||||
|
||||
if [ ${#freshPublicIP} -eq 0 ]; then
|
||||
# prevent having no publicIP set at all and LND getting stuck
|
||||
# https://github.com/rootzoll/raspiblitz/issues/312#issuecomment-462675101
|
||||
|
Loading…
x
Reference in New Issue
Block a user