From 07a645d9cffbccadbd2c1263b18b87c790023930 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Sat, 6 Sep 2025 14:26:05 -0400 Subject: [PATCH 1/3] Fix Flow Cache Control with Schedule Fix Flow Cache Control with Schedule --- Changelog.txt | 4 ++ flexqos.sh | 109 ++++++++++++++++++++++++++++++++++---------------- 2 files changed, 78 insertions(+), 35 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 3a32b02..e672d19 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,7 @@ +v1.5.1 (06-Sep-2025) + - FIXED: Properly compare version by using arithmetic conversation + - FIXED: Fixed new Schedule keeping Flow Cache Disabled when disabling QoS + v1.5.0 (06-Sep-2025) - FIXED: Allow script versions with double-digit segments. diff --git a/flexqos.sh b/flexqos.sh index 92582a6..75ddfcb 100644 --- a/flexqos.sh +++ b/flexqos.sh @@ -12,8 +12,8 @@ # Contributors: @maghuro # shellcheck disable=SC1090,SC1091,SC2039,SC2154,SC3043 # amtm NoMD5check -version=1.5.0 -release=2025-09-06 +version=1.5.1 +release=2025-09-xx # Forked from FreshJR_QOS v8.8, written by FreshJR07 https://github.com/FreshJR07/FreshJR_QOS # License # FlexQoS is free to use under the GNU General Public License, version 3 (GPL-3.0). @@ -1029,20 +1029,28 @@ compare_remote_version() { # Check version on Github and determine the difference with the installed version # Outcomes: Version update, or no update local remotever - # Fetch version of the shell script on Github - remotever="$(curl -fsN --retry 3 --connect-timeout 3 \ + + remotever="$(curl -fsS --retry 3 --connect-timeout 3 \ "${GIT_URL}/$(basename "${SCRIPTPATH}")" \ | /bin/grep '^version=' \ - | sed -e 's/^version=//' -e 's/"//g' -e 's/\r//g')" + | sed -e 's/^version=//' -e 's/"//g' -e 's/\r//g' -e 's/[^0-9.]//g')" + + # Convert 1.5.0 -> 001005000 (4 parts just in case) + ver2int() { + local a b c d IFS=. + set -- $1 + a=${1:-0}; b=${2:-0}; c=${3:-0}; d=${4:-0} + printf '%03d%03d%03d%03d\n' "$a" "$b" "$c" "$d" + } - if [ "$( echo "${version}" | sed 's/\.//g' )" -lt \ - "$( echo "${remotever}" | sed 's/\.//g' )" ]; then - # version upgrade - echo "${remotever}" + [ -z "$remotever" ] && { printf 'Error\n'; return; } + + if [ "$(ver2int "$version")" -lt "$(ver2int "$remotever")" ]; then + printf '%s\n' "$remotever" else - printf "NoUpdate\n" + printf 'NoUpdate\n' fi -} # compare_remote_version +} update() { # Check for, and optionally apply updates. @@ -1114,6 +1122,54 @@ _flush_conntrack_(){ fi } +_fc_apply_policy() { + # $1 = "on" (QoS being enabled) -> maybe DISABLE FC (Auto/Force) + # $1 = "off" (QoS being disabled) -> maybe ENABLE FC (Auto) + case "$(uname -r)" in + 4.19.*) + # Make sure we have current settings + [ -z "${fccontrol}${iptables_rules}" ] && get_config + + case "${1}" in + on) + # Mirror the existing startup() logic + if [ -n "${iptables_rules}" ]; then + if [ "${fccontrol}" = "1" ]; then + # Force disable + if [ "$(nvram get fc_disable)" != "1" ]; then + logmsg "Disabling flowcache" + fc disable + fc flush + fi + elif [ "${fccontrol}" = "2" ]; then + # Auto: only if <400 Mbps both ways and FC currently enabled + if \ + [ "$(printf "%.0f" "$(nvram get qos_ibw)")" -lt 409600 ] && \ + [ "$(printf "%.0f" "$(nvram get qos_obw)")" -lt 409600 ] && \ + [ "$(nvram get fc_disable)" = "0" ] + then + logmsg "Auto-disabling flowcache" + fc disable + fc flush + fi + fi + fi + ;; + off) + # When QoS is turned off by schedule, *re-enable* FC in Auto mode + if [ "${fccontrol}" = "2" ]; then + if [ "$(nvram get fc_disable)" != "0" ]; then + logmsg "QoS disabled by schedule; re-enabling flowcache (Auto)" + fc enable + fc flush + fi + fi + ;; + esac + ;; + esac +} + prompt_restart() { # Restart QoS so that FlexQoS changes can take effect. # Possible values for $needrestart: @@ -1152,6 +1208,7 @@ qos_stop() { if [ "${need_stop}" = "1" ]; then service stop_qos + _fc_apply_policy off prompt_restart _flush_conntrack_ # Only persist if explicitly requested @@ -1180,6 +1237,7 @@ qos_start() { if [ "${need_start}" = "1" ]; then service start_qos + _fc_apply_policy on prompt_restart _flush_conntrack_ # Only persist if explicitly requested @@ -2218,30 +2276,11 @@ startup() { generate_bwdpi_arrays get_config qos_schedule_apply_from_config - - case "$(uname -r)" in - 4.19.*) - if \ - [ "$(printf "%.0f" "$(nvram get qos_ibw)")" -lt 409600 ] && \ - [ "$(printf "%.0f" "$(nvram get qos_obw)")" -lt 409600 ] && \ - [ "$(nvram get fc_disable)" = "0" ] && \ - [ -n "${iptables_rules}" ] && \ - [ "${fccontrol}" = "2" ] - then - logmsg "Auto-disabling flowcache" - fc disable - fc flush - elif \ - [ -n "${iptables_rules}" ] && \ - [ "${fccontrol}" = "1" ] - then - logmsg "Disabling flowcache" - fc disable - fc flush - fi - ;; - esac - + if [ "$(nvram get qos_enable)" = "1" ]; then + _fc_apply_policy on + else + _fc_apply_policy off + fi _flush_conntrack_ cru d "${SCRIPTNAME}"_5min 2>/dev/null From 7496e7d4fb21737ced8bab71f5f5f8f39fc97759 Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Sat, 6 Sep 2025 14:42:58 -0400 Subject: [PATCH 2/3] Typos Typos --- Changelog.txt | 2 +- flexqos.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index e672d19..dc7f3e6 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,6 @@ v1.5.1 (06-Sep-2025) - FIXED: Properly compare version by using arithmetic conversation - - FIXED: Fixed new Schedule keeping Flow Cache Disabled when disabling QoS + - FIXED: Fixed new schedule keeping Flow Cache disabled when disabling QoS v1.5.0 (06-Sep-2025) - FIXED: Allow script versions with double-digit segments. diff --git a/flexqos.sh b/flexqos.sh index 75ddfcb..030eac3 100644 --- a/flexqos.sh +++ b/flexqos.sh @@ -13,7 +13,7 @@ # shellcheck disable=SC1090,SC1091,SC2039,SC2154,SC3043 # amtm NoMD5check version=1.5.1 -release=2025-09-xx +release=2025-09-06 # Forked from FreshJR_QOS v8.8, written by FreshJR07 https://github.com/FreshJR07/FreshJR_QOS # License # FlexQoS is free to use under the GNU General Public License, version 3 (GPL-3.0). From 1b8e599d327b237d6218edec8f414b90f545351d Mon Sep 17 00:00:00 2001 From: ExtremeFiretop Date: Sat, 6 Sep 2025 14:51:48 -0400 Subject: [PATCH 3/3] Typos Typos --- Changelog.txt | 2 +- flexqos.asp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index dc7f3e6..b94181c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,5 @@ v1.5.1 (06-Sep-2025) - - FIXED: Properly compare version by using arithmetic conversation + - FIXED: Properly compare version by using arithmetic conversion - FIXED: Fixed new schedule keeping Flow Cache disabled when disabling QoS v1.5.0 (06-Sep-2025) diff --git a/flexqos.asp b/flexqos.asp index 8c5a25c..8a614c1 100644 --- a/flexqos.asp +++ b/flexqos.asp @@ -3104,7 +3104,7 @@ function DelCookie(cookiename){ - +
Add schedule windowAdd schedule