fixed bug, that wouldn't allow more than one device in PTR section

This commit is contained in:
git 2025-06-16 16:38:47 +01:00
parent 2c432e5422
commit a8b91542fd

12
main.js
View File

@ -81,13 +81,15 @@ function sniffmDNSLocalPackets() {
// Add a new DEVICE to this SERVICE TYPE if needed
if (!db.local.PTR[answer.name].includes(answer.data))
db.local.PTR[answer.name].push(answer.data);
await insertToMariaDB({Type: answer.type,Name: answer.name,Data: db.local.PTR[answer.name]});
}
}
// 2. Handle DEVICE IP resolution
if (answer.type == "A") {
// 2.1 Initialize ADDRESSES sub-database
if (!db.local.A) db.local.A = {};
db.local.A[answer.name] = answer.data;
db.local.A[answer.name] = answer.data;
await insertToMariaDB({Type: answer.type,Name: answer.name,Data: db.local.A[answer.name]});
}
if (answer.type == "SRV") {
@ -95,18 +97,16 @@ function sniffmDNSLocalPackets() {
if (db.local[answer.name] === undefined) db.local[answer.name] = {"TXT":null,"SRV":null};
db.local[answer.name][answer.type] = answer.data;
await insertToMariaDB({Type: answer.type,Name: answer.name,Data: db.local[answer.name][answer.type]});
}
if (answer.type == "TXT") {
// Initialize this device / entry, if needed
if (db.local[answer.name] === undefined) db.local[answer.name] = {"TXT":null,"SRV":null};
db.local[answer.name][answer.type] = answer.data;
await insertToMariaDB({Type: answer.type,Name: answer.name,Data: db.local[answer.name][answer.type]});
}
await insertToMariaDB({
Type: answer.type,
Name: answer.name,
Data: answer.data
});
saveDbToFile(db,DB_FILENAME);
}
})