šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

lan-network

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lan-network

Best-effort discovery of the machine's default gateway and local network IP exclusively with UDP sockets.

0.1.6
latest
Source
npm
Version published
Weekly downloads
391K
10.49%
Maintainers
1
Weekly downloads
Ā 
Created
Source

lan-network

Best-effort discovery of the machine's default gateway and local network IPv4 address exclusively with UDP sockets.

This utility attempts to determine the interface and IPv4 address of a machine on the local network. It'll attempt to determine the default gateway and return the corresponding network interface assignment, both when the network is online and offline.

The LAN Network it attempts to pick is the one that the machine uses to connect to the internet. Determining it is useful to pick the machine's IP address that is generally used to connect to it from other devices on the network.

lanNetwork() makes three separate attempts to guess the local network:

  • Create a socket to a publicly routed IP, and return the assignment matching the socket's local address
  • Broadcast DHCP discovery packets on all routable network assignments and listen for replies
  • Highest priority assignment

lanNetworkSync() does the same synchronously by spawning a child process and blocking until a result is determined. Using this method is generally not recommended.

FAQs

Package last updated on 08 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts