From cc99b29886559b85c0e01c8ee1ab0ac5455fef0e Mon Sep 17 00:00:00 2001 From: plumbeo Date: Sat, 3 Dec 2016 18:03:33 +0100 Subject: Captive portal: add option to include idle time in total session time Add an option to choose whether the time spent idle by a user disconnected for exceeding the idle timeout must be included in the total session time sent to the RADIUS server or not. (cherry picked from commit 1878e1c932fa467956ef44d4bd39adb7d4d21243) --- src/etc/inc/captiveportal.inc | 4 +++- src/usr/local/www/services_captiveportal.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/etc/inc/captiveportal.inc b/src/etc/inc/captiveportal.inc index 15f4838..b0f0444 100644 --- a/src/etc/inc/captiveportal.inc +++ b/src/etc/inc/captiveportal.inc @@ -723,7 +723,9 @@ function captiveportal_prune_old() { if ($lastact && (($pruning_time - $lastact) >= $uidletimeout)) { $timedout = true; $term_cause = 4; // Idle-Timeout - $stop_time = $lastact; // Entry added to comply with WISPr + if (!isset($config['captiveportal'][$cpzone]['includeidletime'])) { + $stop_time = $lastact; + } } } diff --git a/src/usr/local/www/services_captiveportal.php b/src/usr/local/www/services_captiveportal.php index 52edb39..8c5fd1c 100644 --- a/src/usr/local/www/services_captiveportal.php +++ b/src/usr/local/www/services_captiveportal.php @@ -222,6 +222,7 @@ if ($a_cp[$cpzone]) { $pconfig['passthrumacaddusername'] = isset($a_cp[$cpzone]['passthrumacaddusername']); $pconfig['radmac_format'] = $a_cp[$cpzone]['radmac_format']; $pconfig['reverseacct'] = isset($a_cp[$cpzone]['reverseacct']); + $pconfig['includeidletime'] = isset($a_cp[$cpzone]['includeidletime']); $pconfig['radiusnasid'] = $a_cp[$cpzone]['radiusnasid']; $pconfig['page'] = array(); if ($a_cp[$cpzone]['page']['htmltext']) { @@ -462,6 +463,7 @@ if ($_POST) { $newcp['passthrumacaddusername'] = $_POST['passthrumacaddusername'] ? true : false; $newcp['radmac_format'] = $_POST['radmac_format'] ? $_POST['radmac_format'] : false; $newcp['reverseacct'] = $_POST['reverseacct'] ? true : false; + $newcp['includeidletime'] = $_POST['includeidletime'] ? true : false; $newcp['radiusnasid'] = trim($_POST['radiusnasid']); if (!is_array($newcp['page'])) { @@ -1018,6 +1020,15 @@ $section->addInput(new Form_Checkbox( ))->setHelp('When enabled, data counts for RADIUS accounting packets will be taken from the client perspective, not the NAS. ' . 'Acct-Input-Octets will represent download, and Acct-Output-Octets will represent upload.'); +$section->addInput(new Form_Checkbox( + 'includeidletime', + 'Idle time accounting', + 'Include idle time in session time', + $pconfig['includeidletime'] +))->setHelp('When enabled, if a client is disconnected for exceeding the idle timeout the time spent idle is included in the total session time. ' . + 'Otherwise the session time reported to the RADIUS server is the time between when the session started and when the last ' . + 'activity was recorded.'); + $section->addInput(new Form_Input( 'radiusnasid', 'NAS Identifier', -- cgit v1.1