From a9df4b8549a50fbfd1bc1ff120c02cc564f9850a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20VAR=C3=88NE?= Date: Tue, 23 May 2023 15:39:58 +0200 Subject: [PATCH] uspot: accounting: use variables instead of function calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thibaut VARĂˆNE --- .../uspot/files/usr/share/uspot/accounting.uc | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/feeds/ucentral/uspot/files/usr/share/uspot/accounting.uc b/feeds/ucentral/uspot/files/usr/share/uspot/accounting.uc index c1d5df415..62d196ada 100755 --- a/feeds/ucentral/uspot/files/usr/share/uspot/accounting.uc +++ b/feeds/ucentral/uspot/files/usr/share/uspot/accounting.uc @@ -16,18 +16,6 @@ if (!config) { exit(1); } -function acct_interval(interface) { - return config[interface].acct_interval || 600; -} - -function idle_timeout(interface) { - return config[interface].idle_timeout || 600; -} - -function session_timeout(interface) { - return config[interface].session_timeout || 0; -} - uci.foreach('uspot', 'uspot', (d) => { if (!d[".anonymous"]) clients[d[".name"]] = {}; @@ -154,10 +142,19 @@ function client_add(interface, mac, state) { if (state.state != 1) return; + let defval = 0; + let accounting = (config[interface].acct_server && config[interface].acct_secret); - let interval = (state.data?.radius?.reply['Acct-Interim-Interval'] || acct_interval(interface)) * 1000; - let session = (state.data?.radius?.reply['Session-Timeout'] || session_timeout(interface)); - let idle = (state.data?.radius?.reply['Idle-Timeout'] || idle_timeout(interface)); + + defval = config[interface].acct_interval || 600; + let interval = (state.data?.radius?.reply['Acct-Interim-Interval'] || defval) * 1000; + + defval = config[interface].session_timeout || 0; + let session = (state.data?.radius?.reply['Session-Timeout'] || defval); + + defval = config[interface].idle_timeout || 600; + let idle = (state.data?.radius?.reply['Idle-Timeout'] || defval); + let max_total = (state.data?.radius?.reply['ChilliSpot-Max-Total-Octets'] || 0); clients[interface][mac] = {