- 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:
@@ -199,12 +199,12 @@ file_dir_init()
|
||||
local dir
|
||||
|
||||
|
||||
if [ ! -f ${File} ]
|
||||
then
|
||||
if [[ "$( id -u)" != "0" ]]
|
||||
then
|
||||
${ECHO} "Can't perform file init of: [${File}] as non root user!"
|
||||
else
|
||||
if [ ! -f ${File} ]
|
||||
then
|
||||
dir="$( dirname ${File})"
|
||||
|
||||
if [ ! -d ${dir} ]
|
||||
|
||||
@@ -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}
|
||||
do
|
||||
local dst_id="$1"
|
||||
|
||||
|
||||
network_dst_tab_get ${dst_id}
|
||||
|
||||
if [[ ${dst_type} == "0" ]]
|
||||
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)" != "" ]]
|
||||
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
|
||||
else
|
||||
log_trace "Network" "Define default route to device: [${dst_device}] into table: [${dst_table}]"
|
||||
@@ -724,13 +725,23 @@ network_table_init()
|
||||
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}
|
||||
do
|
||||
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}
|
||||
fi
|
||||
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"
|
||||
|
||||
@@ -1186,7 +1213,7 @@ network_start()
|
||||
{
|
||||
log_info "Network" "Starting network..."
|
||||
|
||||
network_table_init
|
||||
network_route_init
|
||||
|
||||
network_bridge_init
|
||||
|
||||
@@ -1211,7 +1238,7 @@ network_stop()
|
||||
|
||||
network_bridge_deinit
|
||||
|
||||
network_table_deinit
|
||||
network_route_deinit
|
||||
|
||||
log_info "Network" "Network stoped!"
|
||||
|
||||
|
||||
@@ -51,8 +51,7 @@ then
|
||||
log_info "VPN-Up" "$line" " Status: [OK]"
|
||||
log_trace "VPN-Up" "[${Dev}]: ip route add table: [${dst_table}] default dev: [${Dev}]"
|
||||
|
||||
${DEBUG} ip route del table ${dst_table} default
|
||||
${DEBUG} ip route add table ${dst_table} default dev ${Dev}
|
||||
network_route_dst_init ${dst_id}
|
||||
else
|
||||
log_error "VPN-Up" "$line" " Status: [ERROR]!"
|
||||
fi
|
||||
Reference in New Issue
Block a user