UNPKG

lib-comfoair

Version:

Library to communicate with Zehnder ComfoAirQ ventilation unit through the ComfoControl gateway

33 lines (32 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NetworkUtils = void 0; const node_os_1 = require("node:os"); class NetworkUtils { /** * Get all available broadcast addresses on the current machine. * @returns An array of broadcast addresses. */ static getBroadcastAddresses() { const interfaces = (0, node_os_1.networkInterfaces)(); const broadcastAddresses = []; for (const networks of Object.values(interfaces)) { if (!networks) { continue; } for (const net of networks) { if (net.family === 'IPv4' && !net.internal) { const addressParts = net.address.split('.').map(Number); const netmaskParts = net.netmask.split('.').map(Number); const broadcastParts = addressParts.map((part, index) => part | (~netmaskParts[index] & 255)); broadcastAddresses.push(broadcastParts.join('.')); } } } return broadcastAddresses; } static getHostname() { return (0, node_os_1.hostname)(); } } exports.NetworkUtils = NetworkUtils;