pubface
v1.2.0
Published
Resolve public network interfaces for current machine
Readme
pubface
Detect public network interfaces for current machine.
Usage as a module
Install the dependency
$ npm install pubfaceUse it to get an array of interfaces. The package ships both CommonJS and ES module builds with TypeScript type declarations.
const { resolvePublicInterfaces } = require('pubface');
// or: import { resolvePublicInterfaces } from 'pubface';
...
let interfaces = await resolvePublicInterfaces();
console.log(interfaces);The PublicInterface type describes one entry of the result:
import { resolvePublicInterfaces, type PublicInterface } from 'pubface';
const interfaces: PublicInterface[] = await resolvePublicInterfaces();Usage as a command
Install the command
$ npm install -g pubfaceOr alternatively download the latest executable if you do not have Node.js or NPM installed
Use it to get an array of interfaces
$ pubfaceOutput
Output is an array of interfaces:
[
{
"localAddress": "192.168.3.4",
"ip": "1.2.3.4",
"name": "ec2-1-2-3-4.eu-central-1.compute.amazonaws.com",
"family": "IPv4",
"defaultInterface": true
},
{
"localAddress": "10.240.128.227",
"ip": "101.102.103.104",
"name": "104-103-102-101.sta.estpak.ee",
"family": "IPv4"
}
]- localAddress is the local IP address
- ip is the public IP address that servers see as your IP address when you make a connection
- name is the reverse record for ip
- family is either IPv4 or IPv6 depending on the ip
- defaultInterface is a boolean that indicates if this is the default interface used when making connections and not specifying a local address
Configuration
- RESOLV_URL is the resolver service that reports the public IP address of a request,
https://api.nodemailer.com/by default. It must answer with a JSON object that has anipproperty. - RESOLV_TIMEOUT is the time limit in seconds for resolving one interface, including its reverse DNS lookup, 5 by default.
License
Pubface is licensed under the MIT No Attribution license
