lnp

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lnp handles macOS local network privacy (macOS 15 and later).

macOS asks once per app before it lets the app reach a device on the local network, and the ssh processes hopsesh starts count as hopsesh (Apple TN3179). The rules this package follows come from that note:

  • Only some destinations are gated: addresses on a broadcast-capable interface's subnet (Wi-Fi, Ethernet), link-local and multicast addresses, and names ending in .local. Tailscale and other VPN addresses are not gated.
  • There is no API that reports the permission. A connection made with Network framework waits with the reason "local network denied", and continues on its own when the person allows access. Probe uses exactly that.
  • The prompt may deny the first connection before the person answers, so callers wait and retry instead of reporting a failure straight away.
  • Command-line tools started from Terminal or over SSH are always allowed. Other terminal apps (iTerm, VS Code, …) carry their own permission.

Index

Constants

View Source
const CanProbe = false

CanProbe reports whether this build can run Probe (macOS builds with cgo).

View Source
const SettingsURL = "x-apple.systempreferences:com.apple.settings.PrivacySecurity.extension"

SettingsURL opens System Settings at Privacy & Security. macOS has no link straight to the Local Network list, so the message tells the person where to scroll.

Variables

This section is empty.

Functions

func FirstRun

func FirstRun(stateDir string) bool

FirstRun reports whether no probe has finished yet, so the macOS prompt may be about to appear for the first time.

func Gated

func Gated() bool

Gated reports whether this OS has local network privacy (macOS 15 or later).

func Granted

func Granted(stateDir string) bool

Granted reports whether access was confirmed before (and not seen denied since).

func Hint

func Hint(responsible string) string

Hint is the advice shown when local network access blocks a machine.

func InApp

func InApp() bool

InApp reports whether this process is the main executable of a .app bundle, which is the code macOS holds responsible for its network use.

func IsLocalAddr

func IsLocalAddr(ip net.IP) bool

IsLocalAddr reports whether traffic to ip needs local network access.

func IsLocalName

func IsLocalName(host string) bool

IsLocalName reports whether a host name is a multicast DNS name (.local).

func Needs

func Needs(ctx context.Context, host string) (bool, string)

Needs reports whether connecting to host needs local network access, and the address that decided it. A .local name always does; it is not resolved here, because resolving it is itself gated.

func Remember

func Remember(stateDir string, st State, waited time.Duration)

Remember records a probe's outcome.

func ResetWait

func ResetWait(stateDir string)

ResetWait makes the next probe wait long again (the person pressed "Try again" after changing the setting, or wants to answer a prompt they dismissed).

func Responsible

func Responsible() string

Responsible names the app whose Local Network setting applies to this process, or "" when macOS always allows it (a command-line tool run from Terminal or over SSH).

func Wait

func Wait(stateDir string) time.Duration

Wait returns how long a probe should wait for local network access: long while the macOS prompt may be on screen for the first time, short once the person has answered.

Types

type State

type State string

State is what a probe learned about local network access.

const (
	// NotNeeded: the destination is not on the local network, or the OS has no gate.
	NotNeeded State = "not-needed"
	// Allowed: an in-process connection to the destination succeeded.
	Allowed State = "allowed"
	// Denied: the connection was still waiting for local network access when the probe
	// gave up. The person either declined, or has not answered the macOS prompt yet;
	// macOS does not say which.
	Denied State = "denied"
	// Unknown: the gate applies but this build cannot probe (no cgo), or the
	// connection failed for some other reason (machine off, firewall).
	Unknown State = "unknown"
)

func Probe

func Probe(ctx context.Context, host string, port int, wait time.Duration) State

Probe makes an in-process TCP connection to host:port with Network framework and reports whether local network access is the obstacle. It waits up to wait for the person to answer the macOS prompt; the connection proceeds by itself once they allow it. The connection is closed as soon as it is ready; nothing is sent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL