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
- func FirstRun(stateDir string) bool
- func Gated() bool
- func Granted(stateDir string) bool
- func Hint(responsible string) string
- func InApp() bool
- func IsLocalAddr(ip net.IP) bool
- func IsLocalName(host string) bool
- func Needs(ctx context.Context, host string) (bool, string)
- func Remember(stateDir string, st State, waited time.Duration)
- func ResetWait(stateDir string)
- func Responsible() string
- func Wait(stateDir string) time.Duration
- type State
Constants ¶
const CanProbe = false
CanProbe reports whether this build can run Probe (macOS builds with cgo).
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 ¶
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 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 ¶
IsLocalAddr reports whether traffic to ip needs local network access.
func IsLocalName ¶
IsLocalName reports whether a host name is a multicast DNS name (.local).
func Needs ¶
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 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).
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 ¶
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.