mirror of
https://github.com/Akkadius/glass-isc-dhcp.git
synced 2025-07-27 23:54:32 +02:00
Fix issue where unidentified mac's would not show up in device lists
This commit is contained in:
parent
877fbff2c1
commit
e558f1b97e
@ -1,24 +1,40 @@
|
|||||||
var express = require('express');
|
var express = require('express');
|
||||||
var router = express.Router();
|
var router = express.Router();
|
||||||
var fs = require('fs');
|
|
||||||
|
|
||||||
router.get('/', function(req, res, next) {
|
router.get('/', function (req, res, next) {
|
||||||
|
|
||||||
var stat_data = {};
|
var stat_data = {};
|
||||||
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
for (var key in dhcp_lease_data) {
|
for (var key in dhcp_lease_data) {
|
||||||
if((typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc') == "")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(typeof stat_data[(typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc')] === "undefined")
|
/**
|
||||||
stat_data[(typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc')] = 0;
|
* If we don't have a vendor - set as N/A
|
||||||
|
*/
|
||||||
|
if (dhcp_lease_data[key].mac_oui_vendor === "") {
|
||||||
|
dhcp_lease_data[key].mac_oui_vendor = "N/A";
|
||||||
|
}
|
||||||
|
|
||||||
stat_data[(typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" && dhcp_lease_data[key].mac_oui_vendor != "" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc')]++;
|
/**
|
||||||
}
|
* Init array
|
||||||
|
*/
|
||||||
|
if (typeof stat_data[(typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc')] === "undefined")
|
||||||
|
stat_data[(typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc')] = 0;
|
||||||
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
let vendor_string = (typeof dhcp_lease_data[key].mac_oui_vendor !== "undefined" && dhcp_lease_data[key].mac_oui_vendor != "" ? dhcp_lease_data[key].mac_oui_vendor : 'Misc');
|
||||||
res.send(JSON.stringify(stat_data));
|
|
||||||
|
/**
|
||||||
|
* Increment vendor count
|
||||||
|
*/
|
||||||
|
stat_data[vendor_string]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return JSON response
|
||||||
|
*/
|
||||||
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.send(JSON.stringify(stat_data));
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
Loading…
x
Reference in New Issue
Block a user