10 Commits

Author SHA1 Message Date
6d2fd44dba - Start migration of dns, network & vpn lib,
- Start migration of rx3_net_adm.
2026-04-13 16:35:39 +02:00
0c05cfd6c0 - Fix ReleaseNotes file. 2026-04-13 12:08:50 +02:00
540bd1ce03 - Add rx3-network.minotaur config file,
- Add missing etc/sudoers.d/rx3-network config file.
2025-10-19 20:13:09 +02:00
5e3d8ed47b - Minor config files update. 2025-09-19 11:43:49 +02:00
ce66dba7a6 - Fix uptime for gateway destinations,
- Add status filtering in the VPN Admin page.
2025-09-19 11:02:09 +02:00
2083444bc1 - Minor fixes in config files and openvpn-status. 2025-09-12 18:43:25 +02:00
8cd1bcce64 - Fix sysconfig files,
- Fix openvpn-status.
2025-09-07 23:26:55 +02:00
e5a41ec931 - Update changelog for release. 2025-09-03 14:51:05 +02:00
a0d8a55ca8 - Fix stupid -x on the shebang line of vpn lib! 2025-09-01 19:33:27 +02:00
fc549dfea0 - Add network reinit() function,
- Add reinit at each supervisor end loop,
- Fix address refresh algorithm,
- Fix log function parameter passing bug.
2025-09-01 19:22:40 +02:00
17 changed files with 369 additions and 164 deletions

View File

@@ -1,3 +1,43 @@
------------------------------------------------------------------------------------------------------------------------------------
Network Tools V 1.2.0 - A. GIBERT - 2026/04/xx
------------------------------------------------------------------------------------------------------------------------------------
- Migrate Network Tools to the new Rx3 Base Bash library,
- Add RPM Spec & bash completion files,
- Move install dir form /usr/locla to usr,
- Support now rx3-base 1.1.1.
------------------------------------------------------------------------------------------------------------------------------------
Network Tools V 1.1.3 - A. GIBERT - 2025/09/19
------------------------------------------------------------------------------------------------------------------------------------
- Fix uptime for gateway destinations,
- Add status filtering in the VPN Admin page.
------------------------------------------------------------------------------------------------------------------------------------
Network Tools V 1.1.2 - A. GIBERT - 2025/09/12
------------------------------------------------------------------------------------------------------------------------------------
- Minor fixes in config files and openvpn-status.
------------------------------------------------------------------------------------------------------------------------------------
Network Tools V 1.1.1 - A. GIBERT - 2025/09/03
------------------------------------------------------------------------------------------------------------------------------------
- Add a new conection state for gateways device up with no gateway client connected,
- Improve openvpn stats reporting,
- Improve device up api events,
- Add network reinit() function,
- Add reinit at each supervisor end loop.
------------------------------------------------------------------------------------------------------------------------------------
Network Tools V 1.1.0 - A. GIBERT - 2025/08/26
------------------------------------------------------------------------------------------------------------------------------------

View File

@@ -361,7 +361,7 @@ log_print()
log_trace()
{
log_print "${LOG_FILE}" "${LOG_LOCK}" "${LOG_ECHO}" "TRA" $*
log_print "${LOG_FILE}" "${LOG_LOCK}" "${LOG_ECHO}" "TRA" "$@"
}
@@ -374,7 +374,7 @@ log_trace()
log_info()
{
log_print "${LOG_FILE}" "${LOG_LOCK}" "${LOG_ECHO}" "INF" $*
log_print "${LOG_FILE}" "${LOG_LOCK}" "${LOG_ECHO}" "INF" "$@"
}
@@ -387,7 +387,7 @@ log_info()
log_warning()
{
log_print "${LOG_FILE}" "${LOG_LOCK}" "${LOG_ECHO}" "WRN" $*
log_print "${LOG_FILE}" "${LOG_LOCK}" "${LOG_ECHO}" "WRN" "$@"
}
@@ -400,5 +400,5 @@ log_warning()
log_error()
{
log_print "${LOG_FILE}" "${LOG_LOCK}" "${LOG_ECHO}" "ERR" $*
log_print "${LOG_FILE}" "${LOG_LOCK}" "${LOG_ECHO}" "ERR" "$@"
}

View File

