UNPKG

snips-sam

Version:

The Snips Assistant Manager

22 lines 967 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const os_1 = require("os"); const shell = require('shelljs'); exports.scanNetwork = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { const response = shell.exec('arp -na | grep -i b8:27:eb | awk \'{print $2}\'', { async: false, silent: true }); if (response.length === 0) { throw new Error('No devices discovered'); } return response.split('\n') .filter((line, index, array) => array.indexOf(line) === index) .filter(line => line.length > 0) .map(ip => ip.replace('(', '').replace(')', '')); }); exports.getLocalExternalIp = () => { const interfaceInfos = [].concat.apply([], Object.values(os_1.networkInterfaces())); return interfaceInfos .find(interfaceInfo => interfaceInfo.family === 'IPv4' && !interfaceInfo.internal) .address; }; //# sourceMappingURL=device.js.map