diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 4835848..01a1392 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -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, diff --git a/SPECS/network_tools.spec b/SPECS/network_tools.spec index 2e663df..ebe2d11 100644 --- a/SPECS/network_tools.spec +++ b/SPECS/network_tools.spec @@ -126,7 +126,7 @@ cp etc/sudoers.d/* %{buildroot}%{_sysconfdir}/sudoers.d # SystemD %{__mkdir_p} %{buildroot}%{_unitdir} -cp etc/systemd/system/* %{buildroot}%{_unitdir} +cp lib/systemd/system/* %{buildroot}%{_unitdir} # Bash completion %{__mkdir_p} %{buildroot}%{_sysconfdir}/bash_completion.d @@ -213,5 +213,5 @@ cp www/cgi-bin/*.cgi %{buildroot}%{_webcgi} #----------------------------------------------------------------------------------------------------------------------------------- %changelog -* Sun May 3 2026 Arnaud G. GIBERT - 1.2.0-1rx3.mga9 +* Tue May 19 2026 Arnaud G. GIBERT - 1.2.0-1rx3.mga9 - Create initial SPEC file for 1.2.0 on Mageia 9 diff --git a/lib/rx3/dns.bash b/lib/rx3/dns.bash index b0ff9ad..e965480 100644 --- a/lib/rx3/dns.bash +++ b/lib/rx3/dns.bash @@ -302,9 +302,9 @@ dns_host_update() local ip="$3" 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}]" @@ -315,9 +315,9 @@ dns_host_update() echo "update delete ${host}.${zone}. TXT" echo "update add ${host}.${zone}. ${ttl} TXT ${date}" echo "" - ) | sudo nsupdate + ) | sudo nsupdate || rc="$?" - if [[ "$?" == "0" ]] + if [[ "${rc}" == "0" ]] then dns_tab_put "A" "${host}.${zone}" "${ip}" fi diff --git a/lib/rx3/network.bash b/lib/rx3/network.bash index 483838f..39323e8 100644 --- a/lib/rx3/network.bash +++ b/lib/rx3/network.bash @@ -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 } diff --git a/etc/systemd/system/rx3-network.service b/lib/systemd/system/rx3-network.service similarity index 57% rename from etc/systemd/system/rx3-network.service rename to lib/systemd/system/rx3-network.service index 4eb97bf..63322ea 100644 --- a/etc/systemd/system/rx3-network.service +++ b/lib/systemd/system/rx3-network.service @@ -8,11 +8,11 @@ Before=docker.service [Service] Type=oneshot -ExecStart=/usr/local/sbin/rx3_net_adm start -ExecStartPost=/usr/local/sbin/rx3_net_adm status -ExecStop=/usr/local/sbin/rx3_net_adm stop -ExecStopPost=/usr/local/sbin/rx3_net_adm status -ExecReload=/usr/local/sbin/rx3_net_adm restart +ExecStart=/usr/sbin/rx3_net_adm start +ExecStartPost=/usr/sbin/rx3_net_adm status +ExecStop=/usr/sbin/rx3_net_adm stop +ExecStopPost=/usr/sbin/rx3_net_adm status +ExecReload=/usr/sbin/rx3_net_adm restart RemainAfterExit=yes TimeoutStartSec=30s TimeoutStopSec=15s diff --git a/etc/systemd/system/rx3-vpn.service b/lib/systemd/system/rx3-vpn.service similarity index 56% rename from etc/systemd/system/rx3-vpn.service rename to lib/systemd/system/rx3-vpn.service index d196592..cadf7e7 100644 --- a/etc/systemd/system/rx3-vpn.service +++ b/lib/systemd/system/rx3-vpn.service @@ -8,11 +8,11 @@ Before=docker.service [Service] Type=oneshot -ExecStart=/usr/local/sbin/rx3_vpn_adm start -ExecStartPost=/usr/local/sbin/rx3_vpn_adm status -ExecStop=/usr/local/sbin/rx3_vpn_adm stop -ExecStopPost=/usr/local/sbin/rx3_vpn_adm status -ExecReload=/usr/local/sbin/rx3_vpn_adm restart +ExecStart=/usr/sbin/rx3_vpn_adm start +ExecStartPost=/usr/sbin/rx3_vpn_adm status +ExecStop=/usr/sbin/rx3_vpn_adm stop +ExecStopPost=/usr/sbin/rx3_vpn_adm status +ExecReload=/usr/sbin/rx3_vpn_adm restart RemainAfterExit=yes TimeoutStartSec=30s TimeoutStopSec=15s diff --git a/sbin/openvpn-down b/sbin/openvpn-down index a854ed2..0f19e7f 100755 --- a/sbin/openvpn-down +++ b/sbin/openvpn-down @@ -58,12 +58,12 @@ declare -g LOG="" # Main #----------------------------------------------------------------------------------------------------------------------------------- -local dev="$1" -local local_mtu="$2" -local remote_mtu="$3" -local local_address="$4" -local local_netmask="$5" -local phase="$6" + dev="$1" + local_mtu="$2" + remote_mtu="$3" +local_address="$4" +local_netmask="$5" + phase="$6" network_init diff --git a/sbin/openvpn-up b/sbin/openvpn-up index da7a832..9ddf014 100755 --- a/sbin/openvpn-up +++ b/sbin/openvpn-up @@ -56,12 +56,12 @@ declare -g LOG="" # Main #----------------------------------------------------------------------------------------------------------------------------------- -local dev="$1" -local local_mtu="$2" -local remote_mtu="$3" -local local_address="$4" -local local_netmask="$5" -local phase="$6" + dev="$1" + local_mtu="$2" + remote_mtu="$3" +local_address="$4" +local_netmask="$5" + phase="$6" network_init diff --git a/www/cgi-bin/vpn-admin_board.cgi b/www/cgi-bin/vpn-admin_board.cgi index 5641281..548b892 100755 --- a/www/cgi-bin/vpn-admin_board.cgi +++ b/www/cgi-bin/vpn-admin_board.cgi @@ -663,10 +663,10 @@ vab_main_board_print() echo "

" time_out=$(date +%s%N) - elaps=$(( TIME_IN - time_out )) - elaps_sec=$(( elaps / 1000000000 )) - elaps_mili=$(( ( elaps / 1000000) - ( elaps_sec * 1000) )) - + elaps=$(( time_out - TIME_IN)) + elaps_sec=$(( elaps / 1000000000)) + elaps_mili=$(( ( elaps / 1000000) - ( elaps_sec * 1000))) + echo "

" echo "
" echo "
"