Skip to content

Commit

Permalink
use all A/AAAA records announced in mDNS for SHC discovery, remove du…
Browse files Browse the repository at this point in the history
…plicates (#40)
  • Loading branch information
hobbyquaker committed Nov 23, 2020
1 parent 13fd565 commit 1686cc4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
12 changes: 10 additions & 2 deletions nodes/shc-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,16 @@ module.exports = function (RED) {
function filter(res) {
const filterList = [];
res.forEach(element => {
if (Object.prototype.hasOwnProperty.call(element, 'fqdn') && element.fqdn.includes('Bosch SHC')) {
filterList.push(element);
if (element && element.fqdn && element.fqdn.includes('Bosch SHC')) {
if (element.packet && element.packet.additionals) {
element.packet.additionals.forEach(record => {
if (record && record.class === 'IN' && ['A', 'AAAA'].includes(record.type)) {
if (!filterList.find(e => e.address === record.rdata)) {
filterList.push({address: record.rdata, fqdn: element.fqdn});
}
}
});
}
}
});
result.set({'content-type': 'application/json; charset=utf-8'});
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-bosch-shc",
"version": "0.3.23",
"version": "0.3.24",
"description": "Bosch Smart Home Controller (SHC) nodes for Node-Red",
"repository": "https://github.com/hxmelab/node-red-contrib-bosch-shc",
"main": "none",
Expand All @@ -20,6 +20,9 @@
"name": "hxmelab",
"email": "hxmelab@gmail.com"
},
"contributors": [
"Sebastian Raff <hobbyquaker@gmail.com> https://github.com/hobbyquaker"
],
"license": "MIT",
"node-red": {
"nodes": {
Expand Down Expand Up @@ -62,7 +65,10 @@
"unicorn/prevent-abbreviations": 0,
"promise/prefer-await-to-then": "warn",
"prefer-object-spread": "warn",
"complexity": ["warn", 30],
"complexity": [
"warn",
30
],
"no-unused-vars": [
2,
{
Expand Down

0 comments on commit 1686cc4

Please sign in to comment.