@@ -1,28 +1,48 @@
#!/bin/bash
#-----------------------------------------------------------------------------------------------------------------------------------
#
# Rx3 DNS Library
#
# Copyright (C) 2025-2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
#
# This is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; If not, see
# <https://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------------------------------------------------------------
if [[ "${DNS_BASH}" != "" ]]
if [[ "${RX3_DNS_LIB}" != "" ]]
then
return
else
declare -g DNS_BASH=1
declare -g RX3_DNS_LIB=1
fi
#-----------------------------------------------------------------------------------------------------------------------------------
# Includes
#-----------------------------------------------------------------------------------------------------------------------------------
if [[ -e /usr/local/lib/default.bash ]]
then
. /usr/local/lib/default.bash
else
. /usr/global/lib/default.bash
fi
: "${RX3_LIB_DIR:=/usr/lib/rx3}"
. "${RX3_LIB_DIR}/base.bash"
#-----------------------------------------------------------------------------------------------------------------------------------
# Global Variable
#-----------------------------------------------------------------------------------------------------------------------------------
@@ -291,6 +311,14 @@ dns_init()
dns_deinit()
{
:;
DNS_A_TAB=()
DNS_A_ID_LIST=""
DNS_PTR_TAB=()
DNS_PTR_ID_LIST=""
DNS_CACHE_UPDATED=0
# :;
}

View File

