Détail du package

lan-network

kitten2.1mMIT0.1.7

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

readme

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:

  1. Create a socket to a publicly routed IP, and return the assignment matching the socket's local address
  2. Broadcast DHCP discovery packets on all routable network assignments and listen for replies
  3. 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.

changelog

lan-network

0.1.7

Patch Changes

  • Compare subnet-masked addresses before accepting DHCP discover message Submitted by @hyoban (See #12)

0.1.6

Patch Changes

  • ⚠️ Fix probing and fallback methods for Windows Submitted by @kitten (See #9)

0.1.5

Patch Changes

  • When matching a probed route, ignore internal interfaces. The probed route will match a VPN (virtual) interface when using it to tunnel all traffic, but is unlikely to be considered the local network by users Submitted by @kitten (See #7)

0.1.3

Patch Changes

  • Move vitest to devDependencies Submitted by @kitten (See #5)

0.1.2

Patch Changes

  • Add CLI for testing Submitted by @kitten (See #3)

0.1.1

Patch Changes

  • Bind to assignment IP for DHCP discovery Submitted by @kitten (See #1)

0.1.0

Initial Release.