ufpd: add fingerprint aging

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2024-05-31 12:12:46 +02:00
parent cef663ab58
commit 4fb4a30910

View File

@@ -305,22 +305,22 @@ global.ubus_object = {
args: {
macaddr: "",
weight: false,
age: 1
age: 1,
raw: false
},
call: function(req) {
refresh_plugins();
let mac_list = req.args.macaddr ? [ req.args.macaddr ] : keys(devices);
let ret = {};
if (age)
age = time() - (age * 1000);;
let now = time();
for (let mac in mac_list) {
let match_list = device_match_list(mac);
if (!match_list)
return libubus.STATUS_NOT_FOUND;
if (age && devices[mac].created > age)
if (req.args.age && (now - devices[mac].created) < req.args.age)
continue;
let cur_ret = { };
@@ -340,6 +340,8 @@ global.ubus_object = {
if (req.args.weight)
cur_ret.weight[meta] = match_meta[1];
}
if (req.args.raw)
ret[mac].raw = devices[mac];
}
return req.args.macaddr ? ret[req.args.macaddr] : ret;