- Start new external VPN management implementation.

This commit is contained in:
2025-07-08 23:25:17 +02:00
parent de448dd924
commit bd5c0ecbd6
4 changed files with 118 additions and 31 deletions

View File

@@ -759,6 +759,87 @@ network_table_set()
#--------------------------------------------------------------------------------------------------------------------------
# network_dst_address_refresh
#--------------------------------------------------------------------------------------------------------------------------
network_dst_address_refresh()
{
local dst_id="$1"
local dst_host_name="$2"
local dst_ip_old="$3"
local dst_ip_new
local proxy_host="proxy${dst_id}.not.rx3"
local proxy_port=8080
dst_ip_new=$( nc ${proxy_host} ${proxy_port})
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}"
else
${LOG} "Skiping ${dst_host_name}: IP: [${dst_ip_old}]"
fi
}
#--------------------------------------------------------------------------------------------------------------------------
# network_dst_address_refresh
#--------------------------------------------------------------------------------------------------------------------------
network_dst_address_refresh()
{
local dst_id="$1"
local dst_host_name="$2"
local dst_ip_old="$3"
local dst_ip_new
local proxy_host="proxy${dst_id}.not.rx3"
local proxy_port=8080
dst_ip_new=$( nc ${proxy_host} ${proxy_port})
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}"
else
${LOG} "Skiping ${dst_host_name}: IP: [${dst_ip_old}]"
fi
}
#--------------------------------------------------------------------------------------------------------------------------
# network_dst_address_refresh_all
#--------------------------------------------------------------------------------------------------------------------------
network_dst_address_refresh_all()
{
for dst_id in ${NETWORK_DST_ID_LIST}
do
network_dst_tab_get ${dst_id}
network_dst_address_refresh ${dst_id} ${dst_host_name} ${dst_ip}
done
}
#--------------------------------------------------------------------------------------------------------------------------
# bridge_up
#--------------------------------------------------------------------------------------------------------------------------

View File

@@ -99,7 +99,7 @@ dump()
#--------------------------------------------------------------------------------------------------------------------------
# Table-Set ()
# Table_Set
#--------------------------------------------------------------------------------------------------------------------------
table_set()
@@ -111,6 +111,32 @@ table_set()
#--------------------------------------------------------------------------------------------------------------------------
# Address_Refresh
#--------------------------------------------------------------------------------------------------------------------------
address_refresh()
{
dst_id="$1"
if [[ "${dst_id}" != "" ]]
then
echo "Refreshing address: [${dst_id}]..."
network_dst_tab_get ${dst_id}
network_dst_address_refresh ${dst_id} ${dst_host_name} ${dst_ip}
else
echo "Refreshing all address..."
network_dst_address_refresh_all
fi
}
#--------------------------------------------------------------------------------------------------------------------------
# Main
#--------------------------------------------------------------------------------------------------------------------------
@@ -144,6 +170,10 @@ case "$1" in
table_set $2 $3
;;
refresh_address)
address_refresh $2
;;
*)
echo "Usage: $0 {start|stop|restart|status|dump|table_set}"
RETVAL=1

View File

@@ -1,10 +1,10 @@
#!/bin/bash
#DEBUG=""
DEBUG="echo"
#DEBUG="echo"
#DEBUG=":"
LOG=":"
#LOG=":"
#LOG="echo"

View File

@@ -1,11 +1,12 @@
#!/bin/bash
#DEBUG=""
DEBUG="echo"
#DEBUG="echo"
#DEBUG=":"
LOG=":"
#LOG=":"
#LOG="echo"
LOG=""
@@ -53,32 +54,7 @@ then
${DEBUG} ip route del table ${dst_table} default
${DEBUG} ip route add table ${dst_table} default dev ${Dev}
# (
# sleep 3
#
# i=0
#
# while [[ ${remote_address} == "" && $i -lt 5 ]]
# do
# remote_address=$(/usr/local/sbin/ns-launch 3 ${dst_table} /usr/local/bin/my_address_get 2>/dev/null)
# echo >>${log_file} "$(date): Up: ${Dev}: Remote_Address=${remote_address} try=$i"
#
# i=$(($i + 1))
# sleep 5
# done
#
# if [[ remote_address != "" ]]
# then
# echo >>${log_file} "$(date): Up: ${Dev}: set ${remote_address} to vpn${dst_id}.vpn.rx3"
# /usr/local/sbin/ip_host_update vpn${dst_id} vpn.rx3 ${remote_address} 60
# else
# echo >>${log_file} "$(date): Up: ${Dev}: VPN not working?"
# fi
#
# echo >>${log_file} "$(date): Up: ${Dev}: Done!"
# ) &
echo >>${LOG_FILE} "$(date): Up: ${Dev}: Partially Done..."
echo >>${LOG_FILE} "$(date): Up: ${Dev}: Done!"
else
echo >>${LOG_FILE} " Status: [ERROR]!"
echo >>${LOG_FILE} "$(date): Up: [${Dev}] Done"