@@ -1,23 +1,48 @@
#!/bin/bash
#-----------------------------------------------------------------------------------------------------------------------------------
#
# Rx3 Network Library
#
# Copyright (C) 2025-2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
#
# This is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; If not, see
# <https://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------------------------------------------------------------
if [[ "${NETWORK_BASH}" != "" ]]
if [[ "${RX3_NETWORK_LIB}" != "" ]]
then
return
else
declare -g NETWORK_BASH=1
declare -g RX3_NETWORK_LIB=1
fi
#-----------------------------------------------------------------------------------------------------------------------------------
# Includes
#-----------------------------------------------------------------------------------------------------------------------------------
. /usr/local/lib/dns.bash
: "${RX3_LIB_DIR:=/usr/lib/rx3}"
. "${RX3_LIB_DIR}/dns.bash"
#-----------------------------------------------------------------------------------------------------------------------------------
# Global Variable
#-----------------------------------------------------------------------------------------------------------------------------------
@@ -119,7 +144,7 @@ num_to_ip()
# Optional safety check
if (( num < 0 || num > 4294967295 ))
then
echo "num_to_ip: value out of range (04294967295)" >&2
echo_error "num_to_ip: value out of range (04294967295)"
return 1
fi
@@ -406,9 +431,14 @@ network_dst_tab_load()
if [[ "${ndtl_status}" == "1" ]]
then
ndtl_start_date="$( stat -c %Z /sys/class/net/${ndtl_device})"
ndtl_uptime="$( echo $(( $(date +%s) - ${ndtl_start_date})) | awk '{days = int($1/86400); print days " day" (( days > 1 ) ? "s" : "") strftime(" %H:%M:%S", $1,1)}')"
if [[ "${ndtl_type}" == "1" ]]
then
ndtl_start_date="${ovpn_stat_connected_date}"
ndtl_uptime="$( echo $(( $(date +%s) - ${ovpn_stat_connected_time_t})) | awk '{days = int($1/86400); print days " day" (( days > 1 ) ? "s" : "") strftime(" %H:%M:%S", $1,1)}')"
else
ndtl_start_date="$( stat -c %Z /sys/class/net/${ndtl_device})"
ndtl_uptime="$( echo $(( $(date +%s) - ${ndtl_start_date})) | awk '{days = int($1/86400); print days " day" (( days > 1 ) ? "s" : "") strftime(" %H:%M:%S", $1,1)}')"
fi
else
ndtl_start_date=""
ndtl_uptime=""
@@ -554,12 +584,12 @@ network_dst_ip_update()
if [[ "${dst_ip}" != "${dst_ip_new}" ]]
then
log_info "Network" "Update ${dst_host_name}: Old: [${dst_ip}] New: [${dst_ip_new}]"
log_info "Network" "Update [${dst_host_name}]: Old: [${dst_ip}] New: [${dst_ip_new}]"
${DEBUG} /usr/local/sbin/ip_host_update "${dst_host_name/.*}" "${dst_host_name#*.}" "${dst_ip_new}" 60
tab_assign NETWORK_DST_TAB "${dst_id},IP" "${dst_ip_new}"
else
log_trace "Network" "Skiping ${dst_host_name}: IP: [${dst_ip}]"
log_trace "Network" "Skiping [${dst_host_name}]: IP: [${dst_ip}]"
fi
}
@@ -584,7 +614,7 @@ network_dst_name_ip_update()
network_dst_tab_get "${dst_id}"
network_dst_ip_update "${dst_ip_new}"
else
log_error "Network: dst name not found: [${dst_name}]"
log_error "Network" "dst name not found: [${dst_name}]"
fi
}
@@ -694,7 +724,7 @@ network_src_tab_load()
if [[ " ${NETWORK_TABLE_LIST} " != *" ${nstl_table} "* ]]
then
err_echo "Invalid table number: [${nstl_table}] in network src entry: [${nstl_id}]!"
echo_error "Invalid table number: [${nstl_table}] in network src entry: [${nstl_id}]!"
exit 1
fi
@@ -1019,52 +1049,6 @@ network_device_deinit()
#--------------------------------------------------------------------------------------------------------------------------
# network_dst_init
#--------------------------------------------------------------------------------------------------------------------------
#
#network_device_name_init()
#{
# local dst_id="$1"
#
#
# if [[ "${dst_id}" != "" ]]
# then
# network_dst_tab_get "${dst_id}"
#
# network_route_dst_init "${dst_id}"
#
# network_route_rx3_init "${dst_device}"
#
# fi
#
# network_route_rx3_init "${target_device}"
#}
#--------------------------------------------------------------------------------------------------------------------------
# network_device_name_init
#--------------------------------------------------------------------------------------------------------------------------
#
#network_device_name_init()
#{
# local target_device="$1"
#
#
# network_dst_tab_dev_lookup ${target_device}
#
# if [[ "${dst_id}" != "" ]]
# then
# network_route_dst_init "${dst_id}"
# fi
#
# network_route_rx3_init "${target_device}"
#}
#--------------------------------------------------------------------------------------------------------------------------
# network_route_init
@@ -1135,13 +1119,13 @@ network_table_set()
if [[ "${src_id}" == "" ]]
then
err_echo "IP not found: [${nts_ip}]!"
echo_error "IP not found: [${nts_ip}]!"
return 1
fi
if [[ " ${NETWORK_TABLE_LIST} " != *" ${nts_table} "* ]]
then
err_echo "Table not found: [${nts_table}]!"
echo_error "Table not found: [${nts_table}]!"
return 1
fi
@@ -1189,7 +1173,7 @@ network_dst_address_refresh()
local proxy_port=8080
network_dst_tab_get "${dst_id}"
network_dst_tab_get "${dst_id}"
if [[ ( "${dst_host_name}" != "" )]]
then
@@ -1197,21 +1181,32 @@ network_dst_address_refresh()
then
proxy_host="proxy${BASH_REMATCH[1]}.${NETWORK_DST_PROXY_NAME}"
if [[ ( "${dst_ip}" != "0.0.0.0") && ( "${dst_status}" != 1)]]
if [[ ( "${dst_status}" == 1) || ( ( "${dst_status}" != 1) && ( "${dst_ip}" != "0.0.0.0")) ]]
then
dst_ip_new="0.0.0.0"
else
dst_ip_new="$( nc -w ${NETWORK_NC_TIMEOUT} ${proxy_host} ${proxy_port} 2>/dev/null)"
fi
if [[ ( ( "${dst_ip}" != "0.0.0.0") && ( "${dst_status}" != 1)) ]]
then
log_info "Network" "Reseting IP: [${dst_host_name}]: IP: [${dst_ip_new}] Status: (${dst_status})"
dst_ip_new="0.0.0.0"
else
dst_ip_new="$( nc -w "${NETWORK_NC_TIMEOUT}" "${proxy_host}" "${proxy_port}" 2>/dev/null)"
fi
if is_valid_ip "${dst_ip_new}"
then
network_dst_ip_update "${dst_ip_new}"
if is_valid_ip "${dst_ip_new}"
then
if [[ "${dst_ip}" != "${dst_ip_new}" ]]
then
network_dst_ip_update "${dst_ip_new}"
else
log_trace "Network" "Skiping: [${dst_host_name}]: No changes..."
fi
else
log_info "Network" "Skiping: [${dst_host_name}]: Invalid IP: [${dst_ip_new}]"
fi
else
log_info "Network" "Skiping: [${dst_host_name}]: Invalid IP: [${dst_ip_new}]"
log_trace "Network" "Skiping: [${dst_host_name}]: Device not Up..."
fi
else
log_info "Network" "Skiping: dst_id: [${dst_id}]: Invalid host_name: [${dst_host_name}]"
log_info "Network" "Skiping: dst_id: [${dst_id}]: Invalid host_name: [${dst_host_name}]"
fi
fi
}
@@ -1549,6 +1544,23 @@ network_init()
network_deinit()
{
NETWORK_OPENVPN_STATUS=""
NETWORK_IP_ROUTE_TAB=()
NETWORK_IP_ROUTE_ID_LIST=""
NETWORK_IP_ROUTE_IP_IDX=()
NETWORK_SRC_TYPE=""
NETWORK_SRC_TAB=()
NETWORK_SRC_ID_LIST=""
NETWORK_SRC_IP_IDX=()
NETWORK_DST_TYPE=""
NETWORK_DST_TAB=()
NETWORK_DST_ID_LIST=""
NETWORK_DST_NAME_IDX=()
NETWORK_DST_DEV_IDX=()
dns_deinit
}
@@ -1556,6 +1568,20 @@ network_deinit()
#--------------------------------------------------------------------------------------------------------------------------
# network_reinit
#--------------------------------------------------------------------------------------------------------------------------
network_reinit()
{
network_deinit
network_init
}
#--------------------------------------------------------------------------------------------------------------------------
# network_start
#--------------------------------------------------------------------------------------------------------------------------

