Prevents split error

if dhcp leases contain malformed data split would have caused errors
This commit is contained in:
Martin Hoffmann 2019-03-27 10:48:01 +01:00
parent bb7117ca0f
commit 0347920fdb
2 changed files with 8 additions and 5 deletions

View File

@ -10,7 +10,7 @@ router.get('/', function (req, res, next) {
/* Mac OUI Lookup */
var mac_oui = "";
if (typeof dhcp_lease_data[key].mac.split(":").join("") !== "undefined") {
if (typeof dhcp_lease_data[key].mac !== "undefined") {
mac_oui = dhcp_lease_data[key].mac.split(":").join("").toUpperCase().slice(0, 6);
}
@ -41,4 +41,4 @@ router.get('/', function (req, res, next) {
res.send(JSON.stringify(stat_data));
});
module.exports = router;
module.exports = router;

View File

@ -49,11 +49,14 @@ router.post('/', function(req, res, next) {
table_row = table_row + '<td>' + (dhcp_lease_data[key].host ? dhcp_lease_data[key].host : '') + '</td>';
table_row = table_row + '<td>' + human_time(dhcp_lease_data[key].start * 1000) + '</td>';
table_row = table_row + '<td>' + human_time(dhcp_lease_data[key].end * 1000) + '</td>';
table_row = table_row + '<td>' +
if (typeof dhcp_lease_data[key].mac !== "undefined" ) {
table_row = table_row + '<td>' +
'<button class="btn btn-default waves-effect option_data" lease="' + dhcp_lease_data[key].mac.split(":").join("") + '">Show</button>' +
'<pre style="display:none;margin-top:10px" id="' + dhcp_lease_data[key].mac.split(":").join("") + '">' + JSON.stringify(dhcp_lease_data[key].options, null, 2) + '</pre>' +
'</td>';
} else {
table_row = table_row + '<td></td>';
}
table_data = table_data + '<tr>' + table_row + '</tr>';
count++;
@ -69,4 +72,4 @@ router.post('/', function(req, res, next) {
res.send(table_data);
});
module.exports = router;
module.exports = router;