A dictionary of named flag constants for use with `HSNetworkReachability.status()`.
Compare individual bits against these constants to determine which network conditions apply.
The numeric values match the deprecated `SCNetworkReachabilityFlags` for backward compatibility.
Keys: `transientConnection`, `reachable`, `connectionRequired`, `connectionOnTraffic`,
`interventionRequired`, `connectionOnDemand`, `isLocalAddress`, `isDirect`.
Returns all network interfaces present on this system.
Each object contains `name` (string), `isLoopback` (boolean), `isUp` (boolean), and `isRunning` (boolean). A `displayName` string is included when the system provides a human-readable label for the interface (e.g. `"Wi-Fi"` or `"Ethernet"`).
Declaration
hs.network.interfaces() -> [[String: Any]]
Returns
[[String: Any]]
An array of objects describing each network interface.
Returns all IP addresses assigned to this host.
Each object contains `interface` (the BSD name of the interface), `address` (the address string), and `family` (`"ipv4"` or `"ipv6"`).
Asynchronously resolves a hostname to its IP addresses using the system DNS resolver.
Uses CFHost, which respects the system's network configuration including VPN routes and proxy settings.
The hostname to resolve (e.g. `"example.com"` or `"localhost"`).
family
string
The address family to query: `"ipv4"` for A records only, `"ipv6"` for AAAA records only, or `"both"` to return all addresses. Defaults to `"both"` when omitted.
Returns
Promise<string[]>
A Promise that resolves to an array of IP address strings, or rejects with an error message if the lookup fails.
Creates a reachability monitor for a specific IP address.
Returns `null` if `address` is not a valid IPv4 or IPv6 address literal.
Under the hood this monitors general system connectivity (the same as `reachabilityInternet()`),
because `NWPathMonitor` does not support per-address targeting.
Creates a reachability monitor for a source/destination IP address pair.
Returns `null` if either address is not a valid IPv4 or IPv6 address literal.
Under the hood this monitors general system connectivity (the same as `reachabilityInternet()`),
because `NWPathMonitor` does not support per-address targeting.
Creates a reachability monitor for a given hostname.
Returns `null` if `hostName` is empty.
Under the hood this monitors general system connectivity (the same as `reachabilityInternet()`),
because `NWPathMonitor` does not support per-hostname targeting.
Creates a reachability monitor for general internet connectivity.
This is the most common factory method. Use it when you want to know whether the
device currently has a working internet connection.
Creates a reachability monitor for link-local connectivity.
Link-local addresses cover the `169.254.x.x` (IPv4) and `fe80::/10` (IPv6) ranges
used for direct device-to-device communication without a router.
Under the hood this monitors general system connectivity (the same as `reachabilityInternet()`),
because `NWPathMonitor` does not distinguish link-local reachability.
Returns the contents of the macOS System Configuration dynamic store as a dictionary.
The store holds live network configuration for the running system — interface addresses,
routing, DNS servers, proxy settings, VPN state, and more. Keys follow a hierarchical
path convention (e.g. `"State:/Network/Global/IPv4"`).
Omit or pass `null` to return all keys (equivalent to `".*"`).
An optional regular expression that filters which keys are included.
Returns
{[key: string]: any}
A dictionary mapping key strings to their current values. Values may be
Example
// Dump everything
console.log(JSON.stringify(hs.network.configurationStore()))
// Filter to network state
const state = hs.network.configurationStore("State:/Network/.*")
console.log(state["State:/Network/Global/IPv4"])
Returns a mapping of all configured network location UUIDs to their display names.
Use this to discover available locations before calling `configurationSetLocation()`.
Switches the active network location to the one with the given name or UUID.
Pass the location's display name (e.g. `"Home"`) or its UUID from `configurationLocations()`.
The change is applied immediately. Returns `false` if the location was not found or
the preferences could not be committed (e.g. insufficient privileges).
Creates a watcher that fires a callback when System Configuration dynamic store keys change.
Call `setKeys()` to specify which keys (or patterns) to watch, `setCallback()` to register
the handler, then `start()` to begin monitoring. The module automatically stops and
destroys all watchers on `hs.reload()`.
Sends ICMP Echo Requests to `server` and reports results via a callback.
DNS resolution and the first ping begin immediately. The returned object can be used to
pause, resume, or cancel the ping, and to read statistics.
`timeout` (seconds per packet, default 2.0), `family` (`"any"` | `"ipv4"` | `"ipv6"`, default `"any"`),
and `callback` (function).
Declaration
hs.network.ping(server, options) -> HSNetworkPing
Parameters
Name
Type
Description
server
string
A hostname or IP address to ping.
options
JSValue
A callback function or options object. Optional.
Returns
HSNetworkPing
An `HSNetworkPing` object, or `null` if the arguments are invalid.