mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-11-01 02:48:18 +00:00
uspot: accounting: use explicit variable names
And avoid enumerating unused values in k,v pairs Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
This commit is contained in:
committed by
John Crispin
parent
60c708dce9
commit
c6d07ca178
@@ -226,41 +226,41 @@ function accounting(interface) {
|
|||||||
let list = ubus.call('spotfilter', 'client_list', { interface });
|
let list = ubus.call('spotfilter', 'client_list', { interface });
|
||||||
let t = time();
|
let t = time();
|
||||||
|
|
||||||
for (let k, v in list)
|
for (let mac, payload in list)
|
||||||
if (!clients[interface][k])
|
if (!clients[interface][mac])
|
||||||
client_add(interface, k, v);
|
client_add(interface, mac, payload);
|
||||||
|
|
||||||
for (let k, v in clients[interface]) {
|
for (let mac in clients[interface]) {
|
||||||
if (list[k].data?.logoff) {
|
if (list[mac].data?.logoff) {
|
||||||
radius_logoff(interface, k);
|
radius_logoff(interface, mac);
|
||||||
client_flush(interface, k, 'logoff event');
|
client_flush(interface, mac, 'logoff event');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!list[k] || !list[k].state) {
|
if (!list[mac] || !list[mac].state) {
|
||||||
radius_disconnect(interface, k);
|
radius_disconnect(interface, mac);
|
||||||
client_remove(interface, k, 'disconnect event');
|
client_remove(interface, mac, 'disconnect event');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list[k].idle > get_idle_timeout(interface, k)) {
|
if (list[mac].idle > get_idle_timeout(interface, mac)) {
|
||||||
if (clients[interface][k])
|
if (clients[interface][mac])
|
||||||
radius_idle_time(interface, k);
|
radius_idle_time(interface, mac);
|
||||||
client_remove(interface, k, 'idle event');
|
client_remove(interface, mac, 'idle event');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let timeout = get_session_timeout(interface, k);
|
let timeout = get_session_timeout(interface, mac);
|
||||||
if (timeout && ((t - list[k].data.connect) > timeout)) {
|
if (timeout && ((t - list[mac].data.connect) > timeout)) {
|
||||||
if (clients[interface][k])
|
if (clients[interface][mac])
|
||||||
radius_session_time(interface, k);
|
radius_session_time(interface, mac);
|
||||||
client_flush(interface, k, 'session timeout');
|
client_flush(interface, mac, 'session timeout');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (clients[interface][k].max_total) {
|
if (clients[interface][mac].max_total) {
|
||||||
let total = list[k].bytes_ul + list[k].bytes_dl;
|
let total = list[mac].bytes_ul + list[mac].bytes_dl;
|
||||||
if (total >= clients[interface][k].max_total) {
|
if (total >= clients[interface][mac].max_total) {
|
||||||
radius_session_time(interface, k);
|
radius_session_time(interface, mac);
|
||||||
client_flush(interface, k, 'max octets reached');
|
client_flush(interface, mac, 'max octets reached');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,7 +269,7 @@ function accounting(interface) {
|
|||||||
uloop.init();
|
uloop.init();
|
||||||
|
|
||||||
uloop.timer(1000, function() {
|
uloop.timer(1000, function() {
|
||||||
for (let interface, v in clients)
|
for (let interface in clients)
|
||||||
accounting(interface);
|
accounting(interface);
|
||||||
this.set(1000);
|
this.set(1000);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user