|
1 | 1 | 'use strict'; |
2 | | -const publicIp = require('public-ip'); |
3 | | -const internalIp = require('internal-ip'); |
4 | | -const defaultGateway = require('default-gateway'); |
5 | | -const localDevices = require('local-devices'); |
6 | | -const alfy = require('alfy'); |
| 2 | +import publicIp from "public-ip"; |
| 3 | +import alfy from 'alfy'; |
| 4 | +import findLocalDevices from "local-devices"; |
| 5 | +import defaultGateway from "default-gateway"; |
| 6 | +import {internalIpV4, internalIpV6} from "internal-ip"; |
7 | 7 |
|
8 | 8 | const promises = []; |
9 | 9 | const output = []; |
@@ -59,14 +59,14 @@ function addIPOutput(type, ip, name, mac) { |
59 | 59 | if (alfy.input.split(" ")[0].toLowerCase() === 'ssh') { |
60 | 60 | addOutput(`Type ssh username for ${alfy.input.split(" ")[1]}`, `ssh ${alfy.input.split(" ")[2] || 'root'}@${alfy.input.split(" ")[1]}`, `ssh ${alfy.input.split(" ")[2] || 'root'}@${alfy.input.split(" ")[1]}`, 'Public', 'ssh') |
61 | 61 | } else if (alfy.input.toLowerCase() === 'scan') { |
62 | | - promises.push(localDevices().then(devices => devices.forEach(device => addIPOutput('Device', device.ip, device.name, device.mac))).catch(() => addIPOutput('No local devices found', 'Local'))); |
| 62 | + promises.push(findLocalDevices().then(devices => devices.forEach(device => addIPOutput('Device', device.ip, device.name, device.mac))).catch(() => addIPOutput('No local devices found', 'Local'))); |
63 | 63 | } else if (alfy.input.toLowerCase() === 'ipv6') { |
64 | 64 | if (process.env['show_public'] === 'true') promises.push(publicIp.v6().then(ip => addIPOutput('Public', ip, '', '')).catch(() => addIPOutput('Public', 'IPv6 not found', '', ''))); |
65 | | - if (process.env['show_local'] === 'true') promises.push(internalIp.v6().then(ip => addIPOutput('Internal', ip, '', '')).catch(() => addIPOutput('Internal', 'IPv6 not found', '', ''))); |
| 65 | + if (process.env['show_local'] === 'true') promises.push(internalIpV6().then(ip => addIPOutput('Internal', ip, '', '')).catch(() => addIPOutput('Internal', 'IPv6 not found', '', ''))); |
66 | 66 | if (process.env['show_gateway'] === 'true') promises.push(defaultGateway.v6().then(ip => addIPOutput('Gateway', ip.gateway, '', '')).catch(() => addIPOutput('Gateway', 'IPv6 not found', '', ''))); |
67 | 67 | } else { |
68 | 68 | if (process.env['show_public'] === 'true') promises.push(publicIp.v4().then(ip => addIPOutput('Public', ip, '', '')).catch(() => addIPOutput('Public', 'IPv4 not found', '', ''))); |
69 | | - if (process.env['show_local'] === 'true') promises.push(internalIp.v4().then(ip => addIPOutput('Internal', ip, '', '')).catch(() => addIPOutput('Internal', 'IPv4 not found', '', ''))); |
| 69 | + if (process.env['show_local'] === 'true') promises.push(internalIpV4().then(ip => addIPOutput('Internal', ip, '', '')).catch(() => addIPOutput('Internal', 'IPv4 not found', '', ''))); |
70 | 70 | if (process.env['show_gateway'] === 'true') promises.push(defaultGateway.v4().then(ip => addIPOutput('Gateway', ip.gateway, '', '')).catch(() => addIPOutput('Gateway', 'IPv4 not found', '', ''))); |
71 | 71 | } |
72 | 72 |
|
|
0 commit comments