View File

@@ -1,23 +1,48 @@
#!/bin/bash -x
#!/bin/bash
#-----------------------------------------------------------------------------------------------------------------------------------
#
# Rx3 VPN Library
#
# Copyright (C) 2025-2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
#
# This is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; If not, see
# <https://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------------------------------------------------------------
if [[ "${VPN_BASH}" != "" ]]
if [[ "${RX3_VPN_LIB}" != "" ]]
then
return
else
declare -g VPN_BASH=1
declare -g RX3_VPN_LIB=1
fi
#-----------------------------------------------------------------------------------------------------------------------------------
# Includes
#-----------------------------------------------------------------------------------------------------------------------------------
. /usr/local/lib/network.bash
: "${RX3_LIB_DIR:=/usr/lib/rx3}"
. "${RX3_LIB_DIR}/network.bash"
#-----------------------------------------------------------------------------------------------------------------------------------
# Global Variable
#-----------------------------------------------------------------------------------------------------------------------------------
@@ -348,6 +373,8 @@ vpn_supervisor()
log_trace "VPN" "Refreshing DNS entries..."
network_dst_address_refresh_all
network_reinit
done
}

View File

@@ -1,10 +0,0 @@
#!/bin/bash
dev=$1
if [[ "$1" != "" ]]
then
cat /etc/openvpn/openvpn-status-$dev.log
else
awk '{print FILENAME ": " $0}' /etc/openvpn/openvpn-status-*.log
fi

