Commit Graph

310 Commits

Author SHA1 Message Date
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
Andrew Gillis
20d9660a64
chore: use go-log/v2 (#10801)
Some checks are pending
CodeQL / codeql (push) Waiting to run
Docker Build / docker-build (push) Waiting to run
Gateway Conformance / gateway-conformance (push) Waiting to run
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Waiting to run
Go Build / go-build (push) Waiting to run
Go Check / go-check (push) Waiting to run
Go Lint / go-lint (push) Waiting to run
Go Test / go-test (push) Waiting to run
Interop / interop-prep (push) Waiting to run
Interop / helia-interop (push) Blocked by required conditions
Interop / ipfs-webui (push) Blocked by required conditions
Sharness / sharness-test (push) Waiting to run
Spell Check / spellcheck (push) Waiting to run
* chore: update to go-log/v2

go-log v2 has been out for quite a while now and it is time to deprecate v1.

Replace all use of go-log with go-log/v2
Makes /api/v0/log/tail useful over HTTP
Updates dependencies that have moved to go-lov/v2
Removes support for ContextWithLoggable as this is not needed for tracing-like functionality
- Replaces: PR #8765
- Closes issue #8753
- Closes issue #9245
- Closes issue #10809

Other fixes:
* update go-ipfs-cmds
* update http logs test
* fix test
* Read/send one line of log data at a time
* Update -log-level docs
2025-05-19 13:04:05 -07:00
Icarus9913
9fdb085605
refactor: stop using go-libp2p deprecated peer.ID.Pretty
Signed-off-by: Icarus9913 <icaruswu66@qq.com>
2023-09-18 15:58:15 +02:00
Kay
f12b372af9
style: gofumpt and godot [skip changelog] (#10081) 2023-08-17 14:02:08 +02:00
Marten Seemann
a00f5cae23 chore: update go-libp2p to v0.25.1 2023-02-14 22:19:46 +01:00
Jorropo
196887cbe5 chore: bump go-libp2p v0.22.0 & go1.18&go1.19
Fixes: #9225
2022-09-09 17:09:38 +02:00
Adin Schmahmann
b88bdfeb9d chore: update go-multiaddr and go-multiaddr-net 2020-08-25 15:24:48 -04:00
Steven Allen
a53d48059b fix: migrate from deprecated warning function 2020-01-28 21:20:21 -08:00
Raúl Kripalani
e8c2852179 migrate to go-libp2p-core.
closes #6391

License: MIT
Signed-off-by: Raúl Kripalani <raul@protocol.ai>
2019-05-31 23:23:52 -07:00
Łukasz Magiera
456084e613 constructor: drop P2P prefix from libp2p related units
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2019-04-23 13:30:58 +02:00
Steven Allen
1f293eff1b chore: fix a bunch of issues caught by golangci-lint
Most of these are probably harmless but a few looked like they might actually be
bugs. Most of them are just faulty tests.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-03-29 11:57:45 +00:00
Jakub Sztandera
42e191c017 gx: unrewrite
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
2019-03-05 18:33:56 +01:00
Hector Sanjuan
6972a9aa4d Gx Bubble. libp2p-6.0.38
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-02-27 01:10:59 +00:00
Jakub Sztandera
28cf3de0f9 Update protobuf
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
2019-02-18 20:46:22 +01:00
Steven Allen
2c93eeffc6 gx: update go-libp2p-peer
Switch _back_ to the 0.4.18 style of peer IDs while we figure things out. See
https://github.com/libp2p/specs/issues/138.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-02-07 17:41:39 -08:00
Steven Allen
08cc5da55f gx: update deps
Importantly:

* fixes a bunch of MFS bugs
* pulls in some bitswap improvements

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-01-08 19:19:34 -08:00
Steven Allen
9dcec2b3e2 gx: update go-libp2p-peer
Reverts the changes that allowed small keys (ed25519 keys) to be inlined.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2018-12-07 15:37:23 -08:00
Łukasz Magiera
c0a1e80f36 p2p: report-peer-id option for listen
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-11-29 20:49:17 -08:00
hannahhoward
0963c9cdcb Update go-ipfs-delay and assoc deps
License: MIT
Signed-off-by: hannahhoward <hannah@hannahhoward.net>
2018-11-15 18:53:45 -08:00
Steven Allen
0d80fc54c3 gx: update go-log and sha256
fixes #5709

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2018-11-02 21:17:20 -07:00
Steven Allen
c97c3459be gx update
License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2018-10-24 09:59:43 -07:00
Steven Allen
dd4d8bb25e
Merge pull request #5529 from overbool/fix/issue-#5523
fix(p2p): issue #5523
2018-10-18 19:33:44 +01:00
Steven Allen
8117a2bcee gx: update go-buffer-pool
Turns out that `pool.Put(buf)` had to *allocate* because we needed to turn
`[]byte` into `interface{}`. Apparently, we've never done this correctly we just
never noticed because we never really used buffer pools extensively.

However, since migrating yamux to a buffer-pool backed buffer, this started
showing up in allocation profiles.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2018-10-10 14:11:31 +01:00
Steven Allen
098933ade4 gx: update stuff
* go-datastore and friends: GetSize
* badger: new release, fewer allocations
* go-mplex: send fewer packets
* go-bitswap: pack multiple blocks in a single message, fewer allocations
* go-buffer-pool: replace the buffer pool from go-msgio
* yamux: fixed data race and uses go-buffer-pool for stream read-buffers to
  reduce memory and allocations.
* go-libp2p-secio: get rid of a hot-spot allocation
* go-libp2p-peerstore: reduced allocations (at the cost of some memory)

More?

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2018-10-05 14:48:44 -07:00
Overbool
03ad3b87ff fix(p2p): issue #5523
License: MIT
Signed-off-by: Overbool <overbool.xu@gmail.com>
2018-10-05 13:30:31 +08:00
Lars Gierth
2c3ed7efb0 gx: update go-datastore, go-libp2p-swarm
License: MIT
Signed-off-by: Lars Gierth <larsg@systemli.org>
2018-10-04 19:52:42 -04:00
Steven Allen
dac058f8be gx: update go-log go-ipld-cbor
(and friends)

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2018-09-24 05:36:29 -07:00
Łukasz Magiera
b53936a706 p2p: Close on Listeners
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-12 23:27:15 +02:00
Łukasz Magiera
0b575bc0c5 p2p: rebase import updates
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:58:39 +02:00
Łukasz Magiera
f5cb640d25 p2p: simplify listener startup
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
80b89405ed p2p: fix docstrings
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
05bc3bd924 p2p: simplify remote handler matching
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
228a71aef2 p2p: deduplicate some listeners logic
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
c5090508a8 p2p: fix connmgr use
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
bba2d05ca9 p2p: cleanup after listener iface split
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
dd48b8237a p2p: separate listener types
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
d184433e6d p2p: hold lock when handling new streams
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
87567645f4 p2p: test for double-registering listeners
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
35eaa1664c p2p: rebase updates
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
0f9d284421 p2p: use host.SetStreamHandlerMatch for now
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
4badcdc340 p2p: tag connections in connection manager
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
8849193de0 p2p: more locks
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
5e8725dbde p2p: test to ensure closing right linsters
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
4c98edaff6 p2p: fix remote/local listener races
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
a3c84e20ef p2p: refactor review
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
df0e566e98 p2p: update deps after rebase
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
830ed48703 p2p: refactor first review
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
3e0184bdad p2p: fix codeclimate warnings
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
0465079f35 p2p: fix ci
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00
Łukasz Magiera
e8ba4fc01a p2p: fix sharness tests after refactor
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-09-11 04:57:40 +02:00