- 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:
@@ -1,5 +1,5 @@
|
|||||||
------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------
|
||||||
Network Tools V 1.2.0 - A. GIBERT - 2026/05/03
|
Network Tools V 1.2.0 - A. GIBERT - 2026/05/19
|
||||||
------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
- Split repository to remove the Rx3 configuration part and push it to rx3-config repo,
|
- Split repository to remove the Rx3 configuration part and push it to rx3-config repo,
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ cp etc/sudoers.d/* %{buildroot}%{_sysconfdir}/sudoers.d
|
|||||||
|
|
||||||
# SystemD
|
# SystemD
|
||||||
%{__mkdir_p} %{buildroot}%{_unitdir}
|
%{__mkdir_p} %{buildroot}%{_unitdir}
|
||||||
cp etc/systemd/system/* %{buildroot}%{_unitdir}
|
cp lib/systemd/system/* %{buildroot}%{_unitdir}
|
||||||
|
|
||||||
# Bash completion
|
# Bash completion
|
||||||
%{__mkdir_p} %{buildroot}%{_sysconfdir}/bash_completion.d
|
%{__mkdir_p} %{buildroot}%{_sysconfdir}/bash_completion.d
|
||||||
@@ -213,5 +213,5 @@ cp www/cgi-bin/*.cgi %{buildroot}%{_webcgi}
|
|||||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Sun May 3 2026 Arnaud G. GIBERT <arnaud@rx3.net> - 1.2.0-1rx3.mga9
|
* Tue May 19 2026 Arnaud G. GIBERT <arnaud@rx3.net> - 1.2.0-1rx3.mga9
|
||||||
- Create initial SPEC file for 1.2.0 on Mageia 9
|
- Create initial SPEC file for 1.2.0 on Mageia 9
|
||||||
|
|||||||
@@ -302,9 +302,9 @@ dns_host_update()
|
|||||||
local ip="$3"
|
local ip="$3"
|
||||||
local ttl="$4"
|
local ttl="$4"
|
||||||
|
|
||||||
local date
|
local date="$(date --rfc-3339=seconds)"
|
||||||
|
local rc
|
||||||
|
|
||||||
date="$(date --rfc-3339=seconds)"
|
|
||||||
|
|
||||||
log_info "DNS" "Host: [${host}] Zone: [${zone}] IP: [${ip}] TTL: [${ttl}] Date: [${date}]"
|
log_info "DNS" "Host: [${host}] Zone: [${zone}] IP: [${ip}] TTL: [${ttl}] Date: [${date}]"
|
||||||
|
|
||||||
@@ -315,9 +315,9 @@ dns_host_update()
|
|||||||
echo "update delete ${host}.${zone}. TXT"
|
echo "update delete ${host}.${zone}. TXT"
|
||||||
echo "update add ${host}.${zone}. ${ttl} TXT ${date}"
|
echo "update add ${host}.${zone}. ${ttl} TXT ${date}"
|
||||||
echo ""
|
echo ""
|
||||||
) | sudo nsupdate
|
) | sudo nsupdate || rc="$?"
|
||||||
|
|
||||||
if [[ "$?" == "0" ]]
|
if [[ "${rc}" == "0" ]]
|
||||||
then
|
then
|
||||||
dns_tab_put "A" "${host}.${zone}" "${ip}"
|
dns_tab_put "A" "${host}.${zone}" "${ip}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ network_dst_tab_name_lookup()
|
|||||||
{
|
{
|
||||||
dst_name="$1"
|
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_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_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_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_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
|
else
|
||||||
nstl_bytes_received=""
|
nstl_bytes_received=""
|
||||||
nstl_bytes_sent=""
|
nstl_bytes_sent=""
|
||||||
|
nstl_start_date=""
|
||||||
nstl_uptime=""
|
nstl_uptime=""
|
||||||
nstl_last_seen=""
|
nstl_last_seen=""
|
||||||
fi
|
fi
|
||||||
@@ -792,7 +794,7 @@ network_src_tab_ip_lookup()
|
|||||||
{
|
{
|
||||||
src_ip="$1"
|
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)" != "" ]]
|
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 ${dst_table}
|
${DEBUG} ip route add $(ip route list match 0.0.0.0 table main) table ${dst_table} || true
|
||||||
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}]"
|
||||||
|
|
||||||
if [[ "$(ip link show ${dst_device})" != "" ]]
|
if [[ "$(ip link show ${dst_device})" != "" ]]
|
||||||
then
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -898,7 +900,7 @@ network_route_rx3_init()
|
|||||||
|
|
||||||
if [[ "${ip_route_device}" == "${target_device}" ]]
|
if [[ "${ip_route_device}" == "${target_device}" ]]
|
||||||
then
|
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
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@@ -928,7 +930,7 @@ network_route_other_init()
|
|||||||
|
|
||||||
if [[ "${dst_id}" == "" ]]
|
if [[ "${dst_id}" == "" ]]
|
||||||
then
|
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
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -1033,7 +1035,7 @@ network_route_deinit()
|
|||||||
do
|
do
|
||||||
network_ip_route_tab_get ${ip_route_id}
|
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
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -1044,7 +1046,7 @@ network_route_deinit()
|
|||||||
|
|
||||||
log_trace "Network" "Remove default route in table: [${dst_table}]"
|
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
|
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} 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}
|
${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}]..."
|
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}
|
${DEBUG} ip rule add from ${bu_peer_address} table ${bu_table}
|
||||||
|
|
||||||
for bu_tab in ${NETWORK_TABLE_LIST}
|
for bu_tab in ${NETWORK_TABLE_LIST}
|
||||||
do
|
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
|
done
|
||||||
# set +x
|
# 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
|
${DEBUG} ip route del ${bd_bridge_network}/${bd_bridge_mask} dev ${bd_bridge_device} table ${bd_tab} 2>/dev/null || true
|
||||||
done
|
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}]..."
|
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" ]]
|
if [[ "${src_type}" != "0" ]]
|
||||||
then
|
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}
|
${DEBUG} ip rule add from ${src_ip} table ${src_table}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1406,7 +1409,7 @@ network_forward_stop()
|
|||||||
do
|
do
|
||||||
network_src_tab_get ${src_id}
|
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" ]]
|
if [[ "${src_port_range}" != "0" ]]
|
||||||
then
|
then
|
||||||
@@ -1423,14 +1426,14 @@ network_forward_stop()
|
|||||||
|
|
||||||
if [[ "${dst_type}" != "0" ]]
|
if [[ "${dst_type}" != "0" ]]
|
||||||
then
|
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
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
log_trace "Network" "Delete VPN forward chain"
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ Before=docker.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/usr/local/sbin/rx3_net_adm start
|
ExecStart=/usr/sbin/rx3_net_adm start
|
||||||
ExecStartPost=/usr/local/sbin/rx3_net_adm status
|
ExecStartPost=/usr/sbin/rx3_net_adm status
|
||||||
ExecStop=/usr/local/sbin/rx3_net_adm stop
|
ExecStop=/usr/sbin/rx3_net_adm stop
|
||||||
ExecStopPost=/usr/local/sbin/rx3_net_adm status
|
ExecStopPost=/usr/sbin/rx3_net_adm status
|
||||||
ExecReload=/usr/local/sbin/rx3_net_adm restart
|
ExecReload=/usr/sbin/rx3_net_adm restart
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
TimeoutStartSec=30s
|
TimeoutStartSec=30s
|
||||||
TimeoutStopSec=15s
|
TimeoutStopSec=15s
|
||||||
@@ -8,11 +8,11 @@ Before=docker.service
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/usr/local/sbin/rx3_vpn_adm start
|
ExecStart=/usr/sbin/rx3_vpn_adm start
|
||||||
ExecStartPost=/usr/local/sbin/rx3_vpn_adm status
|
ExecStartPost=/usr/sbin/rx3_vpn_adm status
|
||||||
ExecStop=/usr/local/sbin/rx3_vpn_adm stop
|
ExecStop=/usr/sbin/rx3_vpn_adm stop
|
||||||
ExecStopPost=/usr/local/sbin/rx3_vpn_adm status
|
ExecStopPost=/usr/sbin/rx3_vpn_adm status
|
||||||
ExecReload=/usr/local/sbin/rx3_vpn_adm restart
|
ExecReload=/usr/sbin/rx3_vpn_adm restart
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
TimeoutStartSec=30s
|
TimeoutStartSec=30s
|
||||||
TimeoutStopSec=15s
|
TimeoutStopSec=15s
|
||||||
@@ -58,12 +58,12 @@ declare -g LOG=""
|
|||||||
# Main
|
# Main
|
||||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
local dev="$1"
|
dev="$1"
|
||||||
local local_mtu="$2"
|
local_mtu="$2"
|
||||||
local remote_mtu="$3"
|
remote_mtu="$3"
|
||||||
local local_address="$4"
|
local_address="$4"
|
||||||
local local_netmask="$5"
|
local_netmask="$5"
|
||||||
local phase="$6"
|
phase="$6"
|
||||||
|
|
||||||
|
|
||||||
network_init
|
network_init
|
||||||
|
|||||||
@@ -56,12 +56,12 @@ declare -g LOG=""
|
|||||||
# Main
|
# Main
|
||||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
local dev="$1"
|
dev="$1"
|
||||||
local local_mtu="$2"
|
local_mtu="$2"
|
||||||
local remote_mtu="$3"
|
remote_mtu="$3"
|
||||||
local local_address="$4"
|
local_address="$4"
|
||||||
local local_netmask="$5"
|
local_netmask="$5"
|
||||||
local phase="$6"
|
phase="$6"
|
||||||
|
|
||||||
|
|
||||||
network_init
|
network_init
|
||||||
|
|||||||
@@ -663,10 +663,10 @@ vab_main_board_print()
|
|||||||
echo " </P>"
|
echo " </P>"
|
||||||
|
|
||||||
time_out=$(date +%s%N)
|
time_out=$(date +%s%N)
|
||||||
elaps=$(( TIME_IN - time_out ))
|
elaps=$(( time_out - TIME_IN))
|
||||||
elaps_sec=$(( elaps / 1000000000 ))
|
elaps_sec=$(( elaps / 1000000000))
|
||||||
elaps_mili=$(( ( elaps / 1000000) - ( elaps_sec * 1000) ))
|
elaps_mili=$(( ( elaps / 1000000) - ( elaps_sec * 1000)))
|
||||||
|
|
||||||
echo " <P>"
|
echo " <P>"
|
||||||
echo " <BR>"
|
echo " <BR>"
|
||||||
echo " <BR>"
|
echo " <BR>"
|
||||||
|
|||||||
Reference in New Issue
Block a user