mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 01:22:25 +00:00
uspot: accounting: fix loop logic
When looping through known clients: - removal of client in spotfilter list is checked first - checks for known client existence are redundant by construction Also format the max_total check similarly to the timeout one Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
This commit is contained in:
committed by
John Crispin
parent
c6d07ca178
commit
245b062db8
@@ -231,37 +231,33 @@ function accounting(interface) {
|
||||
client_add(interface, mac, payload);
|
||||
|
||||
for (let mac in clients[interface]) {
|
||||
if (list[mac].data?.logoff) {
|
||||
radius_logoff(interface, mac);
|
||||
client_flush(interface, mac, 'logoff event');
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!list[mac] || !list[mac].state) {
|
||||
radius_disconnect(interface, mac);
|
||||
client_remove(interface, mac, 'disconnect event');
|
||||
continue;
|
||||
}
|
||||
|
||||
if (list[mac].data.logoff) {
|
||||
radius_logoff(interface, mac);
|
||||
client_flush(interface, mac, 'logoff event');
|
||||
continue;
|
||||
}
|
||||
|
||||
if (list[mac].idle > get_idle_timeout(interface, mac)) {
|
||||
if (clients[interface][mac])
|
||||
radius_idle_time(interface, mac);
|
||||
radius_idle_time(interface, mac);
|
||||
client_remove(interface, mac, 'idle event');
|
||||
continue;
|
||||
}
|
||||
let timeout = get_session_timeout(interface, mac);
|
||||
if (timeout && ((t - list[mac].data.connect) > timeout)) {
|
||||
if (clients[interface][mac])
|
||||
radius_session_time(interface, mac);
|
||||
radius_session_time(interface, mac);
|
||||
client_flush(interface, mac, 'session timeout');
|
||||
continue;
|
||||
}
|
||||
if (clients[interface][mac].max_total) {
|
||||
let total = list[mac].bytes_ul + list[mac].bytes_dl;
|
||||
if (total >= clients[interface][mac].max_total) {
|
||||
radius_session_time(interface, mac);
|
||||
client_flush(interface, mac, 'max octets reached');
|
||||
}
|
||||
let maxtotal = +clients[interface][mac].max_total;
|
||||
if (maxtotal && ((list[mac].bytes_ul + list[mac].bytes_dl) >= maxtotal)) {
|
||||
radius_session_time(interface, mac);
|
||||
client_flush(interface, mac, 'max octets reached');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user