- Rename vyprvpn-up/down to openvpn-up/down,

- Add network_route_dst_init function, to support VPN up/down roting table update.
This commit is contained in:
2025-08-09 10:29:41 +02:00
parent 67cb4f2940
commit e17b7ab24b
4 changed files with 64 additions and 38 deletions

View File

@@ -199,12 +199,12 @@ file_dir_init()
local dir local dir
if [ ! -f ${File} ]
then
if [[ "$( id -u)" != "0" ]] if [[ "$( id -u)" != "0" ]]
then then
${ECHO} "Can't perform file init of: [${File}] as non root user!" ${ECHO} "Can't perform file init of: [${File}] as non root user!"
else else
if [ ! -f ${File} ]
then
dir="$( dirname ${File})" dir="$( dirname ${File})"
if [ ! -d ${dir} ] if [ ! -d ${dir} ]

View File

@@ -698,22 +698,23 @@ network_tab_dump()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# network_table_init # network_route_init
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
network_table_init() network_route_dst_init()
{ {
for dst_id in ${NETWORK_DST_ID_LIST} local dst_id="$1"
do
network_dst_tab_get ${dst_id} network_dst_tab_get ${dst_id}
if [[ ${dst_type} == "0" ]] if [[ ${dst_type} == "0" ]]
then then
log_trace "Network" "Copy main default route into table 3 (VPN Local routing table)" log_trace "Network" "Copy main default route into table ${dst_table} (VPN Local routing table)"
if [[ "$(ip route list match 0.0.0.0 table main)" != "" ]] if [[ "$(ip route list match 0.0.0.0 table main)" != "" ]]
then then
${DEBUG} ip route add $(ip route list match 0.0.0.0 table main) table 3 ${DEBUG} ip route add $(ip route list match 0.0.0.0 table main) table ${dst_table}
fi fi
else else
log_trace "Network" "Define default route to device: [${dst_device}] into table: [${dst_table}]" log_trace "Network" "Define default route to device: [${dst_device}] into table: [${dst_table}]"
@@ -724,13 +725,23 @@ network_table_init()
fi fi
fi fi
log_trace "Network" "Add Rx3 routes in VPN tables"
target_device=${dst_device}
log_trace "Network" "Add [${target_device}] Rx3 routes in VPN tables"
for dst_id in ${NETWORK_DST_ID_LIST}
do
network_dst_tab_get ${dst_id}
for ip_route_id in ${NETWORK_IP_ROUTE_ID_LIST} for ip_route_id in ${NETWORK_IP_ROUTE_ID_LIST}
do do
network_ip_route_tab_get ${ip_route_id} network_ip_route_tab_get ${ip_route_id}
if [[ "${ip_route_device}" == "${target_device}" ]]
then
${DEBUG} ip route add ${ip_route_ip}/${ip_route_mask} table ${dst_table} dev ${ip_route_device} ${DEBUG} ip route add ${ip_route_ip}/${ip_route_mask} table ${dst_table} dev ${ip_route_device}
fi
done done
done done
} }
@@ -740,10 +751,26 @@ network_table_init()
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
# network_table_deinit # network_route_init
#-------------------------------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------------------------------
network_table_deinit() network_route_init()
{
for dst_id in ${NETWORK_DST_ID_LIST}
do
network_route_dst_init ${dst_id}
done
}
#--------------------------------------------------------------------------------------------------------------------------
# network_route_deinit
#--------------------------------------------------------------------------------------------------------------------------
network_route_deinit()
{ {
log_trace "Network" "Remove Rx3 routes in VPN tables" log_trace "Network" "Remove Rx3 routes in VPN tables"
@@ -1186,7 +1213,7 @@ network_start()
{ {
log_info "Network" "Starting network..." log_info "Network" "Starting network..."
network_table_init network_route_init
network_bridge_init network_bridge_init
@@ -1211,7 +1238,7 @@ network_stop()
network_bridge_deinit network_bridge_deinit
network_table_deinit network_route_deinit
log_info "Network" "Network stoped!" log_info "Network" "Network stoped!"

View File

@@ -51,8 +51,7 @@ then
log_info "VPN-Up" "$line" " Status: [OK]" log_info "VPN-Up" "$line" " Status: [OK]"
log_trace "VPN-Up" "[${Dev}]: ip route add table: [${dst_table}] default dev: [${Dev}]" log_trace "VPN-Up" "[${Dev}]: ip route add table: [${dst_table}] default dev: [${Dev}]"
${DEBUG} ip route del table ${dst_table} default network_route_dst_init ${dst_id}
${DEBUG} ip route add table ${dst_table} default dev ${Dev}
else else
log_error "VPN-Up" "$line" " Status: [ERROR]!" log_error "VPN-Up" "$line" " Status: [ERROR]!"
fi fi