Important: Fixed an error in IP format checking.
- Due to a mistake in the "grep" command, empty strings would pass the IP regex checks, which is not OK. - Please update your VPN scripts with this commit!
This commit is contained in:
parent
f47d78b0f1
commit
b61035137f
@ -93,11 +93,11 @@ PRIVATE_IP=$(wget --retry-connrefused -t 3 -T 15 -qO- 'http://169.254.169.254/la
|
||||
|
||||
# Check IPs for correct format
|
||||
IP_REGEX="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
|
||||
if printf %s "$PUBLIC_IP" | grep -vEq "$IP_REGEX"; then
|
||||
if ! printf %s "$PUBLIC_IP" | grep -Eq "$IP_REGEX"; then
|
||||
echo "Cannot find valid Public IP, please edit the VPN script manually."
|
||||
exit 1
|
||||
fi
|
||||
if printf %s "$PRIVATE_IP" | grep -vEq "$IP_REGEX"; then
|
||||
if ! printf %s "$PRIVATE_IP" | grep -Eq "$IP_REGEX"; then
|
||||
echo "Cannot find valid Private IP, please edit the VPN script manually."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -103,11 +103,11 @@ PRIVATE_IP=$(wget --retry-connrefused -t 3 -T 15 -qO- 'http://169.254.169.254/la
|
||||
|
||||
# Check IPs for correct format
|
||||
IP_REGEX="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
|
||||
if printf %s "$PUBLIC_IP" | grep -vEq "$IP_REGEX"; then
|
||||
if ! printf %s "$PUBLIC_IP" | grep -Eq "$IP_REGEX"; then
|
||||
echo "Cannot find valid Public IP, please edit the VPN script manually."
|
||||
exit 1
|
||||
fi
|
||||
if printf %s "$PRIVATE_IP" | grep -vEq "$IP_REGEX"; then
|
||||
if ! printf %s "$PRIVATE_IP" | grep -Eq "$IP_REGEX"; then
|
||||
echo "Cannot find valid Private IP, please edit the VPN script manually."
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user