- Improve resilience in network & dns libs,
- Fix systemd scripts, - Fix openvpn-up & openvpn-down scripts, - Fix timing in vpn-admin_board.cgi script, - Move systemd script from etc to usr.
This commit is contained in:
@@ -472,7 +472,7 @@ network_dst_tab_name_lookup()
|
||||
{
|
||||
dst_name="$1"
|
||||
|
||||
dst_id=${NETWORK_DST_NAME_IDX["${dst_name}"]}
|
||||
dst_id=${NETWORK_DST_NAME_IDX["${dst_name}"]:-}
|
||||
}
|
||||
|
||||
|
||||
@@ -487,7 +487,7 @@ network_dst_tab_dev_lookup()
|
||||
{
|
||||
dst_device="$1"
|
||||
|
||||
dst_id=${NETWORK_DST_DEV_IDX["${dst_device}"]}
|
||||
dst_id=${NETWORK_DST_DEV_IDX["${dst_device}"]:-}
|
||||
}
|
||||
|
||||
|
||||
@@ -624,9 +624,11 @@ network_src_tab_load()
|
||||
nstl_bytes_sent="$( cat /sys/class/net/${nstl_device}/statistics/tx_bytes 2>/dev/null | numfmt --to=iec-i --suffix=B)" || true
|
||||
nstl_start_date="$( stat -c %Z /sys/class/net/${nstl_device})" || true
|
||||
nstl_uptime="$( echo $(( $(date +%s) - ${nstl_start_date})) | awk '{days = int($1/86400); print days " day" (( days > 1 ) ? "s" : "") strftime(" %H:%M:%S", $1,1)}')" || true
|
||||
nstl_last_seen=""
|
||||
else
|
||||
nstl_bytes_received=""
|
||||
nstl_bytes_sent=""
|
||||
nstl_start_date=""
|
||||
nstl_uptime=""
|
||||
nstl_last_seen=""
|
||||
fi
|
||||
@@ -792,7 +794,7 @@ network_src_tab_ip_lookup()
|
||||
{
|
||||
src_ip="$1"
|
||||
|
||||
src_id=${NETWORK_SRC_IP_IDX["${src_ip}"]}
|
||||
src_id=${NETWORK_SRC_IP_IDX["${src_ip}"]:-}
|
||||
}
|
||||
|
||||
|
||||
@@ -858,14 +860,14 @@ network_route_dst_init()
|
||||
|
||||
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 ${dst_table}
|
||||
${DEBUG} ip route add $(ip route list match 0.0.0.0 table main) table ${dst_table} || true
|
||||
fi
|
||||
else
|
||||
log_trace "Network" "Define default route to device: [${dst_device}] into table: [${dst_table}]"
|
||||
|
||||
if [[ "$(ip link show ${dst_device})" != "" ]]
|
||||
then
|
||||
${DEBUG} ip route add default dev ${dst_device} table ${dst_table}
|
||||
${DEBUG} ip route add default dev ${dst_device} table ${dst_table} || true
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -898,7 +900,7 @@ network_route_rx3_init()
|
||||
|
||||
if [[ "${ip_route_device}" == "${target_device}" ]]
|
||||
then
|
||||
${DEBUG} ip route add ${ip_route_ip}/${ip_route_mask} dev ${ip_route_device} table ${dst_table}
|
||||
${DEBUG} ip route add ${ip_route_ip}/${ip_route_mask} dev ${ip_route_device} table ${dst_table} || true
|
||||
fi
|
||||
done
|
||||
done
|
||||
@@ -928,7 +930,7 @@ network_route_other_init()
|
||||
|
||||
if [[ "${dst_id}" == "" ]]
|
||||
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} || true
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -1033,7 +1035,7 @@ network_route_deinit()
|
||||
do
|
||||
network_ip_route_tab_get ${ip_route_id}
|
||||
|
||||
${DEBUG} ip route del ${ip_route_ip}/${ip_route_mask} table ${table} dev ${ip_route_device} 2>/dev/null
|
||||
${DEBUG} ip route del ${ip_route_ip}/${ip_route_mask} table ${table} dev ${ip_route_device} 2>/dev/null || true
|
||||
done
|
||||
done
|
||||
|
||||
@@ -1044,7 +1046,7 @@ network_route_deinit()
|
||||
|
||||
log_trace "Network" "Remove default route in table: [${dst_table}]"
|
||||
|
||||
${DEBUG} ip route del default table ${dst_table} 2>/dev/null
|
||||
${DEBUG} ip route del default table ${dst_table} 2>/dev/null || true
|
||||
done
|
||||
}
|
||||
|
||||
@@ -1081,7 +1083,7 @@ network_table_set()
|
||||
|
||||
${DEBUG} sed "/^NETWORK_SRC_CONFIG=\"/,/^\"/ { s/^\(${nts_ip//./\\.}[[:space:]]\+\([^\t ]\+[[:space:]]\+\)\{2\}\)[^[:space:]]\+/\1${nts_table}/ }" -i ${NETWORK_CONFIG_FILE}
|
||||
|
||||
${DEBUG} ip rule del from ${nts_ip} 2>/dev/null
|
||||
${DEBUG} ip rule del from ${nts_ip} 2>/dev/null || true
|
||||
${DEBUG} ip rule add from ${nts_ip} table ${nts_table}
|
||||
}
|
||||
|
||||
@@ -1205,12 +1207,12 @@ function bridge_up
|
||||
|
||||
log_trace "Network" "Configure IP rule and routing [${bu_bridge_device}]..."
|
||||
|
||||
${DEBUG} ip rule del from ${bu_peer_address} 2>/dev/null
|
||||
${DEBUG} ip rule del from ${bu_peer_address} 2>/dev/null || true
|
||||
${DEBUG} ip rule add from ${bu_peer_address} table ${bu_table}
|
||||
|
||||
for bu_tab in ${NETWORK_TABLE_LIST}
|
||||
do
|
||||
${DEBUG} ip route add ${bu_bridge_network}/${bu_bridge_mask} dev ${bu_bridge_device} table ${bu_tab}
|
||||
${DEBUG} ip route add ${bu_bridge_network}/${bu_bridge_mask} dev ${bu_bridge_device} table ${bu_tab} || true
|
||||
done
|
||||
# set +x
|
||||
}
|
||||
@@ -1240,12 +1242,13 @@ function bridge_down
|
||||
${DEBUG} ip route del ${bd_bridge_network}/${bd_bridge_mask} dev ${bd_bridge_device} table ${bd_tab} 2>/dev/null || true
|
||||
done
|
||||
|
||||
${DEBUG} ip rule del from ${bd_peer_address} table ${bd_table} 2>/dev/null
|
||||
${DEBUG} ip rule del from ${bd_peer_address} table ${bd_table} 2>/dev/null || true
|
||||
|
||||
|
||||
log_trace "Network" "Remove bridge [${bd_bridge_device}]..."
|
||||
|
||||
${DEBUG} ip link show ${bd_bridge_device} &>/dev/null && ${DEBUG} ip link del ${bd_bridge_device}
|
||||
# ${DEBUG} ip link show ${bd_bridge_device} &>/dev/null && ${DEBUG} ip link del ${bd_bridge_device}
|
||||
${DEBUG} ip link del ${bd_bridge_device} || true
|
||||
}
|
||||
|
||||
|
||||
@@ -1379,7 +1382,7 @@ network_forward_start()
|
||||
|
||||
if [[ "${src_type}" != "0" ]]
|
||||
then
|
||||
${DEBUG} ip rule del from ${src_ip} 2>/dev/null
|
||||
${DEBUG} ip rule del from ${src_ip} 2>/dev/null || true
|
||||
${DEBUG} ip rule add from ${src_ip} table ${src_table}
|
||||
fi
|
||||
|
||||
@@ -1406,7 +1409,7 @@ network_forward_stop()
|
||||
do
|
||||
network_src_tab_get ${src_id}
|
||||
|
||||
${DEBUG} ip rule del from ${src_ip} 2>/dev/null
|
||||
${DEBUG} ip rule del from ${src_ip} 2>/dev/null || true
|
||||
|
||||
if [[ "${src_port_range}" != "0" ]]
|
||||
then
|
||||
@@ -1423,14 +1426,14 @@ network_forward_stop()
|
||||
|
||||
if [[ "${dst_type}" != "0" ]]
|
||||
then
|
||||
${DEBUG} iptables -t nat -D PREROUTING -i ${dst_device} -j PREROUTING-VPN 2>/dev/null
|
||||
${DEBUG} iptables -t nat -D PREROUTING -i ${dst_device} -j PREROUTING-VPN 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
log_trace "Network" "Delete VPN forward chain"
|
||||
|
||||
${DEBUG} iptables -t nat -X PREROUTING-VPN 2>/dev/null
|
||||
${DEBUG} iptables -t nat -X PREROUTING-VPN 2>/dev/null || true
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user