10
usr/sbin/openvpn-status Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
dev=$1
if [[ "$1" != "" ]]
then
cat /var/lib/openvpn/$dev.status
else
awk '{print FILENAME ": " $0}' /var/lib/openvpn/*.status
fi

View File

@@ -1,4 +1,43 @@
#!/bin/bash
#-----------------------------------------------------------------------------------------------------------------------------------
#
# Rx3 Net Adm
#
# Copyright (C) 2025-2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
#
# This is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; If not, see
# <https://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------
# Includes
#-----------------------------------------------------------------------------------------------------------------------------------
: "${RX3_LIB_DIR:=/usr/lib/rx3}"
. "${RX3_LIB_DIR}/network.bash"
#-----------------------------------------------------------------------------------------------------------------------------------
# Global Variable
#-----------------------------------------------------------------------------------------------------------------------------------
RETVAL=0
prog="rx3-net"
@@ -12,13 +51,6 @@ prog="rx3-net"
# Includes
#-----------------------------------------------------------------------------------------------------------------------------------
. /usr/local/lib/network.bash
#--------------------------------------------------------------------------------------------------------------------------

View File

@@ -125,33 +125,35 @@ Destination_Status_Board()
dst_ip="-"
fi
if [[ "${format}" == "html" ]]
if [[ ( "${status}" == "" ) || ( "${status}" == "${dst_status}") ]]
then
echo -n "<TR><TD class="header">${dst_id}</TD><TD>${dst_name}</TD><TD>${NETWORK_DST_TYPE[${dst_type}]}</TD><TD>${dst_device}</TD>"
if [[ "${format}" == "html" ]]
then
echo -n "<TR><TD class="header">${dst_id}</TD><TD>${dst_name}</TD><TD>${NETWORK_DST_TYPE[${dst_type}]}</TD><TD>${dst_device}</TD>"
case "${dst_status}"
in
"0")
echo -n "<TD><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Down\" ALT=\"Down\"></TD>"
;;
case "${dst_status}"
in
"0")
echo -n "<TD><A HREF=\"?admin=${admin}&amp;user=${user}&amp;status=${dst_status}\"><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Down\" ALT=\"Down\"></A></TD>"
;;
"1")
echo -n "<TD><IMG SRC=\"/icons/user-online.png\" TITLE=\"Up\" ALT=\"Up\"></TD>"
;;
"1")
echo -n "<TD><A HREF=\"?admin=${admin}&amp;user=${user}&amp;status=${dst_status}\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Up\" ALT=\"Up\"></A></TD>"
;;
"2")
echo -n "<TD><IMG SRC=\"/icons/user-unready.png\" TITLE=\"Unready\" ALT=\"Unready\"></TD>"
;;
"2")
echo -n "<TD><A HREF=\"?admin=${admin}&amp;user=${user}&amp;status=${dst_status}\"><IMG SRC=\"/icons/user-unready.png\" TITLE=\"Unready\" ALT=\"Unready\"></A></TD>"
;;
*)
echo -n "<TD><IMG SRC=\"\" TITLE=\"Unknown\" ALT=\"Unknown\"></TD>"
;;
esac
*)
echo -n "<TD><IMG SRC=\"\" TITLE=\"Unknown\" ALT=\"Unknown\"></TD>"
;;
esac
echo "<TD>${dst_ip:--}</TD><TD>${dst_host_name:--}</TD><TD>${dst_config:--}</TD><TD>${dst_table}</TD><TD>${dst_bytes_received:--}</TD><TD>${dst_bytes_sent:--}</TD><TD>${dst_uptime:--}</TD>"
else
echo "${dst_id};${dst_name};${NETWORK_DST_TYPE[${dst_type}]};${dst_device};${dst_status};${dst_ip};${dst_host_name};${dst_config};${dst_table};${dst_bytes_received};${dst_bytes_sent};${dst_uptime}"
echo "<TD>${dst_ip:--}</TD><TD>${dst_host_name:--}</TD><TD>${dst_config:--}</TD><TD>${dst_table}</TD><TD>${dst_bytes_received:--}</TD><TD>${dst_bytes_sent:--}</TD><TD>${dst_uptime:--}</TD>"
else
echo "${dst_id};${dst_name};${NETWORK_DST_TYPE[${dst_type}]};${dst_device};${dst_status};${dst_ip};${dst_host_name};${dst_config};${dst_table};${dst_bytes_received};${dst_bytes_sent};${dst_uptime}"
fi
fi
done
@@ -179,13 +181,13 @@ Source_Routing_Board_Line()
network_src_tab_get ${src_id}
if [[ ( "${filter}" == "") || ( "${filter}" == "owner") || ( "${filter}" == "${src_owner}") ]]
if [[ ( "${user}" == "") || ( "${user}" == "owner") || ( "${user}" == "${src_owner}") ]]
then
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
then
class="default"
else
if [[ "${filter}" == "owner" ]]
if [[ "${user}" == "owner" ]]
then
class="skip"
else
@@ -193,11 +195,16 @@ Source_Routing_Board_Line()
fi
fi
else
# filter == user not owner of this line
# user == user not owner of this line
class="skip"
fi
if [[ ( "${status}" != "") && ( "${status}" != "${src_status}") ]]
then
class="skip"
fi
if [[ "${class}" != "skip" ]]
then
@@ -212,19 +219,19 @@ Source_Routing_Board_Line()
case "${src_status}"
in
"0")
echo -n "<TD><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Down\" ALT=\"Down\"></TD>"
echo -n "<TD><A HREF=\"?admin=${admin}&amp;user=${user}&amp;status=${src_status}\"><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Down\" ALT=\"Down\"></A></TD>"
;;
"1")
echo -n "<TD><IMG SRC=\"/icons/user-online.png\" TITLE=\"Up\" ALT=\"Up\"></TD>"
echo -n "<TD><A HREF=\"?admin=${admin}&amp;user=${user}&amp;status=${src_status}\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Up\" ALT=\"Up\"></A></TD>"
;;
"2")
echo -n "<TD>-</TD>"
echo -n "<TD><A HREF=\"?admin=${admin}&amp;user=${user}&amp;status=${src_status}\">-</A></TD>"
;;
esac
else
echo -n "${src_id};${NETWORK_SRC_TYPE[${src_type}]};${src_ip};${src_host_name};${src_device};${status};"
echo -n "${src_id};${NETWORK_SRC_TYPE[${src_type}]};${src_ip};${src_host_name};${src_device};${src_status};"
fi
@@ -246,7 +253,7 @@ Source_Routing_Board_Line()
if [[ ( ${admin} == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
then
echo -n "<A HREF=\"?cmd=route_set&amp;admin=${admin}&amp;filter=${filter}&amp;ip=${src_ip}&amp;vpn=${dst_id}\"><IMG SRC=\"/icons/user-invisible.png\" TITLE=\"Activate\" ALT=\"Activate\"></A>"
echo -n "<A HREF=\"?cmd=route_set&amp;admin=${admin}&amp;user=${user}&amp;status=${status}&amp;ip=${src_ip}&amp;vpn=${dst_id}\"><IMG SRC=\"/icons/user-invisible.png\" TITLE=\"Activate\" ALT=\"Activate\"></A>"
else
echo -n "&nbsp;"
fi
@@ -274,7 +281,7 @@ Source_Routing_Board_Line()
echo -n "<TD>${src_port_range}</TD><TD>-</TD><TD>-</TD>"
fi
echo "<TD><A HREF=\"?admin=${admin}&amp;filter=${src_owner}\">${src_owner}</A></TD><TD>${src_bytes_received:--}</TD><TD>${src_bytes_sent:--}</TD><TD>${src_uptime:--}</TD><TD>${src_last_seen:--}</TD></TR>"
echo "<TD><A HREF=\"?admin=${admin}&amp;user=${src_owner}&amp;status=${status}\">${src_owner}</A></TD><TD>${src_bytes_received:--}</TD><TD>${src_bytes_sent:--}</TD><TD>${src_uptime:--}</TD><TD>${src_last_seen:--}</TD></TR>"
else
echo "${src_port_range};${src_port_start};${src_port_end};${src_owner};${src_bytes_received};${src_bytes_sent};${src_uptime};${src_last_seen}"
fi
@@ -378,13 +385,13 @@ VPN_OpenVPN_Board()
if [[ "${src_type}" == 2 ]]
then
if [[ ( "${filter}" == "") || ( "${filter}" == "owner") || ( "${filter}" == "${src_owner}") ]]
if [[ ( "${user}" == "") || ( "${user}" == "owner") || ( "${user}" == "${src_owner}") ]]
then
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
then
class="default"
else
if [[ "${filter}" == "owner" ]]
if [[ "${user}" == "owner" ]]
then
class="skip"
else
@@ -392,30 +399,36 @@ VPN_OpenVPN_Board()
fi
fi
else
# filter == user not owner of this line
# user == user not owner of this line
class="skip"
fi
if [[ ( "${status}" != "") && ( "${status}" != "${src_status}") ]]
then
class="skip"
fi
if [[ "${class}" != "skip" ]]
then
if [[ "${format}" == "html" ]]
then
echo -n " <TR class=\"${class}\"><TD class=\"header\">${idx}</TD><TD>${src_ip}</TD><TD>${src_host_name}</TD>"
echo -n "<TD><A HREF=\"?cmd=config_download&amp;admin=${admin}&amp;filter=${filter}&amp;ip=${src_ip}&amp;defroute=true&amp;type=ext\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Default Route External Certificates\" ALT=\"Configuration External Certificates\"></A></TD>"
echo -n "<TD><A HREF=\"?cmd=config_download&amp;admin=${admin}&amp;user=${user}&amp;status=${status}&amp;ip=${src_ip}&amp;defroute=true&amp;type=ext\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Default Route External Certificates\" ALT=\"Configuration External Certificates\"></A></TD>"
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
then
echo -n "<TD><A HREF=\"?cmd=config_download&amp;admin=${admin}&amp;filter=${filter}&amp;ip=${src_ip}&amp;defroute=true&amp;type=inline\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Default Route Inline Certificates\" ALT=\"Configuration Inline Certificates\"></A></TD>"
echo -n "<TD><A HREF=\"?cmd=config_download&amp;admin=${admin}&amp;user=${user}&amp;status=${status}&amp;ip=${src_ip}&amp;defroute=true&amp;type=inline\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Default Route Inline Certificates\" ALT=\"Configuration Inline Certificates\"></A></TD>"
else
echo -n "<TD><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Inline Certificates\" ALT=\"Configuration Inline Certificates\"></TD>"
fi
echo -n "<TD><A HREF=\"?cmd=config_download&amp;admin=${admin}&amp;filter=${filter}&amp;ip=${src_ip}&amp;defroute=false&amp;type=ext\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration NoDefault Route External Certificates\" ALT=\"Configuration External Certificates\"></A></TD>"
echo -n "<TD><A HREF=\"?cmd=config_download&amp;admin=${admin}&amp;user=${user}&amp;status=${status}&amp;ip=${src_ip}&amp;defroute=false&amp;type=ext\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration NoDefault Route External Certificates\" ALT=\"Configuration External Certificates\"></A></TD>"
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
then
echo -n "<TD><A HREF=\"?cmd=config_download&amp;admin=${admin}&amp;filter=${filter}&amp;ip=${src_ip}&amp;defroute=false&amp;type=inline\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration NoDefault Route Inline Certificates\" ALT=\"Configuration Inline Certificates\"></A></TD>"
echo -n "<TD><A HREF=\"?cmd=config_download&amp;admin=${admin}&amp;user=${user}&amp;status=${status}&amp;ip=${src_ip}&amp;defroute=false&amp;type=inline\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration NoDefault Route Inline Certificates\" ALT=\"Configuration Inline Certificates\"></A></TD>"
else
echo -n "<TD><IMG SRC=\"/icons/user-online.png\" TITLE=\"Configuration Inline Certificates\" ALT=\"Configuration Inline Certificates\"></TD>"
fi
@@ -425,17 +438,17 @@ VPN_OpenVPN_Board()
if [[ "${format}" == "html" ]]
then
echo -n "<TD><A HREF=\"?cmd=cert_download&amp;admin=${admin}&amp;filter=${filter}&amp;ip=${src_ip}&amp;type=ca\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"CA Certificate\" ALT=\"CA Certificate\"></A></TD>"
echo -n "<TD><A HREF=\"?cmd=cert_download&amp;admin=${admin}&amp;user=${user}&amp;status=${status}&amp;ip=${src_ip}&amp;type=ca\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"CA Certificate\" ALT=\"CA Certificate\"></A></TD>"
if [[ ( "${admin}" == "true") || ( "${REMOTE_USER}" == "${src_owner}") ]]
then
echo -n "<TD><A HREF=\"?cmd=cert_download&amp;admin=${admin}&amp;filter=${filter}&amp;ip=${src_ip}&amp;type=tc\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"TC Certificate\" ALT=\"TC Certificate\"></A></TD>"
echo -n "<TD><A HREF=\"?cmd=cert_download&amp;admin=${admin}&amp;user=${user}&amp;status=${status}&amp;ip=${src_ip}&amp;type=tc\" ><IMG SRC=\"/icons/user-online.png\" TITLE=\"TC Certificate\" ALT=\"TC Certificate\"></A></TD>"
if [[ -f /etc/openvpn/tls/certs/${src_host_name}.crt ]]
then
echo -n "<TD><A HREF=\"?cmd=cert_download&amp;admin=${admin}&amp;filter=${filter}&amp;ip=${src_ip}&amp;type=key\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Private Key\" ALT=\"Private Key\"></A></TD>"
echo -n "<TD><A HREF=\"?cmd=cert_download&amp;admin=${admin}&amp;filter=${filter}&amp;ip=${src_ip}&amp;type=csr\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Certificate Signing Request\" ALT=\"Certificat Signing Request\"></A></TD>"
echo "<TD><A HREF=\"?cmd=cert_download&amp;admin=${admin}&amp;filter=${filter}&amp;ip=${src_ip}&amp;type=crt\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Public Certificate\" ALT=\"Public Certificate\"></A></TD></TR>"
echo -n "<TD><A HREF=\"?cmd=cert_download&amp;admin=${admin}&amp;user=${user}&amp;status=${status}&amp;ip=${src_ip}&amp;type=key\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Private Key\" ALT=\"Private Key\"></A></TD>"
echo -n "<TD><A HREF=\"?cmd=cert_download&amp;admin=${admin}&amp;user=${user}&amp;status=${status}&amp;ip=${src_ip}&amp;type=csr\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Certificate Signing Request\" ALT=\"Certificat Signing Request\"></A></TD>"
echo "<TD><A HREF=\"?cmd=cert_download&amp;admin=${admin}&amp;user=${user}&amp;status=${status}&amp;ip=${src_ip}&amp;type=crt\"><IMG SRC=\"/icons/user-online.png\" TITLE=\"Public Certificate\" ALT=\"Public Certificate\"></A></TD></TR>"
else
echo -n "<TD><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Private Key\" ALT=\"Private Key\"></TD>"
echo -n "<TD><IMG SRC=\"/icons/user-busy.png\" TITLE=\"Certificat Signing Request\" ALT=\"Certificat Signing Request\"></TD>"
@@ -497,22 +510,46 @@ Main_Board_Print()
admin_mode=""
fi
case "${filter}"
case "${user}"
in
"owner")
filter_mode="My VPN"
"")
user_mode="All"
;;
"")
filter_mode="All VPN"
"owner")
user_mode="My"
;;
*)
filter_mode="${filter} VPN"
user_mode="${user}"
;;
esac
echo " <H1>VPN Admin Board: ${filter_mode}${admin_mode}</H1>"
case "${status}"
in
"")
status_mode="All"
;;
"0")
status_mode="Down"
;;
"1")
status_mode="UP"
;;
"2")
status_mode="Not Conected"
;;
*)
status_mode="Unkwown"
;;
esac
echo " <H1>VPN Admin Board: ${user_mode} VPN - ${status_mode} Status${admin_mode}</H1>"
echo " <P>"
@@ -539,17 +576,23 @@ Main_Board_Print()
then
if [[ "${admin}" == "true" ]]
then
echo -n "<A HREF=\"?filter=${filter}\">Non Admin Mode</A>"
echo -n "<A HREF=\"?user=${user}&amp;status=${status}\">Non Admin Mode</A>"
else
echo -n "<A HREF=\"?admin=true&amp;filter=${filter}\">Admin Mode</A>"
echo -n "<A HREF=\"?admin=true&amp;user=${user}&amp;status=${status}\">Admin Mode</A>"
fi
echo -n "&nbsp;&nbsp;&nbsp;"
fi
if [[ "${filter}" != "" ]]
if [[ "${user}" != "" ]]
then
echo -n "<A HREF=\"?admin=${admin}\">All VPN</A>"
echo -n "<A HREF=\"?admin=${admin}&amp;status=${status}\">All VPN</A>"
echo -n "&nbsp;&nbsp;&nbsp;"
fi
if [[ "${status}" != "" ]]
then
echo -n "<A HREF=\"?admin=${admin}&amp;user=${user}\">All Status</A>"
fi
echo ""
@@ -598,7 +641,8 @@ Main_Board_Print()
cmd=""
format=""
filter=""
user=""
status=""
ip=""
vpn=""
type=""
@@ -638,6 +682,14 @@ then
filter=${arg}
;;
"user")
user=${arg}
;;
"status")
status=${arg}
;;
"ip")
ip=${arg}
;;
@@ -685,7 +737,7 @@ if [[ ( ${admin} == "true") && ( " ${ADMIN_USER_LIST} " != *" ${REMOTE_USER} "*)
then
cmd_status="${cmd}: Admin NOT_AUTHORIZED"
redirect="?filter=${filter}"
redirect="?user=${user}&up=${up}"
Header_Print
Footer_Print