Provides access to the local machine's hardware. Will use spawn from node:child_process for pings, might have to change this to raw tcp connections This is a separate plugin for permission reasons.
Example
const { IPv4, Hardware } = require('ipv4-utils');
IPv4.use(Hardware);
Classes
Methods
(static) fromCurrent(interface_indexopt)
Get the local ip from the computer's interface
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
interface_index | Number | <optional> | The index of the interface |
Returns:
Interface ip as an IPv4 instance
Example
const my_interface = IPv4.fromCurrent();
(static) fromLocalhost()
Get the current loopback address
Returns:
Current localhost interface as an IPv4 instance
(static) getInterfacesIPv4(localhostopt)
Get all network interfaces IP adresses
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
localhost | boolean | <optional> | Whether or not to include localhost |
Returns:
An array of IPv4 instances
(static) getMask()
Returns:
Interface mask as an IPv4 instance
(static) getNetworkInterfaces()
Get all network interfaces IP adresses
Returns:
os.interfaces output
(static) ping(ip)
Ping an IP address
Parameters:
Name | Type | Description |
---|---|---|
ip | IPv4 | | The ip address |
Example
IPv4.ping('127.0.0.1').then(response => console.log(response));