From 4b3b622300d723797706c8a52c757d92e4569109 Mon Sep 17 00:00:00 2001 From: mozoloa Date: Sat, 21 Dec 2024 19:16:00 +0100 Subject: [PATCH 1/2] Change method to retrieve broadcast addresses and update probe to use them --- index.js | 49 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 0f72ce9..99648d1 100644 --- a/index.js +++ b/index.js @@ -189,25 +189,54 @@ class BAirInstance extends InstanceBase { this.checkFeedbacks(...Object.keys(this.blinkingFB)) } + /** + * Get broadcast addresses for all local IPv4 interfaces. + * @returns {string[]} An array of broadcast addresses (e.g., ["192.168.1.255", ...]). + */ + getBroadcastAddresses() { + const os = require('os'); + const interfaces = os.networkInterfaces(); + const broadcastAddresses = []; + + for (const name of Object.keys(interfaces)) { + for (const iface of interfaces[name]) { + if (iface.family === 'IPv4' && !iface.internal) { + // Calculate broadcast address by replacing the last octet with 255 + const parts = iface.address.split('.'); + parts[3] = '255'; + broadcastAddresses.push(parts.join('.')); + } + } + } + + return broadcastAddresses; + } + + /** * * network scanner interval */ probe() { + const broadcastAddresses = this.getBroadcastAddresses(); + if (!(this.probeCount % 6)) { - // scan every 30 seconds - this.scanPort.send( - { - address: '/xinfo', - args: [], - }, - '255.255.255.255', - 10024 - ) + // Scan every 30 seconds + for (const broadcast of broadcastAddresses) { + this.scanPort.send( + { + address: '/xinfo', + args: [], + }, + broadcast, + 10024 + ); + } } - this.probeCount++ + this.probeCount++; } + /** * Gather list of local mixer IP numbers and names */ From 07a66b1adacf1eb91bd70543a7bcd4cd03e9a3b6 Mon Sep 17 00:00:00 2001 From: mozoloa Date: Sat, 21 Dec 2024 23:23:11 +0100 Subject: [PATCH 2/2] Bump version to 2.6.4 in package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 895bde5..ecd5c78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "behringer-xair", - "version": "2.6.3", + "version": "2.6.4", "type": "module", "main": "index.js", "scripts": { @@ -19,4 +19,4 @@ "devDependencies": { "@companion-module/tools": "^2.1.0" } -} +} \ No newline at end of file