From b96aed3f34523fedd763f1bff9d972774e9c4ea1 Mon Sep 17 00:00:00 2001 From: John A Knight Jr Date: Sun, 22 Dec 2024 11:50:30 -0800 Subject: [PATCH] import 'os' instead of obsolete require --- index.js | 28 +++++++++++++--------------- package.json | 4 ++-- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index 99648d1..e061aab 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,7 @@ import { buildHADefs } from './buildHADefs.js' import { getConfigFields } from './config.js' import { ICON_SOLO } from './icons.js' import { pad0 } from './helpers.js' +import os from 'os' class BAirInstance extends InstanceBase { constructor(internal) { @@ -190,35 +191,33 @@ class BAirInstance extends InstanceBase { } /** - * Get broadcast addresses for all local IPv4 interfaces. - * @returns {string[]} An array of broadcast addresses (e.g., ["192.168.1.255", ...]). - */ + * 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 = []; + 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('.')); + const parts = iface.address.split('.') + parts[3] = '255' + broadcastAddresses.push(parts.join('.')) } } } - return broadcastAddresses; + return broadcastAddresses } - /** * * network scanner interval */ probe() { - const broadcastAddresses = this.getBroadcastAddresses(); + const broadcastAddresses = this.getBroadcastAddresses() if (!(this.probeCount % 6)) { // Scan every 30 seconds @@ -230,13 +229,12 @@ class BAirInstance extends InstanceBase { }, broadcast, 10024 - ); + ) } } - this.probeCount++; + this.probeCount++ } - /** * Gather list of local mixer IP numbers and names */ diff --git a/package.json b/package.json index ecd5c78..ed27c31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "behringer-xair", - "version": "2.6.4", + "version": "2.6.5", "type": "module", "main": "index.js", "scripts": { @@ -19,4 +19,4 @@ "devDependencies": { "@companion-module/tools": "^2.1.0" } -} \ No newline at end of file +}