Skip to content

Commit

Permalink
Merge pull request #128 from istnv/bug/os
Browse files Browse the repository at this point in the history
import 'os' instead of obsolete require
  • Loading branch information
istnv authored Dec 22, 2024
2 parents de61950 + b96aed3 commit 9450679
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
28 changes: 13 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -230,13 +229,12 @@ class BAirInstance extends InstanceBase {
},
broadcast,
10024
);
)
}
}
this.probeCount++;
this.probeCount++
}


/**
* Gather list of local mixer IP numbers and names
*/
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "behringer-xair",
"version": "2.6.4",
"version": "2.6.5",
"type": "module",
"main": "index.js",
"scripts": {
Expand All @@ -19,4 +19,4 @@
"devDependencies": {
"@companion-module/tools": "^2.1.0"
}
}
}

0 comments on commit 9450679

Please sign in to comment.