mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-11-02 11:27:48 +00:00
uspot: accounting: build radius payload from settings
Address RADIUS accounting server from the global settings, and call client_interim() only if accounting is globally enabled for that interface. Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
This commit is contained in:
committed by
John Crispin
parent
b5e33cec05
commit
395e98dc66
@@ -49,12 +49,16 @@ function debug(interface, mac, msg) {
|
|||||||
|
|
||||||
function radius_init(interface, mac, payload) {
|
function radius_init(interface, mac, payload) {
|
||||||
let client = interfaces[interface].clients[mac];
|
let client = interfaces[interface].clients[mac];
|
||||||
for (let key in [ 'server', 'acct_server', 'acct_session', 'client_ip', 'called_station', 'calling_station', 'nas_ip', 'nas_id', 'username', 'location_name' ])
|
let settings = interfaces[interface].settings;
|
||||||
|
|
||||||
|
payload.acct_server = sprintf('%s:%s:%s', settings.acct_server, settings.acct_port, settings.acct_secret);
|
||||||
|
|
||||||
|
for (let key in [ 'acct_session', 'client_ip', 'called_station', 'calling_station', 'nas_ip', 'nas_id', 'username', 'location_name' ])
|
||||||
if (client.radius[key])
|
if (client.radius[key])
|
||||||
payload[key] = client.radius[key];
|
payload[key] = client.radius[key];
|
||||||
|
|
||||||
if (interfaces[interface].settings.acct_proxy)
|
if (settings.acct_proxy)
|
||||||
payload.acct_proxy = interfaces[interface].settings.acct_proxy;
|
payload.acct_proxy = settings.acct_proxy;
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
@@ -124,9 +128,6 @@ function radius_interim(interface, mac) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function client_interim(interface, mac, time) {
|
function client_interim(interface, mac, time) {
|
||||||
if (!interfaces[interface].settings.accounting)
|
|
||||||
return;
|
|
||||||
|
|
||||||
let client = interfaces[interface].clients[mac];
|
let client = interfaces[interface].clients[mac];
|
||||||
|
|
||||||
// preserve a copy of last spotfilter stats for use in disconnect case
|
// preserve a copy of last spotfilter stats for use in disconnect case
|
||||||
@@ -230,6 +231,7 @@ function client_reset(interface, mac, reason) {
|
|||||||
function accounting(interface) {
|
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();
|
||||||
|
let accounting = interfaces[interface].settings.accounting;
|
||||||
|
|
||||||
for (let mac, payload in list)
|
for (let mac, payload in list)
|
||||||
if (!interfaces[interface].clients[mac])
|
if (!interfaces[interface].clients[mac])
|
||||||
@@ -266,7 +268,8 @@ function accounting(interface) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
client_interim(interface, mac, t);
|
if (accounting)
|
||||||
|
client_interim(interface, mac, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user