Pane icon indicating copy to clipboard operation
Pane copied to clipboard

Add controls to disable or exclude automatic TCP listener probes for strict socket tests

Open allenrchan opened this issue 4 weeks ago • 2 comments

Problem

Pane's automatic listening-port classification sends HTTP HEAD / requests to test receivers. This interferes with strict assertions that an authorization failure must produce zero connections to a receiver: Pane itself becomes an unexpected client.

Please provide a supported host-side setting to disable active probes, and ideally exclusions for selected ports or port ranges, while retaining passive listener discovery.

Related: #1033 describes the same probing mechanism breaking one-shot OAuth callback listeners. This request also covers long-lived test receivers and processes launched inside Pane, so restricting probes to Pane descendants or adding a delay would not fully address it.

Environment and evidence

  • macOS; inspected installed Pane 2.4.215 and the local source checkout.
  • During authorization-migration validation, an agent's passive socket controls attributed incoming HTTP HEAD requests to the Pane process, with both IPv4 and IPv6 test listeners affected. A detached test process was affected too. This observation is from the validation agent; I independently checked the implementation and installed bundle, rather than rerunning its test.
  • No supported probe toggle or configurable exclusion was found in the settings, configuration types, CLI documentation, or monitor options.

How to reproduce

  1. Keep Pane running on a Mac.
  2. Start a TCP test receiver on an ephemeral 127.0.0.1 port; record every accepted connection. Repeat with an IPv6 ::1 listener.
  3. Do not launch any intended client and observe the receivers through several port-monitor polls.
  4. Repeat with the receiver detached from its launching terminal.

Expected: when active probing is disabled or the listener is excluded, the receiver accepts no connections from Pane, while its port can still appear in the passive Ports list.

Actual: Pane can connect to the receiver and send HEAD /, contaminating the no-connection control. Detaching does not prevent discovery.

Implementation trace

  • listeningPorts.ts: discovers host TCP listeners and probes them regardless of their ownership group. On macOS discovery uses lsof; probe() calls http.request({ method: 'HEAD', host: 'localhost', port, path: '/' }), allowing both address families.
  • The poll interval starts at 2 seconds; classification is cached, with additional attempts for silent listeners. Even the first connection is enough to invalidate these tests.
  • The hard-coded exceptions cover nc, ncat, netcat, and socat, and Pane's registered tunnel listeners. Arbitrary Python, Node, or compiled test receivers have no equivalent opt-out.
  • bootstrap.ts: starts listeningPortMonitor unconditionally. ports:list can also trigger a refresh. Closing browser tabs or muting the live-preview prompt does not disable the monitor.

Requested behavior

  • A documented disable active port probes setting, honored on the machine that owns the listeners, including when it is a remote/headless host.
  • Keep passive discovery available; unprobed ports can remain tcp or use an explicit unknown classification.
  • Optional port/port-range exclusions for users who want automatic web previews elsewhere.
  • Honor the policy before opening any socket, for both background polling and explicit refresh. Define when a changed setting takes effect so tests can wait until probing has stopped.
  • Regression coverage should verify zero connections to IPv4 and IPv6 listeners with probes disabled/excluded, including receivers outside the current Pane's process tree.

The current alternatives are to stop Pane on the test host or isolate the entire test network. Weakening the no-receiver-connection assertion or ignoring HEAD requests would defeat what the authorization test is proving.

allenrchan avatar Nov 06 '26 11:11 allenrchan

I'll take this. listeningPorts.ts sends HEAD / to every listener it classifies and there's no config to stop it. Plan: a setting to turn active probes off and a port/range exclusion list, keeping passive listener discovery as is, wired through config and Settings, with unit tests that assert zero connections to an excluded or probes-off port.

ilijachrchev avatar Nov 20 '26 19:11 ilijachrchev

PR's up: #1639. Adds portProbesEnabled and portProbeExcludedPorts (ports and ranges) under Settings > General; an unprobed listener still shows in the Ports list, just without the HEAD probe.

ilijachrchev avatar Nov 20 '26 19:11 ilijachrchev