kubo/test/cli
Marcin Rataj 25ebab9dae
feat(p2p): add --foreground flag to listen and forward commands (#11099)
* feat(p2p): add --foreground flag to listen and forward commands

adds `-f/--foreground` option that keeps the command running until
interrupted (SIGTERM/Ctrl+C) or closed via `ipfs p2p close`. the
listener/forwarder is automatically removed when the command exits.

useful for systemd services and scripts that need cleanup on exit.

* docs: add p2p-tunnels.md with systemd examples

- add dedicated docs/p2p-tunnels.md covering:
  - why p2p tunnels (NAT traversal, no public IP needed)
  - quick start with netcat
  - background and foreground modes
  - systemd integration with path-based activation
  - security considerations and troubleshooting
- document Experimental.Libp2pStreamMounting in docs/config.md
- simplify docs/experimental-features.md, link to new doc
- add "Learn more" links to ipfs p2p listen/forward --help
- update changelog entry with doc link
- add cross-reference in misc/README.md

* chore: reference kubo#5460 for p2p config

Ref. https://github.com/ipfs/kubo/issues/5460

* fix(daemon): write api/gateway files only after HTTP server is ready

fixes race condition where $IPFS_PATH/api and $IPFS_PATH/gateway files
were written before the HTTP servers were ready to accept connections.
this caused issues for tools like systemd path units that immediately
try to connect when these files appear.

changes:
- add corehttp.ServeWithReady() that signals when server is ready
- wait for ready signal before writing address files
- use sync.WaitGroup.Go() (Go 1.25) for cleaner goroutine management
- add TestAddressFileReady to verify both api and gateway files

* fix(daemon): buffer errc channel and wait for all listeners

- buffer error channel with len(listeners) to prevent deadlock when
  multiple servers write errors simultaneously
- wait for ALL listeners to be ready before writing api/gateway file,
  not just the first one

Feedback-from: https://github.com/ipfs/kubo/pull/11099#pullrequestreview-3593885839

* docs(changelog): improve p2p tunnel section clarity

reframe to lead with user benefit and add example output

* docs(p2p): remove obsolete race condition caveat

the "First launch fails but restarts work" troubleshooting section
described a race where the api file was written before the daemon was
ready. this was fixed in 80b703a which ensures api/gateway files are
only written after HTTP servers are ready to accept connections.

---------

Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com>
2026-01-09 19:22:43 +01:00
..
autoconf refactor(config): migration 17-to-18 to unify Provider/Reprovider into Provide.DHT (#10951) 2025-09-18 22:17:43 +02:00
fixtures feat(cli): improve ipfs dag stat output UX (#11097) 2026-01-09 18:41:10 +01:00
harness fix: disable telemetry in test profile (#10931) 2025-08-24 14:30:35 +02:00
migrations fix: migrations for Windows (#11010) 2025-10-08 18:02:04 +02:00
testutils feat: support GetClosesPeers (IPIP-476) and ExposeRoutingAPI by default (#10954) 2025-11-19 10:51:56 +00:00
add_test.go feat: fast provide support in dag import (#11058) 2025-11-14 21:06:25 -08:00
agent_version_unicode_test.go fix(cmds): cleanup unicode identify strings (#9465) 2025-09-19 04:46:38 +02:00
api_file_test.go feat(p2p): add --foreground flag to listen and forward commands (#11099) 2026-01-09 19:22:43 +01:00
backup_bootstrap_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
basic_commands_test.go feat(config): AutoConf with "auto" placeholders (#10883) 2025-08-20 05:59:11 +02:00
bitswap_config_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
bootstrap_auto_test.go feat(config): AutoConf with "auto" placeholders (#10883) 2025-08-20 05:59:11 +02:00
cid_test.go fix(cmd): exit 1 on error (#10903) 2025-08-08 17:25:05 -07:00
cli_https_test.go fix(cli): support HTTPS in ipfs --api (#10659) 2025-01-10 22:34:56 +01:00
commands_without_repo_test.go fix: ipfs cid without repo (#10897) 2025-08-08 16:39:34 +02:00
completion_test.go feat: add zsh completions (#10040) 2023-08-17 16:43:27 +02:00
config_secrets_test.go test: add regression tests for config secrets protection (#11061) 2025-11-17 19:10:40 +01:00
content_blocking_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
content_routing_http_test.go chore: replace random test utils with equivalents in go-test/random (#10915) 2025-08-14 10:37:55 -07:00
daemon_test.go refactor: remove goprocess (#10872) 2025-08-06 00:33:45 +02:00
dag_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
delegated_routing_v1_http_client_test.go feat(gateway): expose /routing/v1 server (opt-in) (#9877) 2023-08-25 17:30:04 +02:00
delegated_routing_v1_http_proxy_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
delegated_routing_v1_http_server_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
dht_autoclient_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
dht_opt_prov_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
files_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
fuse_test.go refactor: remove goprocess (#10872) 2025-08-06 00:33:45 +02:00
gateway_limits_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
gateway_range_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
gateway_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
http_gateway_over_libp2p_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
http_retrieval_client_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
identity_cid_test.go fix: enforce identity CID size limits (#10949) 2025-09-09 20:22:21 +02:00
init_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
ipfswatch_test.go fix(ipfswatch): loading datastore plugins (#11078) 2025-12-10 02:50:59 +01:00
log_level_test.go fix(go-log@2.9/go-libp2p@0.45): dynamic log level control and tail (#11039) 2025-11-06 16:00:56 +01:00
must.go test: port remote pinning tests to Go (#9720) 2023-03-30 07:46:35 -04:00
name_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
p2p_test.go feat(p2p): add --foreground flag to listen and forward commands (#11099) 2026-01-09 19:22:43 +01:00
peering_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
pin_ls_names_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
pin_name_validation_test.go feat: limit pin names to 255 bytes (#10981) 2025-09-25 23:54:04 +02:00
ping_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
pinning_remote_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
pins_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
provide_stats_test.go feat(provide): detailed ipfs provide stat (#11019) 2025-10-23 20:29:36 +02:00
provider_test.go fix(routing): use LegacyProvider for HTTP-only custom routing (#11112) 2026-01-09 18:23:31 +01:00
rcmgr_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
repo_verify_test.go test: verifyWorkerRun and helptext (#11063) 2025-11-17 18:51:33 +01:00
routing_dht_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
rpc_auth_test.go test: add regression tests for API.Authorizations (#11060) 2025-11-17 18:52:05 +01:00
rpc_unixsocket_test.go Cleanup commented imports 2024-08-19 19:55:11 -07:00
stats_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
swarm_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
telemetry_test.go feat(telemetry): collect high level provide DHT sweep settings (#11056) 2025-11-13 01:28:15 +01:00
tracing_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
transports_test.go shutdown daemon after test (#11135) 2026-01-07 20:51:19 -08:00
webui_test.go feat: ipfs-webui v4.9.0 with retrieval diagnostics (#10969) 2025-09-19 04:16:21 +02:00