1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 03:19:47 +08:00

239 Commits

Author SHA1 Message Date
2260e35df2 chore: upgrade to go 1.23 (#10486)
* chore: upgrade to go 1.23

https://tip.golang.org/doc/go1.23

* refactor: golangci-lint v1.60.2
2024-08-28 18:56:45 +02:00
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
6be6630e4e libp2p: stop reporting ProtocolVersion 2023-07-26 14:48:19 +02:00
1fe17a4165 docs(commands): explain that swarm connect can reuse existing connections or known addresses (#10015) 2023-07-20 08:25:56 -07:00
e89cce63fd feat: add identify option to swarm peers command
Fixes #9578
2023-03-30 04:34:57 +00:00
7986196414 feat: Reduce RM code footprint
Co-Authored-By: Antonio Navarro Perez <antnavper@gmail.com>
2023-03-06 12:46:58 +01:00
0ff406170d fix: update rcmgr for go-libp2p v0.25 2023-02-14 22:19:46 +01:00
255e64e49e chore: migrate from go-ipfs-files to go-libipfs/files (#9535) 2023-01-13 14:27:03 +01:00
01e0bfa359 docs: libp2p resource management (#9468)
Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com>
Co-authored-by: Marcin Rataj <lidel@lidel.org>
2022-12-08 16:18:04 +01:00
d16e63a23e Fix: Resource Manager: Filter stats correctly by %
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
2022-12-07 18:05:15 +01:00
254d81a9d5 feat: Improve ResourceManager UX (#9338)
This PR adds several new functionalities to make easier the usage of ResourceManager:

- Now resource manager logs when resources are exceeded are on ERROR instead of warning.
- The resources exceeded error now shows what kind of limit was reached and the scope.
- When there was no limit exceeded, we print a message for the user saying that limits are not exceeded anymore.
- Added `swarm limit all` command to show all set limits with the same format as `swarm stats all`
- Added `min-used-limit-perc` option to `swarm stats all` to only show stats that are above a specific percentage
- Simplify a lot default values.
- **Enable ResourceManager by default.**

Output example:
```
2022-11-09T10:51:40.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:51:50.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 483095 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:51:50.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:52:00.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 455294 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:00.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:52:10.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 471384 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:10.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:52:20.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 8 times with error "peer:12D3KooWKqcaBtcmZKLKCCoDPBuA6AXGJMNrLQUPPMsA5Q6D1eG6: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:20.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 192 times with error "peer:12D3KooWPjetWPGQUih9LZTGHdyAM9fKaXtUxDyBhA93E3JAWCXj: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:20.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 469746 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:20.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:52:30.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 484137 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:30.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 29 times with error "peer:12D3KooWPjetWPGQUih9LZTGHdyAM9fKaXtUxDyBhA93E3JAWCXj: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:30.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:52:40.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 468843 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:40.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:52:50.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 366638 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:52:50.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:53:00.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 405526 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:53:00.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 107 times with error "peer:12D3KooWQZQCwevTDGhkE9iGYk5sBzWRDUSX68oyrcfM9tXyrs2Q: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:53:00.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:53:10.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 336923 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:53:10.566+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:53:20.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:55      Resource limits were exceeded 71 times with error "transient: cannot reserve inbound stream: resource limit exceeded".
2022-11-09T10:53:20.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:59      Consider inspecting logs and raising the resource manager limits. Documentation: https://github.com/ipfs/kubo/blob/master/docs/config.md#swarmresourcemgr
2022-11-09T10:53:30.565+0100    ERROR   resourcemanager libp2p/rcmgr_logging.go:64      Resrouce limits are no longer being exceeded.

```
## Validation tests

- Accelerated DHT client runs with no errors when ResourceManager is active. No problems were observed.
- Running an attack with 200 connections and 1M streams using yamux protocol. Node was usable during the attack. With ResourceManager deactivated, the node was killed by the OS because of the amount of memory consumed.
	- Actions done when the attack was active:
		- Add files 
		- Force a reprovide
		- Use the gateway to resolve an IPNS address.

It closes #9001 
It closes #9351
It closes #9322
2022-11-10 12:25:57 +01:00
3574caede5 fix: error when using huge json limit file
This error nicely instead of ooming when trying to use a json file so big it would oom.
2022-11-08 22:28:14 +01:00
b5fe824964 fix ipfs swarm peering crash in offline mode (#9261) 2022-10-13 16:43:06 +02:00
bf8274f6e2 feat: --reset flag on swarm limit command (#9310)
* feat: --reset flag on swarm limit command

This flag allows to the user to reset limits to default values.

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>

* Use adjusted default limits and remove already fixed FIXME

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>

* Apply suggestions from code review

Co-authored-by: Gus Eggert <gus@gus.dev>

* Return correct defaults

* Remove resetting all values from a map.

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
Co-authored-by: Gus Eggert <gus@gus.dev>
2022-10-12 11:02:43 -04:00
e550d9e476 ci: add stylecheck to golangci-lint (#9334) 2022-10-06 10:18:40 -04:00
196887cbe5 chore: bump go-libp2p v0.22.0 & go1.18&go1.19
Fixes: #9225
2022-09-09 17:09:38 +02:00
c3589a1728 WIP rcmgr auto limit scaling 2022-08-15 14:12:18 -07:00
82467bc936 refactor: rename to kubo 2022-07-06 18:40:37 +02:00
0a01574ff7 docs: fix typo in the swarm/peering help text 2022-06-03 08:37:58 -07:00
5615715c55 feat: log when resource manager limits are exceeded (#8980)
This periodically logs how many times Resource Manager limits were
exceeded. If they aren't exceeded, then nothing is logged. The log
levels are at ERROR log level so that they are shown by default.

The motivation is so that users know when they have exceeded resource
manager limits. To find what is exceeding the limits, they'll need to
turn on debug logging and inspect the errors being logged. This could
collect the specific limits being reached, but that's more complicated
to implement and could result in much longer log messages.
2022-05-19 15:27:44 -04:00
74aff245d2 feat: persist limits to Swarm.ResourceMgr.Limits (#8901)
* feat: persist limit changes to config

This changes the "ipfs swarm limit" command so that when limit changes
are applied via the command line, they are persisted to the repo
config, so that they remain in effect when the daemon restarts.

Any existing limit.json can be dropped into the IPFS config easily
using something like:

cat ~/.ipfs/config | jq ".Swarm.ResourceMgr.Limits = $(cat limit.json)" | sponge ~/.ipfs/config

This also upgrades to Resource Manager v0.3.0, which exports the config
schema so that we don't have to maintain our own copy of it.

Co-authored-by: Marcin Rataj <lidel@lidel.org>
2022-04-28 15:27:16 +02:00
514411bedb feat: opt-in Swarm.ResourceMgr (go-libp2p v0.18) (#8680)
* update go-libp2p to v0.18.0

* initialize the resource manager

* add resource manager stats/limit commands

* load limit file when building resource manager

* log absent limit file

* write rcmgr to file when IPFS_DEBUG_RCMGR is set

* fix: mark swarm limit|stats as experimental

* feat(cfg): opt-in Swarm.ResourceMgr

This ensures we can safely test the resource manager without impacting
default behavior.

- Resource manager is disabled by default
    - Default for Swarm.ResourceMgr.Enabled is false for now
- Swarm.ResourceMgr.Limits allows user to tweak limits per specific
  scope in a way that is persisted across restarts
- 'ipfs swarm limit system' outputs human-readable json
- 'ipfs swarm limit system new-limits.json' sets new runtime limits
  (but does not change Swarm.ResourceMgr.Limits in the config)

Conventions to make libp2p devs life easier:
- 'IPFS_RCMGR=1 ipfs daemon' overrides the config and enables resource manager
- 'limit.json' overrides implicit defaults from libp2p (if present)

* docs(config): small tweaks

* fix: skip libp2p.ResourceManager if disabled

This ensures 'ipfs swarm limit|stats' work only when enabled.

* fix: use NullResourceManager when disabled

This reverts commit b19f7c9eca4cee4187f8cba3389dc2c930258512.
after clarification feedback from
https://github.com/ipfs/go-ipfs/pull/8680#discussion_r841680182

* style: rename IPFS_RCMGR to LIBP2P_RCMGR

preexisting libp2p toggles use LIBP2P_ prefix

* test: Swarm.ResourceMgr

* fix: location of opt-in limit.json and rcmgr.json.gz

Places these files inside of IPFS_PATH

* Update docs/config.md

* feat: expose rcmgr metrics when enabled (#8785)

* add metrics for the resource manager
* export protocol and service name in Prometheus metrics
* fix: expose rcmgr metrics only when enabled

Co-authored-by: Marcin Rataj <lidel@lidel.org>

* refactor: rcmgr_metrics.go

* refactor: rcmgr_defaults.go

This file defines implicit limit defaults used when Swarm.ResourceMgr.Enabled

We keep vendored copy to ensure go-ipfs is not impacted when go-libp2p
decides to change defaults in any of the future releases.

* refactor: adjustedDefaultLimits

Cleans up the way we initialize defaults and adds a fix for case
when connection manager runs with high limits.

It also hides `Swarm.ResourceMgr.Limits` until we have a better
understanding what syntax makes sense.

* chore: cleanup after a review

* fix: restore go-ipld-prime v0.14.2

* fix: restore go-ds-flatfs v0.5.1

Co-authored-by: Lucas Molas <schomatis@gmail.com>
Co-authored-by: Marcin Rataj <lidel@lidel.org>
2022-04-07 21:06:35 -04:00
8d549f03f3 fix: rewrite dependencies over the go-ipfs-config package 2022-03-04 09:45:16 +01:00
a43e506d7f fix: multibase in pubsub http rpc (#8183)
* multibase encoding on pubsub
* emit multibase for json clients
* refactor(pubsub): base64url for all URL args

This makes it easier to reason about.
Also added better helptext to each command explaining how the binary
data is encoded on the wire, and how to process it in userland.

* refactor: remove ndpayload and lenpayload

Those output formats are undocumented and seem to be only used in tests.
This change removes their implementation and replaces it with error
message to use JSON instead.

I also refactored tests to test the --enc=json response format instead
of imaginary one, making tests more useful as they also act as
regression tests for HTTP RPC.

* test(pubsub): go-ipfs-api

Testing against compatible version from
https://github.com/ipfs/go-ipfs-api/pull/255

* refactor: safeTextListEncoder

Making it clear what it does and why

* refactor(pubsub): unify peerids

This ensures `ipfs pubsub sub` returns the same peerids in the `From`
field as `ipfs pubsub peers`.

libp2p already uses base encoding, no need to double wrap or use custom
multibase.

* test(pubsub): go-ipfs-http-client

* refactor(pubsub): make pub command read from a file

We want to send payload in the body as multipart so users can use
existing tools like curl for publishing arbitrary bytes to a topic.

StringArg was created for "one message per line" use case, and if data
has `\n` or `\r\n` byte sequences, it will cause payload to be split. It
is not possible to undo this, because mentioned sequences are lost, so
we are not able to tell if it was `\n` or `\r\n`

We already avoid this problem in `block put` and `dht put` by reading
payload via FileArg which does not mangle binary data and send it as-is.
It feel like `pubsub pub` should be using it in the first place anyway,
so this commit replaces StringArg with FileArg.

This also closes https://github.com/ipfs/go-ipfs/issues/8454
and makes rpc in go-ipfs easier to code against.

* test(pubsub): publishing with line breaks

Making sure we don't see regressions in the future.
Ref. https://github.com/ipfs/go-ipfs/issues/7939

* chore: disable pubsub interop for now

See
344f692d8c

* test: t0322-pubsub-http-rpc.sh

- Adds HTTP RPC regression test that ensures topic is encoded as URL-safe
  multibase.
- Moves pubsub tests to live in unique range ./t032x

* fix(ci):  js-ipfs with  fixed pubsub wire format

uses js-ipfs from https://github.com/ipfs/js-ipfs/pull/3922 
until js-ipfs release can ship with dependency on go-ipfs 0.11.0-rc1

Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Adin Schmahmann <adin.schmahmann@gmail.com>
2021-11-29 23:06:54 +01:00
a651045c50 feature: 'ipfs swarm peering' command (#8147)
* feat: added swarm peering command supporting add, ls and rm

Co-authored-by: Steven Allen <steven@stebalien.com>
2021-09-15 07:46:16 -07:00
543c5da34a explicit construction of DNS resolver 2021-05-10 21:03:27 -07:00
69ccf99915 chore: update libp2p 2020-05-20 16:56:22 -07:00
26c5e38571 fix: use the correct protocol name for ipfs swarm addrs local --id 2020-02-05 07:46:37 -08:00
15c35a5a95 doc: update documentation for /ipfs -> /p2p multiaddr switch
See: https://github.com/libp2p/libp2p/issues/79
2019-12-14 19:39:59 +01:00
c9f3d4b9ab cmds(help): fix swarm filter add/rm help text
These _are_ added/removed from the config.

fixes #4605
2019-09-20 15:02:11 -07:00
5d468e23ea chore: deprecate go-ipfs-addr 2019-05-31 23:46:11 -07:00
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
2b84b2ba13 chore: fix linter nits and tests that don't compile 2019-05-21 11:09:57 -07:00
5f64b270f8 cmdkit -> cmds
License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-05-10 23:00:20 -07:00
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
5fc7b027fd fix(swarm): improve swarm connect no peers found error
License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-03-18 19:13:56 -07:00
1cc8c3a17e fix(swarm): catch cases where we fail to resolve an address to a peer
License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-03-18 19:13:53 -07:00
f1b6888081 fix(swarm): use the go fork/join idiom
License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-03-18 19:13:49 -07:00
291614848f fix(swarm): feed through context
License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-03-18 19:13:43 -07:00
597bf2a481 fix(swarm): collect maddr by channel
License: MIT
Signed-off-by: Overbool <overbool.xu@gmail.com>
2019-03-18 18:52:16 -07:00
309cf70570 fix(swarm): add dnsaddr support in swarm connect
License: MIT
Signed-off-by: Overbool <overbool.xu@gmail.com>
2019-03-18 18:51:20 -07:00
42e191c017 gx: unrewrite
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
2019-03-05 18:33:56 +01:00
3fa1bfe1bc gx: update cmds and flatfs
fixes #6028, fixes crash when writing after closing on flatfs.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-03-01 12:17:49 -08:00
f227862e88 gx: update go-ipfs-cmds, go-bitswap, go-libp2p-kad-dht, and go-mplex
Fixes the latest batch of bugs found in RC testing.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-02-27 12:39:24 -08:00
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
3c2536dd81 gx: update go-ipfs-cmds
fixes #6021

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-02-25 16:45:43 -07:00
2f17b951c2 gx: update deps
* Updates go-ipfs-cmds to try to get the tests to pass on travis.
* While we're at it, fix duplicate gx deps.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-02-19 13:12:21 -08:00
28cf3de0f9 Update protobuf
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
2019-02-18 20:46:22 +01:00
e97a60b073 gx: update go-ipfs-files
fix compatibility issue with js-ipfs

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2019-02-11 10:48:58 -08:00