startLanIpMonitor (src/mdns.ts)

portless · packages/portless/src/mdns.ts · typescript · Apache-2.0
infra, tag:knn-classified

Cross‑platform LAN IP monitor and mDNS publisher for auto‑detecting network changes in Node.js applications.

// Source: https://github.com/vercel-labs/portless | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { spawn, spawnSync, type ChildProcess } from "node:child_process";

import { getLocalNetworkIp } from "./lan-ip.js";

export { getLocalNetworkIp };

type MdnsPublisher = {
  command: string;
  probeArgs: string[];
  missingReason: string;
  buildArgs: (fqdn: string, name: string, port: number, ip: string) => string[];
};

type LanIpMonitorOptions = {
  initialIp: string | null;
  intervalMs?: number;
  resolveIp?: () => Promise<string | null>;
  onChange: (nextIp: string | null, previousIp: string | null) => void;
  onError?: (error: unknown) => void;
};

/** Map of hostname -

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key