mirror of
https://github.com/Akkadius/glass-isc-dhcp.git
synced 2025-07-31 01:24:56 +02:00
Fix async start bug(OUI), fix
1. When Glass starting, OUI base not loaded, cause concurency. Therefore the vendor is not defined. 2. When you have failover dhcp cluster, there is many junk records.
This commit is contained in:
parent
10102a6709
commit
b590ccfaf9
17
app.js
17
app.js
@ -125,14 +125,17 @@ let dhcp_log_watcher = require('./core/dhcp-log-watcher');
|
||||
let app_timers = require('./core/app-timers');
|
||||
|
||||
/**
|
||||
* Run routines
|
||||
* Run routines in seq order
|
||||
*/
|
||||
oui_reader.initOuiDatabase();
|
||||
dhcp_leases.parseLeasesFileOnce(glass_config);
|
||||
dhcp_leases.startLeaseListener(glass_config);
|
||||
dhcp_leases.setLeasesCleanTimer();
|
||||
glass_config_watcher.init();
|
||||
dhcp_log_watcher.init(glass_config);
|
||||
(async () => {
|
||||
await oui_reader.initOuiDatabase();
|
||||
dhcp_leases.parseLeasesFileOnce(glass_config);
|
||||
dhcp_leases.startLeaseListener(glass_config);
|
||||
dhcp_leases.setLeasesCleanTimer();
|
||||
glass_config_watcher.init();
|
||||
dhcp_log_watcher.init(glass_config);
|
||||
})();
|
||||
|
||||
|
||||
/**
|
||||
* Timers
|
||||
|
@ -77,13 +77,19 @@ module.exports = {
|
||||
|
||||
/* Mac OUI Lookup */
|
||||
var mac_oui = dhcp_lease_data[ip_address].mac.split(":").join("").toUpperCase().slice(0, 6);
|
||||
|
||||
dhcp_lease_data[ip_address].mac_oui_vendor = '';
|
||||
if (typeof oui_data[mac_oui] !== "undefined") {
|
||||
dhcp_lease_data[ip_address].mac_oui_vendor = oui_data[mac_oui];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (/binding/i.test(lines[l])) {
|
||||
/* Need to ignore binding, when it is not first. Cause "next binding state expired" in Leases. */
|
||||
if (line_data_arg[0] == "binding" && line_data_arg[2] != "active;") {
|
||||
delete dhcp_lease_data[ip_address];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (/hostname/i.test(lines[l])) {
|
||||
if (typeof line_data_arg[1] !== "undefined")
|
||||
dhcp_lease_data[ip_address].host = line_data_arg[1].replace(/;/gi, '').replace(/"/gi, '').trim();
|
||||
|
@ -1,27 +1,29 @@
|
||||
var fs = require('fs');
|
||||
|
||||
module.exports = {
|
||||
initOuiDatabase: function () {
|
||||
var oui_database_file = "bin/oui_table.txt";
|
||||
|
||||
if (fs.existsSync(oui_database_file)) {
|
||||
fs.readFile(oui_database_file, 'utf8', function (err, data) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
else {
|
||||
lines = data.split("\n");
|
||||
for (l = 0; l < lines.length; l++) {
|
||||
/* Trim whitespaces at each ends of the line */
|
||||
lines[l] = lines[l].trim();
|
||||
var oui_line_data = lines[l].split(":::");
|
||||
|
||||
if (typeof oui_line_data[1] !== "undefined")
|
||||
oui_data[oui_line_data[0].trim()] = oui_line_data[1].trim();
|
||||
initOuiDatabase: async function () {
|
||||
return new Promise((resolve) => {
|
||||
var oui_database_file = "bin/oui_table.txt";
|
||||
if (fs.existsSync(oui_database_file)) {
|
||||
fs.readFile(oui_database_file, 'utf8', function (err, data) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
console.log("[Glass Server] OUI Database Loaded");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
else {
|
||||
lines = data.split("\n");
|
||||
for (l = 0; l < lines.length; l++) {
|
||||
/* Trim whitespaces at each ends of the line */
|
||||
lines[l] = lines[l].trim();
|
||||
var oui_line_data = lines[l].split(":::");
|
||||
|
||||
if (typeof oui_line_data[1] !== "undefined")
|
||||
oui_data[oui_line_data[0].trim()] = oui_line_data[1].trim();
|
||||
}
|
||||
console.log("[Glass Server] OUI Database Loaded");
|
||||
resolve()
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user