- Improve VPN supervisor log,
- Add IP validation on refresh.
This commit is contained in:
@@ -60,6 +60,38 @@ fi
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# is_valid_ip
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
is_valid_ip()
|
||||
{
|
||||
local ip=$1
|
||||
local regex='^([0-9]{1,3}\.){3}[0-9]{1,3}$'
|
||||
|
||||
|
||||
if [[ $ip =~ $regex ]]
|
||||
then
|
||||
IFS='.' read -r o1 o2 o3 o4 <<< "$ip"
|
||||
|
||||
for octet in $o1 $o2 $o3 $o4
|
||||
do
|
||||
if (( octet < 0 || octet > 255 ))
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# ip_to_num
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -746,7 +778,7 @@ network_table_set()
|
||||
|
||||
|
||||
tab_assign NETWORK_SRC_TAB "${src_id},Table" "${ts_table}"
|
||||
|
||||
|
||||
|
||||
${DEBUG} sed "/^NETWORK_SRC_CONFIG=\"/,/^\"/ { s/^\(${nts_ip//./\\.}[[:space:]]\+\([^\t ]\+[[:space:]]\+\)\{2\}\)[^[:space:]]\+/\1${nts_table}/ }" -i ${NETWORK_CONFIG_FILE}
|
||||
|
||||
@@ -775,14 +807,19 @@ network_dst_address_refresh()
|
||||
|
||||
dst_ip_new=$( nc ${proxy_host} ${proxy_port})
|
||||
|
||||
if [[ "${dst_ip_old}" != "${dst_ip_new}" ]]
|
||||
if is_valid_ip ${dst_ip_new}
|
||||
then
|
||||
${LOG} "Update ${dst_host_name}: Old: [${dst_ip_old}] New: [${dst_ip_new}]"
|
||||
${DEBUG} /usr/local/sbin/ip_host_update "${dst_host_name/.*}" "${dst_host_name#*.}" "${dst_ip_new}" 60
|
||||
if [[ "${dst_ip_old}" != "${dst_ip_new}" ]]
|
||||
then
|
||||
${LOG} "Update ${dst_host_name}: Old: [${dst_ip_old}] New: [${dst_ip_new}]"
|
||||
${DEBUG} /usr/local/sbin/ip_host_update "${dst_host_name/.*}" "${dst_host_name#*.}" "${dst_ip_new}" 60
|
||||
|
||||
tab_assign NETWORK_DST_TAB "${dst_id},IP" "${dst_ip_new}"
|
||||
tab_assign NETWORK_DST_TAB "${dst_id},IP" "${dst_ip_new}"
|
||||
else
|
||||
${LOG} "Skiping ${dst_host_name}: IP: [${dst_ip_old}]"
|
||||
fi
|
||||
else
|
||||
${LOG} "Skiping ${dst_host_name}: IP: [${dst_ip_old}]"
|
||||
${LOG} "Skiping ${dst_host_name}: Invalid IP: [${dst_ip_new}] Old IP[${dst_ip_old}]"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user