Filter mDNS responses. Fixes #47
This commit is contained in:
parent
2c376baa77
commit
6b8a2924a5
1 changed files with 22 additions and 12 deletions
|
|
@ -145,9 +145,6 @@ export default {
|
||||||
if (mdns) {
|
if (mdns) {
|
||||||
// TODO: Have this run periodically on a timer
|
// TODO: Have this run periodically on a timer
|
||||||
|
|
||||||
// Store the current context for callbacks
|
|
||||||
var context = this;
|
|
||||||
|
|
||||||
// Create a browser to search for 'openflexure' type services
|
// Create a browser to search for 'openflexure' type services
|
||||||
var browser = mdns.createBrowser(mdns.tcp('openflexure'));
|
var browser = mdns.createBrowser(mdns.tcp('openflexure'));
|
||||||
|
|
||||||
|
|
@ -156,18 +153,31 @@ export default {
|
||||||
browser.discover();
|
browser.discover();
|
||||||
});
|
});
|
||||||
|
|
||||||
browser.on('update', function (data) {
|
browser.on('update', (data) => {
|
||||||
var hostData = {
|
console.log(data)
|
||||||
hostname: data.addresses[0],
|
|
||||||
name: `${data.host} on ${data.networkInterface}`,
|
|
||||||
port: data.port
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof data.port !== "undefined") {
|
// We will be checking if it's a valid openflexure device
|
||||||
context.$set(context.foundHosts, hostData.hostname, hostData)
|
var validDevice = false
|
||||||
}
|
|
||||||
|
|
||||||
console.log(context.foundHosts)
|
// Go through each type of the host, make valid if 'openflexure' appears
|
||||||
|
data.type.forEach((element) => {
|
||||||
|
console.log(element)
|
||||||
|
if (element.name === "openflexure") {
|
||||||
|
validDevice = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
var hostData = {
|
||||||
|
hostname: data.addresses[0],
|
||||||
|
name: `${data.host} on ${data.networkInterface}`,
|
||||||
|
port: data.port
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((typeof data.port !== "undefined") && (validDevice === true)) {
|
||||||
|
this.$set(this.foundHosts, hostData.hostname, hostData)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(this.foundHosts)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue