()
| 382 | // seem to be true aliases on all systems but ipv4 aliases may or may not be. |
| 383 | private static localHostAliases: string[] = []; |
| 384 | protected static getLocalHostAliases(): string[] { |
| 385 | if (TcpPortScanner.localHostAliases.length === 0) { |
| 386 | // On Unixes, the two are treated like true aliases but on Windows |
| 387 | // you can have distint servers on all of them. So, try everything. |
| 388 | TcpPortScanner.localHostAliases = ['127.0.0.1', '0.0.0.0']; |
| 389 | const ifaces = os.networkInterfaces(); |
| 390 | Object.keys(ifaces).forEach((ifname) => { |
| 391 | ifaces[ifname].forEach((iface) => { |
| 392 | // Skip external interfaces (VPN tunnels, actual IP, etc). Only want loopbacks |
| 393 | if (iface.internal && ('ipv4' === iface.family.toLowerCase())) { |
| 394 | if (TcpPortScanner.localHostAliases.indexOf(iface.address) === -1) { |
| 395 | TcpPortScanner.localHostAliases.push(iface.address); |
| 396 | } |
| 397 | } |
| 398 | }); |
| 399 | }); |
| 400 | // ConsoleLog(aliases.join(',')); |
| 401 | } |
| 402 | return TcpPortScanner.localHostAliases; |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * quick/dirty way of figuring out if this is a local host. guaranteed way would have |
no outgoing calls
no test coverage detected