bonjour-hap
Advanced tools
Comparing version 3.5.7 to 3.5.8
@@ -18,3 +18,3 @@ 'use strict' | ||
for (var i = 0; i < query.questions.length; i++) { | ||
var question = query.questions.length | ||
var question = query.questions[i] | ||
@@ -34,3 +34,3 @@ var type = question.type | ||
if (type !== 'ANY') { | ||
answers.forEach(function (answer) { | ||
answers.forEach(answer => { | ||
if (answer.type !== 'PTR') return | ||
@@ -45,10 +45,10 @@ additionals = additionals | ||
additionals | ||
.filter(function (record) { | ||
.filter(record => { | ||
return record.type === 'SRV' | ||
}) | ||
.map(function (record) { | ||
.map(record => { | ||
return record.data.target | ||
}) | ||
.filter(helpers.unique()) | ||
.forEach(function (target) { | ||
.forEach(target => { | ||
additionals = additionals | ||
@@ -63,3 +63,3 @@ .concat(this._recordsFor(target, 'A')) | ||
additionals: additionals | ||
}, function (err) { | ||
}, err => { | ||
if (err) throw err // TODO: Handle this (if no callback is given, the error will be ignored) | ||
@@ -92,3 +92,3 @@ }) | ||
this.registry[type] = this.registry[type].filter(function (r) { | ||
this.registry[type] = this.registry[type].filter(r => { | ||
return r.name !== record.name | ||
@@ -102,3 +102,3 @@ }) | ||
return this.registry[type].filter(function (record) { | ||
return this.registry[type].filter(record => { | ||
var recordName = ~name.indexOf('.') ? record.name : record.name.split('.')[0] | ||
@@ -105,0 +105,0 @@ return dnsEqual(recordName, name) |
@@ -108,12 +108,30 @@ 'use strict' | ||
const ipv4 = ip.address('public', 'ipv4') | ||
const ipv6 = ip.address('public', 'ipv6') | ||
records.push(...this._addressRecords()) | ||
if (!ip.isLoopback(ipv4)) { // ip returns loopback address if there is not public ipv4 configured | ||
records.push(this._rrA(ipv4)) | ||
} | ||
if (!ip.isLoopback(ipv6)) { // ip returns loopback address if there is not public ipv6 configured | ||
records.push(this._rrAaaa(ipv6)) | ||
} | ||
return records | ||
}, | ||
_addressRecords: function () { | ||
const records = [] | ||
const addresses = [] | ||
Object.values(os.networkInterfaces()).forEach(interfaces => { | ||
interfaces.forEach(iface => { | ||
if (iface.internal || iface.mac === '00:00:00:00:00:00' || | ||
ip.isLoopback(iface.address) || | ||
(!ip.isV4Format(iface.address) && ip.isPrivate(iface.address)) || | ||
addresses.includes(iface.address)) { | ||
return | ||
} | ||
addresses.push(iface.address) | ||
if (iface.family === 'IPv4') { | ||
records.push(this._rrA(iface.address)) | ||
} else { | ||
records.push(this._rrAaaa(iface.address)) | ||
} | ||
}) | ||
}) | ||
return records | ||
@@ -120,0 +138,0 @@ }, |
{ | ||
"name": "bonjour-hap", | ||
"version": "3.5.7", | ||
"version": "3.5.8", | ||
"description": "A Bonjour/Zeroconf implementation in pure JavaScript (for HAP)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,13 +12,16 @@ 'use strict' | ||
var getAddresses = function () { | ||
var addresses = [] | ||
const addresses = [] | ||
const ipv4 = ip.address('public', 'ipv4') | ||
const ipv6 = ip.address('public', 'ipv6') | ||
Object.values(os.networkInterfaces()).forEach(interfaces => { | ||
interfaces.forEach(iface => { | ||
if (iface.internal || iface.mac === '00:00:00:00:00:00' || | ||
ip.isLoopback(iface.address) || | ||
(!ip.isV4Format(iface.address) && ip.isPrivate(iface.address)) || | ||
addresses.includes(iface.address)) { | ||
return | ||
} | ||
if (!ip.isLoopback(ipv4)) { // ip returns loopback address if there is not public ipv4 configured | ||
addresses.push(ipv4) | ||
} | ||
if (!ip.isLoopback(ipv6)) { // ip returns loopback address if there is not public ipv6 configured | ||
addresses.push(ipv6) | ||
} | ||
addresses.push(iface.address) | ||
}) | ||
}) | ||
@@ -25,0 +28,0 @@ return addresses |
@@ -11,7 +11,17 @@ 'use strict' | ||
const addresses = [ip.address('public', 'ipv4'), ip.address('public', 'ipv6')] | ||
const addresses = [] | ||
Object.values(os.networkInterfaces()).forEach(interfaces => { | ||
interfaces.forEach(iface => { | ||
if (iface.internal || iface.mac === '00:00:00:00:00:00' || | ||
ip.isLoopback(iface.address) || | ||
(!ip.isV4Format(iface.address) && ip.isPrivate(iface.address)) || | ||
addresses.includes(iface.address)) { | ||
return | ||
} | ||
addresses.push(iface.address) | ||
}) | ||
}) | ||
addresses.forEach(address => { | ||
if (ip.isLoopback(address)) { | ||
return | ||
} | ||
records.push({ data: address, name: host, ttl: 120, type: ip.isV4Format(address) ? 'A' : 'AAAA' }) | ||
@@ -18,0 +28,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40855
929