Skip to content

Commit

Permalink
Update wg_manager.sh
Browse files Browse the repository at this point in the history
	CHANGE: Flow Cache is no longer auto-disabled for ANY router model (previously two models:RT-AX86U/RT-AX58U were EXPLICITLY hard-coded to DISABLE Flow Cache); instead users must now EXPLICITLY uncomment DISABLE_FLOW_CACHE directive using command 'vx'
CHANGE: When all 'client' Peers have been stopped, ensure Flow Cache is ENABLED
CHANGE: WebUI Beta v0.15 now uses 'checkboxes' rather than 'radio' buttons as the listed configuration settings items are not mutually exclusive.
CHANGE: WebUI Beta v0.15 'Connected' checkbox (which displays the state of the 'client' Peer) is also an active button and can toggle (stop/start) the 'client' Peer if clicked.
  • Loading branch information
MartineauUK committed Jul 12, 2022
1 parent 88b6846 commit 99f3a99
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions wg_manager.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# shellcheck disable=SC2039,SC2155,SC2124,SC2046,SC2027
VERSION="v4.18b2"
#============================================================================================ © 2021-2022 Martineau v4.18b2
VERSION="v4.18b3"
#============================================================================================ © 2021-2022 Martineau v4.18b3
#
# wgm [ help | -h ]
# wgm [ { start | stop | restart } [wg_interface]... ]
Expand Down Expand Up @@ -33,7 +33,7 @@ VERSION="v4.18b2"
#

# Maintainer: Martineau
# Last Updated Date: 10-Jul-2022
# Last Updated Date: 12-Jul-2022

#
# Description:
Expand Down Expand Up @@ -2521,6 +2521,11 @@ Manage_Wireguard_Sessions() {
fi
done

# If there are no active 'client' Peers, then enable FC if not EXPLICITY disabled in configuration
if [ -z "$(wg show interfaces | grep "wg1")" ] && [ -z "$(grep -E "^DISABLE_FLOW_CACHE" ${INSTALL_DIR}WireguardVPN.conf)" ];then
[ -z "$(fc status | grep "Flow Learning Enabled")" ] && RC="$(Manage_FC "enable")" # v4.18
fi

# Temporary WebUI hack
if [ "$(nvram get wgmc_unit)" == "${WG_INTERFACE:3:1}" ];then # v4.18
nvram set wgmc_enable="0"
Expand Down Expand Up @@ -8082,9 +8087,11 @@ if [ "$1" != "install" ];then # v2.01
fi

# http://www.snbforums.com/threads/beta-wireguard-session-manager.70787/post-688282
if { [ -f ${INSTALL_DIR}WireguardVPN.conf ] && [ -n "$(grep -E "^DISABLE_FLOW_CACHE" ${INSTALL_DIR}WireguardVPN.conf)" ] ;} || \
[ -n "$(echo "RT-AX86U RT-AX56U" | grep -ow "$HARDWARE_MODEL")" ];then # v4.16 v4.15
RC="$(Manage_FC "disable")" # v4.14
#if { [ -f ${INSTALL_DIR}WireguardVPN.conf ] && [ -n "$(grep -E "^DISABLE_FLOW_CACHE" ${INSTALL_DIR}WireguardVPN.conf)" ] ;} || \
#[ -n "$(echo "RT-AX86U RT-AX56U" | grep -ow "$HARDWARE_MODEL")" ];then # v4.16 v4.15
# Force users to manually set DISABLE_FLOW_CACHE using command 'vx' rather than have the script hard-code the models to always DISABLE_FLOW_CACHE
if [ -f ${INSTALL_DIR}WireguardVPN.conf ] && [ -n "$(grep -E "^DISABLE_FLOW_CACHE" ${INSTALL_DIR}WireguardVPN.conf)" ];then # v4.18
RC="$(Manage_FC "disable")" # v4.14
fi

Manage_Wireguard_Sessions "start" "$PEER" "$NOPOLICY"
Expand All @@ -8094,6 +8101,10 @@ if [ "$1" != "install" ];then # v2.01
;;
stop)
Manage_Wireguard_Sessions "stop" "$PEER" "$NOPOLICY"
# If there are no active 'client' Peers, then enable FC if not EXPLICITY disabled in configuration
if [ -z "$(wg show interfaces | grep "wg1")" ] && [ -z "$(grep -E "^DISABLE_FLOW_CACHE" ${INSTALL_DIR}WireguardVPN.conf)" ];then
[ -z "$(fc status | grep "Flow Learning Enabled")" ] && RC="$(Manage_FC "enable")" # v4.18
fi
echo -e $cRESET
exit_message
;;
Expand Down

0 comments on commit 99f3a99

Please sign in to comment.