diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000000..eeba0640dc6 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: [ipshipyard.gitwallet.co] diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 9472db123b9..b0d0d1f0db1 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -18,7 +18,7 @@ body: label: Checklist description: Please verify that you've followed these steps options: - - label: This is a bug report, not a question. Ask questions on [discuss.ipfs.io](https://discuss.ipfs.io). + - label: This is a bug report, not a question. Ask questions on [discuss.ipfs.tech](https://discuss.ipfs.tech/c/help/13). required: true - label: I have searched on the [issue tracker](https://github.com/ipfs/kubo/issues?q=is%3Aissue) for my bug. required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index f3f53fe6cac..ec985b0bc36 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,7 +1,7 @@ blank_issues_enabled: false contact_links: - name: Getting Help on IPFS - url: https://ipfs.io/help + url: https://ipfs.tech/help about: All information about how and where to get help on IPFS. - name: Kubo configuration reference url: https://github.com/ipfs/kubo/blob/master/docs/config.md#readme @@ -9,9 +9,9 @@ contact_links: - name: Kubo experimental features docs url: https://github.com/ipfs/kubo/blob/master/docs/experimental-features.md#readme about: Documentation on Private Networks, Filestore and other experimental features. - - name: RPC API Reference + - name: Kubo RPC API Reference url: https://docs.ipfs.tech/reference/kubo/rpc/ about: Documentation of all Kubo RPC API endpoints. - - name: IPFS Official Forum - url: https://discuss.ipfs.io + - name: IPFS Official Discussion Forum + url: https://discuss.ipfs.tech about: Please post general questions, support requests, and discussions here. diff --git a/.github/ISSUE_TEMPLATE/enhancement.yml b/.github/ISSUE_TEMPLATE/enhancement.yml index 9bfeba5b516..a0b241b557b 100644 --- a/.github/ISSUE_TEMPLATE/enhancement.yml +++ b/.github/ISSUE_TEMPLATE/enhancement.yml @@ -6,11 +6,11 @@ body: - type: markdown attributes: value: | - Suggest an enhancement to Kubo (the program). If you'd like to suggest an improvement to the IPFS protocol, please discuss it on [the forum](https://discuss.ipfs.io). + Suggest an enhancement to Kubo (the program). If you'd like to suggest an improvement to the IPFS protocol, please discuss it on [the forum](https://discuss.ipfs.tech). Issues in this repo must be specific, actionable, and well motivated. They should be starting points for _building_ new features, not brainstorming ideas. - If you have an idea you'd like to discuss, please open a new thread on [the forum](https://discuss.ipfs.io). + If you have an idea you'd like to discuss, please open a new thread on [the forum](https://discuss.ipfs.tech). **Example:** diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml index cf2fa81167f..d368588b419 100644 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -6,11 +6,11 @@ body: - type: markdown attributes: value: | - Suggest a new feature in Kubo (the program). If you'd like to suggest an improvement to the IPFS protocol, please discuss it on [the forum](https://discuss.ipfs.io). + Suggest a new feature in Kubo (the program). If you'd like to suggest an improvement to the IPFS protocol, please discuss it on [the forum](https://discuss.ipfs.tech). Issues in this repo must be specific, actionable, and well motivated. They should be starting points for _building_ new features, not brainstorming ideas. - If you have an idea you'd like to discuss, please open a new thread on [the forum](https://discuss.ipfs.io). + If you have an idea you'd like to discuss, please open a new thread on [the forum](https://discuss.ipfs.tech). **Example:** diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2d1ce7dd2d7..2967c999721 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ on: - 'master' env: - GO_VERSION: 1.21.x + GO_VERSION: 1.22.x concurrency: group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 69beb5e377c..d0e082d6597 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,7 +34,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: 1.22.x # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 733dc2c0e0d..433240f42a1 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -28,7 +28,7 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: 1.22.x - uses: actions/checkout@v4 - run: docker build -t $IMAGE_NAME:$WIP_IMAGE_TAG . - run: docker run --rm $IMAGE_NAME:$WIP_IMAGE_TAG --version diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 33c5bb5491f..9c2f6d4eaa6 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -63,7 +63,7 @@ jobs: shell: bash - name: Log in to Docker Hub - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d + uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 with: username: ${{ vars.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} diff --git a/.github/workflows/gateway-conformance.yml b/.github/workflows/gateway-conformance.yml index 4a94287ecdc..0f369864162 100644 --- a/.github/workflows/gateway-conformance.yml +++ b/.github/workflows/gateway-conformance.yml @@ -49,7 +49,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: 1.22.x - uses: protocol/cache-go-action@v1 with: name: ${{ github.job }} @@ -137,7 +137,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: 1.22.x - uses: protocol/cache-go-action@v1 with: name: ${{ github.job }} diff --git a/.github/workflows/gobuild.yml b/.github/workflows/gobuild.yml index f5de9e5173f..93159eaddc8 100644 --- a/.github/workflows/gobuild.yml +++ b/.github/workflows/gobuild.yml @@ -30,7 +30,7 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: 1.22.x - uses: actions/checkout@v4 - run: make cmd/ipfs-try-build env: diff --git a/.github/workflows/golang-analysis.yml b/.github/workflows/golang-analysis.yml index 0643de16054..e89034a9210 100644 --- a/.github/workflows/golang-analysis.yml +++ b/.github/workflows/golang-analysis.yml @@ -27,7 +27,7 @@ jobs: submodules: recursive - uses: actions/setup-go@v5 with: - go-version: "1.21.x" + go-version: "1.22.x" - name: Check that go.mod is tidy uses: protocol/multiple-go-modules@v1.4 with: diff --git a/.github/workflows/golint.yml b/.github/workflows/golint.yml index 59150747150..aa8b21b534b 100644 --- a/.github/workflows/golint.yml +++ b/.github/workflows/golint.yml @@ -31,6 +31,6 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: 1.22.x - uses: actions/checkout@v4 - run: make -O test_go_lint diff --git a/.github/workflows/gotest.yml b/.github/workflows/gotest.yml index a69dbc2f0d9..2e34922d62c 100644 --- a/.github/workflows/gotest.yml +++ b/.github/workflows/gotest.yml @@ -32,7 +32,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: 1.22.x - name: Check out Kubo uses: actions/checkout@v4 - name: Install missing tools @@ -45,7 +45,7 @@ jobs: make -j "$PARALLEL" test/unit/gotest.junit.xml && [[ ! $(jq -s -c 'map(select(.Action == "fail")) | .[]' test/unit/gotest.json) ]] - name: Upload coverage to Codecov - uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1 + uses: codecov/codecov-action@7afa10ed9b269c561c2336fd862446844e0cbf71 # v4.2.0 if: failure() || success() with: name: unittests diff --git a/.github/workflows/sharness.yml b/.github/workflows/sharness.yml index 436ef34a1be..03c04f922dc 100644 --- a/.github/workflows/sharness.yml +++ b/.github/workflows/sharness.yml @@ -25,7 +25,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: 1.22.x - name: Checkout Kubo uses: actions/checkout@v4 with: @@ -55,7 +55,7 @@ jobs: # increasing parallelism beyond 10 doesn't speed up the tests much PARALLEL: ${{ github.repository == 'ipfs/kubo' && 10 || 3 }} - name: Upload coverage report - uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1 + uses: codecov/codecov-action@7afa10ed9b269c561c2336fd862446844e0cbf71 # v4.2.0 if: failure() || success() with: name: sharness diff --git a/CHANGELOG.md b/CHANGELOG.md index bfcf27bed31..cd0dc69b9fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Kubo Changelogs +- [v0.28](docs/changelogs/v0.28.md) - [v0.27](docs/changelogs/v0.27.md) - [v0.26](docs/changelogs/v0.26.md) - [v0.25](docs/changelogs/v0.25.md) diff --git a/Dockerfile b/Dockerfile index d68e525b9f8..4ed07d3d403 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21 AS builder +FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.22 AS builder ARG TARGETOS TARGETARCH diff --git a/README.md b/README.md index 74b53c3ad6e..d2ff46a9310 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,24 @@ Official images are published at https://hub.docker.com/r/ipfs/kubo/: [![Docker Image Version (latest semver)](https://img.shields.io/docker/v/ipfs/kubo?color=blue&label=kubo%20docker%20image&logo=docker&sort=semver&style=flat-square&cacheSeconds=3600)](https://hub.docker.com/r/ipfs/kubo/) -More info on how to run Kubo (go-ipfs) inside Docker can be found [here](https://docs.ipfs.tech/how-to/run-ipfs-inside-docker/). +- 🟢 Releases + - `latest` and `release` tags always point at [the latest stable release](https://github.com/ipfs/kubo/releases/latest) + - `vN.N.N` points at a specific [release tag](https://github.com/ipfs/kubo/releases) + - These are production grade images. +- 🟠 We also provide experimental developer builds + - `master-latest` always points at the `HEAD` of the `master` branch + - `master-YYYY-DD-MM-GITSHA` points at a specific commit from the `master` branch + - These tags are used by developers for internal testing, not intended for end users or production use. + +```console +$ docker pull ipfs/kubo:latest +$ docker run --rm -it --net=host ipfs/kubo:latest +``` + +To [customize your node](https://docs.ipfs.tech/install/run-ipfs-inside-docker/#customizing-your-node), +pass necessary config via `-e` or by mounting scripts in the `/container-init.d`. + +Learn more at https://docs.ipfs.tech/install/run-ipfs-inside-docker/ ### Official prebuilt binaries @@ -428,7 +445,9 @@ We ❤️ all [our contributors](docs/AUTHORS); this project wouldn’t be what This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). -Please reach out to us in one [chat](https://docs.ipfs.tech/community/chat/) rooms. +Members of IPFS community provide Kubo support on [discussion forum category here](https://discuss.ipfs.tech/c/help/help-kubo/23). + +Need help with IPFS itself? Learn where to get help and support at https://ipfs.tech/help. ## License diff --git a/assets/assets.go b/assets/assets.go index 17bfa89413a..6196ed22f89 100644 --- a/assets/assets.go +++ b/assets/assets.go @@ -9,9 +9,7 @@ import ( "github.com/ipfs/kubo/core/coreapi" "github.com/ipfs/boxo/files" - "github.com/ipfs/boxo/path" cid "github.com/ipfs/go-cid" - options "github.com/ipfs/kubo/core/coreiface/options" ) //go:embed init-doc @@ -39,12 +37,7 @@ func addAssetList(nd *core.IpfsNode, l []string) (cid.Cid, error) { return cid.Cid{}, err } - dirb, err := api.Object().New(nd.Context(), options.Object.Type("unixfs-dir")) - if err != nil { - return cid.Cid{}, err - } - - basePath := path.FromCid(dirb.Cid()) + dirMap := map[string]files.Node{} for _, p := range l { d, err := Asset.ReadFile(p) @@ -52,17 +45,12 @@ func addAssetList(nd *core.IpfsNode, l []string) (cid.Cid, error) { return cid.Cid{}, fmt.Errorf("assets: could load Asset '%s': %s", p, err) } - fp, err := api.Unixfs().Add(nd.Context(), files.NewBytesFile(d)) - if err != nil { - return cid.Cid{}, err - } - - fname := gopath.Base(p) + dirMap[gopath.Base(p)] = files.NewBytesFile(d) + } - basePath, err = api.Object().AddLink(nd.Context(), basePath, fname, fp) - if err != nil { - return cid.Cid{}, err - } + basePath, err := api.Unixfs().Add(nd.Context(), files.NewMapDirectory(dirMap)) + if err != nil { + return cid.Cid{}, err } if err := api.Pin().Add(nd.Context(), basePath); err != nil { diff --git a/bin/ipns-republish b/bin/ipns-republish index f5535ee4c4a..5fc81cd5724 100755 --- a/bin/ipns-republish +++ b/bin/ipns-republish @@ -19,7 +19,7 @@ if [ $? -ne 0 ]; then fi # check the object is there -ipfs object stat "$1" >/dev/null +ipfs dag stat "$1" >/dev/null if [ $? -ne 0 ]; then echo "error: ipfs cannot find $1" exit 1 diff --git a/client/rpc/api.go b/client/rpc/api.go index 827b427c9ff..79d42124a7b 100644 --- a/client/rpc/api.go +++ b/client/rpc/api.go @@ -227,12 +227,6 @@ func (api *HttpApi) Object() iface.ObjectAPI { return (*ObjectAPI)(api) } -// nolint deprecated -// Deprecated: use [HttpApi.Routing] instead. -func (api *HttpApi) Dht() iface.DhtAPI { - return (*DhtAPI)(api) -} - func (api *HttpApi) Swarm() iface.SwarmAPI { return (*SwarmAPI)(api) } diff --git a/client/rpc/api_test.go b/client/rpc/api_test.go index 25bd26ceea6..c0da3d7b04e 100644 --- a/client/rpc/api_test.go +++ b/client/rpc/api_test.go @@ -46,7 +46,6 @@ func (np NodeProvider) MakeAPISwarm(t *testing.T, ctx context.Context, fullIdent c := n.ReadConfig() c.Experimental.FilestoreEnabled = true n.WriteConfig(c) - n.StartDaemon("--enable-pubsub-experiment", "--offline="+strconv.FormatBool(!online)) if online { diff --git a/client/rpc/dht.go b/client/rpc/dht.go deleted file mode 100644 index cfc886a49e6..00000000000 --- a/client/rpc/dht.go +++ /dev/null @@ -1,33 +0,0 @@ -package rpc - -import ( - "context" - - "github.com/ipfs/boxo/path" - caopts "github.com/ipfs/kubo/core/coreiface/options" - "github.com/libp2p/go-libp2p/core/peer" -) - -type DhtAPI HttpApi - -// nolint deprecated -// Deprecated: use [RoutingAPI.FindPeer] instead. -func (api *DhtAPI) FindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, error) { - return api.core().Routing().FindPeer(ctx, p) -} - -// nolint deprecated -// Deprecated: use [RoutingAPI.FindProviders] instead. -func (api *DhtAPI) FindProviders(ctx context.Context, p path.Path, opts ...caopts.DhtFindProvidersOption) (<-chan peer.AddrInfo, error) { - return api.core().Routing().FindProviders(ctx, p, opts...) -} - -// nolint deprecated -// Deprecated: use [RoutingAPI.Provide] instead. -func (api *DhtAPI) Provide(ctx context.Context, p path.Path, opts ...caopts.DhtProvideOption) error { - return api.core().Routing().Provide(ctx, p, opts...) -} - -func (api *DhtAPI) core() *HttpApi { - return (*HttpApi)(api) -} diff --git a/client/rpc/errors.go b/client/rpc/errors.go index 84340b550e2..6c136ebefeb 100644 --- a/client/rpc/errors.go +++ b/client/rpc/errors.go @@ -138,7 +138,7 @@ func parseIPLDErrNotFound(msg string) (error, bool) { // This is a simple error type that just return msg as Error(). // But that also match ipld.ErrNotFound when called with Is(err). -// That is needed to keep compatiblity with code that use string.Contains(err.Error(), "blockstore: block not found") +// That is needed to keep compatibility with code that use string.Contains(err.Error(), "blockstore: block not found") // and code using ipld.ErrNotFound. type blockstoreNotFoundMatchingIPLDErrNotFound struct { msg string diff --git a/client/rpc/object.go b/client/rpc/object.go index 9e00bfb7711..5c9d323e87b 100644 --- a/client/rpc/object.go +++ b/client/rpc/object.go @@ -1,16 +1,10 @@ package rpc import ( - "bytes" "context" - "fmt" - "io" - "github.com/ipfs/boxo/ipld/merkledag" - ft "github.com/ipfs/boxo/ipld/unixfs" "github.com/ipfs/boxo/path" "github.com/ipfs/go-cid" - ipld "github.com/ipfs/go-ipld-format" iface "github.com/ipfs/kubo/core/coreiface" caopts "github.com/ipfs/kubo/core/coreiface/options" ) @@ -21,138 +15,6 @@ type objectOut struct { Hash string } -func (api *ObjectAPI) New(ctx context.Context, opts ...caopts.ObjectNewOption) (ipld.Node, error) { - options, err := caopts.ObjectNewOptions(opts...) - if err != nil { - return nil, err - } - - var n ipld.Node - switch options.Type { - case "empty": - n = new(merkledag.ProtoNode) - case "unixfs-dir": - n = ft.EmptyDirNode() - default: - return nil, fmt.Errorf("unknown object type: %s", options.Type) - } - - return n, nil -} - -func (api *ObjectAPI) Put(ctx context.Context, r io.Reader, opts ...caopts.ObjectPutOption) (path.ImmutablePath, error) { - options, err := caopts.ObjectPutOptions(opts...) - if err != nil { - return path.ImmutablePath{}, err - } - - var out objectOut - err = api.core().Request("object/put"). - Option("inputenc", options.InputEnc). - Option("datafieldenc", options.DataType). - Option("pin", options.Pin). - FileBody(r). - Exec(ctx, &out) - if err != nil { - return path.ImmutablePath{}, err - } - - c, err := cid.Parse(out.Hash) - if err != nil { - return path.ImmutablePath{}, err - } - - return path.FromCid(c), nil -} - -func (api *ObjectAPI) Get(ctx context.Context, p path.Path) (ipld.Node, error) { - r, err := api.core().Block().Get(ctx, p) - if err != nil { - return nil, err - } - b, err := io.ReadAll(r) - if err != nil { - return nil, err - } - - return merkledag.DecodeProtobuf(b) -} - -func (api *ObjectAPI) Data(ctx context.Context, p path.Path) (io.Reader, error) { - resp, err := api.core().Request("object/data", p.String()).Send(ctx) - if err != nil { - return nil, err - } - if resp.Error != nil { - return nil, resp.Error - } - - // TODO: make Data return ReadCloser to avoid copying - defer resp.Close() - b := new(bytes.Buffer) - if _, err := io.Copy(b, resp.Output); err != nil { - return nil, err - } - - return b, nil -} - -func (api *ObjectAPI) Links(ctx context.Context, p path.Path) ([]*ipld.Link, error) { - var out struct { - Links []struct { - Name string - Hash string - Size uint64 - } - } - if err := api.core().Request("object/links", p.String()).Exec(ctx, &out); err != nil { - return nil, err - } - res := make([]*ipld.Link, len(out.Links)) - for i, l := range out.Links { - c, err := cid.Parse(l.Hash) - if err != nil { - return nil, err - } - - res[i] = &ipld.Link{ - Cid: c, - Name: l.Name, - Size: l.Size, - } - } - - return res, nil -} - -func (api *ObjectAPI) Stat(ctx context.Context, p path.Path) (*iface.ObjectStat, error) { - var out struct { - Hash string - NumLinks int - BlockSize int - LinksSize int - DataSize int - CumulativeSize int - } - if err := api.core().Request("object/stat", p.String()).Exec(ctx, &out); err != nil { - return nil, err - } - - c, err := cid.Parse(out.Hash) - if err != nil { - return nil, err - } - - return &iface.ObjectStat{ - Cid: c, - NumLinks: out.NumLinks, - BlockSize: out.BlockSize, - LinksSize: out.LinksSize, - DataSize: out.DataSize, - CumulativeSize: out.CumulativeSize, - }, nil -} - func (api *ObjectAPI) AddLink(ctx context.Context, base path.Path, name string, child path.Path, opts ...caopts.ObjectAddLinkOption) (path.ImmutablePath, error) { options, err := caopts.ObjectAddLinkOptions(opts...) if err != nil { @@ -191,40 +53,6 @@ func (api *ObjectAPI) RmLink(ctx context.Context, base path.Path, link string) ( return path.FromCid(c), nil } -func (api *ObjectAPI) AppendData(ctx context.Context, p path.Path, r io.Reader) (path.ImmutablePath, error) { - var out objectOut - err := api.core().Request("object/patch/append-data", p.String()). - FileBody(r). - Exec(ctx, &out) - if err != nil { - return path.ImmutablePath{}, err - } - - c, err := cid.Parse(out.Hash) - if err != nil { - return path.ImmutablePath{}, err - } - - return path.FromCid(c), nil -} - -func (api *ObjectAPI) SetData(ctx context.Context, p path.Path, r io.Reader) (path.ImmutablePath, error) { - var out objectOut - err := api.core().Request("object/patch/set-data", p.String()). - FileBody(r). - Exec(ctx, &out) - if err != nil { - return path.ImmutablePath{}, err - } - - c, err := cid.Parse(out.Hash) - if err != nil { - return path.ImmutablePath{}, err - } - - return path.FromCid(c), nil -} - type change struct { Type iface.ChangeType Path string diff --git a/cmd/ipfs/dist/README.md b/cmd/ipfs/dist/README.md index 4517f655b7b..7ff65e9f2d2 100644 --- a/cmd/ipfs/dist/README.md +++ b/cmd/ipfs/dist/README.md @@ -1,6 +1,7 @@ # ipfs command line tool -This is the [ipfs](http://ipfs.io) command line tool. It contains a full ipfs node. +This is a [command line tool for interacting with Kubo](https://docs.ipfs.tech/install/command-line/), +an [IPFS](https://ipfs.tech) implementation. It contains a full IPFS node. ## Install diff --git a/cmd/ipfs/kubo/daemon.go b/cmd/ipfs/kubo/daemon.go index 82f24089710..ab034b20a14 100644 --- a/cmd/ipfs/kubo/daemon.go +++ b/cmd/ipfs/kubo/daemon.go @@ -424,7 +424,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment case routingOptionNoneKwd: ncfg.Routing = libp2p.NilRouterOption case routingOptionCustomKwd: - if cfg.Routing.AcceleratedDHTClient { + if cfg.Routing.AcceleratedDHTClient.WithDefault(config.DefaultAcceleratedDHTClient) { return fmt.Errorf("Routing.AcceleratedDHTClient option is set even tho Routing.Type is custom, using custom .AcceleratedDHTClient needs to be set on DHT routers individually") } ncfg.Routing = libp2p.ConstructDelegatedRouting( @@ -850,8 +850,6 @@ func serveHTTPGateway(req *cmds.Request, cctx *oldcmds.Context) (<-chan error, e corehttp.GatewayOption("/ipfs", "/ipns"), corehttp.VersionOption(), corehttp.CheckVersionOption(), - // TODO[api-on-gw]: remove for 0.28.0: https://github.com/ipfs/kubo/issues/10312 - corehttp.CommandsROOption(cmdctx), } if cfg.Experimental.P2pHttpProxy { @@ -932,10 +930,6 @@ func serveTrustlessGatewayOverLibp2p(cctx *oldcmds.Context) (<-chan error, error StreamHost: node.PeerHost, } - tmpProtocol := protocol.ID("/kubo/delete-me") - h.SetHTTPHandler(tmpProtocol, http.NotFoundHandler()) - h.WellKnownHandler.RemoveProtocolMeta(tmpProtocol) - h.WellKnownHandler.AddProtocolMeta(gatewayProtocolID, p2phttp.ProtocolMeta{Path: "/"}) h.ServeMux = http.NewServeMux() h.ServeMux.Handle("/", handler) diff --git a/config/gateway.go b/config/gateway.go index fa093245d9a..35af598b435 100644 --- a/config/gateway.go +++ b/config/gateway.go @@ -9,7 +9,7 @@ const ( type GatewaySpec struct { // Paths is explicit list of path prefixes that should be handled by - // this gateway. Example: `["/ipfs", "/ipns", "/api"]` + // this gateway. Example: `["/ipfs", "/ipns"]` Paths []string // UseSubdomains indicates whether or not this gateway uses subdomains diff --git a/config/profile.go b/config/profile.go index 83d53359dae..068498715c5 100644 --- a/config/profile.go +++ b/config/profile.go @@ -82,6 +82,7 @@ is useful when using the daemon in test environments.`, } c.Swarm.DisableNatPortMap = true + c.Routing.LoopbackAddressesOnLanDHT = True c.Bootstrap = []string{} c.Discovery.MDNS.Enabled = false @@ -174,7 +175,7 @@ functionality - performance of content discovery and data fetching may be degraded. `, Transform: func(c *Config) error { - c.Routing.Type = NewOptionalString("dhtclient") // TODO: https://github.com/ipfs/kubo/issues/9480 + c.Routing.Type = NewOptionalString("autoclient") c.AutoNAT.ServiceMode = AutoNATServiceDisabled c.Reprovider.Interval = NewOptionalDuration(0) diff --git a/config/routing.go b/config/routing.go index 60faa605cce..231cbca732c 100644 --- a/config/routing.go +++ b/config/routing.go @@ -6,6 +6,11 @@ import ( "runtime" ) +var ( + DefaultAcceleratedDHTClient = false + DefaultLoopbackAddressesOnLanDHT = false +) + // Routing defines configuration options for libp2p routing. type Routing struct { // Type sets default daemon routing mode. @@ -15,7 +20,9 @@ type Routing struct { // When "custom" is set, user-provided Routing.Routers is used. Type *OptionalString `json:",omitempty"` - AcceleratedDHTClient bool + AcceleratedDHTClient Flag `json:",omitempty"` + + LoopbackAddressesOnLanDHT Flag `json:",omitempty"` Routers Routers diff --git a/core/commands/commands_test.go b/core/commands/commands_test.go index 99cd07988dd..38172fd66d9 100644 --- a/core/commands/commands_test.go +++ b/core/commands/commands_test.go @@ -15,63 +15,6 @@ func collectPaths(prefix string, cmd *cmds.Command, out map[string]struct{}) { } } -func TestROCommands(t *testing.T) { - list := []string{ - "/block", - "/block/get", - "/block/stat", - "/cat", - "/commands", - "/commands/completion", - "/commands/completion/bash", - "/commands/completion/fish", - "/commands/completion/zsh", - "/dag", - "/dag/get", - "/dag/resolve", - "/dag/stat", - "/dag/export", - "/get", - "/ls", - "/name", - "/name/resolve", - "/object", - "/object/data", - "/object/get", - "/object/links", - "/object/stat", - "/refs", - "/resolve", - "/version", - } - - cmdSet := make(map[string]struct{}) - collectPaths("", RootRO, cmdSet) - - for _, path := range list { - if _, ok := cmdSet[path]; !ok { - t.Errorf("%q not in result", path) - } else { - delete(cmdSet, path) - } - } - - for path := range cmdSet { - t.Errorf("%q in result but shouldn't be", path) - } - - for _, path := range list { - path = path[1:] // remove leading slash - split := strings.Split(path, "/") - sub, err := RootRO.Get(split) - if err != nil { - t.Errorf("error getting subcommand %q: %v", path, err) - } else if sub == nil { - t.Errorf("subcommand %q is nil even though there was no error", path) - } - } -} - func TestCommands(t *testing.T) { list := []string{ "/add", @@ -118,6 +61,11 @@ func TestCommands(t *testing.T) { "/dag/stat", "/dht", "/dht/query", + "/dht/findprovs", + "/dht/findpeer", + "/dht/get", + "/dht/provide", + "/dht/put", "/routing", "/routing/put", "/routing/get", diff --git a/core/commands/dht.go b/core/commands/dht.go index c86b6262f8b..1d46201819b 100644 --- a/core/commands/dht.go +++ b/core/commands/dht.go @@ -15,13 +15,19 @@ import ( var ErrNotDHT = errors.New("routing service is not a DHT") var DhtCmd = &cmds.Command{ + Status: cmds.Deprecated, Helptext: cmds.HelpText{ Tagline: "Issue commands directly through the DHT.", ShortDescription: ``, }, Subcommands: map[string]*cmds.Command{ - "query": queryDhtCmd, + "query": queryDhtCmd, + "findprovs": RemovedDHTCmd, + "findpeer": RemovedDHTCmd, + "get": RemovedDHTCmd, + "put": RemovedDHTCmd, + "provide": RemovedDHTCmd, }, } @@ -32,6 +38,7 @@ type kademlia interface { } var queryDhtCmd = &cmds.Command{ + Status: cmds.Deprecated, Helptext: cmds.HelpText{ Tagline: "Find the closest Peer IDs to a given Peer ID by querying the DHT.", ShortDescription: "Outputs a list of newline-delimited Peer IDs.", @@ -114,3 +121,12 @@ var queryDhtCmd = &cmds.Command{ }, Type: routing.QueryEvent{}, } +var RemovedDHTCmd = &cmds.Command{ + Status: cmds.Removed, + Helptext: cmds.HelpText{ + Tagline: "Removed, use 'ipfs routing' instead.", + }, + Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { + return errors.New("removed, use 'ipfs routing' instead") + }, +} diff --git a/core/commands/name/publish.go b/core/commands/name/publish.go index 9c8d837cb83..168d7fb445f 100644 --- a/core/commands/name/publish.go +++ b/core/commands/name/publish.go @@ -79,7 +79,7 @@ Alternatively, publish an using a valid PeerID (as listed by cmds.StringOption(ttlOptionName, "Time duration hint, akin to --lifetime, indicating how long to cache this record before checking for updates.").WithDefault(ipns.DefaultRecordTTL.String()), cmds.BoolOption(quieterOptionName, "Q", "Write only final IPNS Name encoded as CIDv1 (for use in /ipns content paths)."), cmds.BoolOption(v1compatOptionName, "Produce a backward-compatible IPNS Record by including fields for both V1 and V2 signatures.").WithDefault(true), - cmds.BoolOption(allowOfflineOptionName, "When --offline, save the IPNS record to the the local datastore without broadcasting to the network (instead of failing)."), + cmds.BoolOption(allowOfflineOptionName, "When --offline, save the IPNS record to the local datastore without broadcasting to the network (instead of failing)."), ke.OptionIPNSBase, }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { diff --git a/core/commands/object/object.go b/core/commands/object/object.go index 5a8577cf295..380ca253389 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -1,28 +1,11 @@ package objectcmd import ( - "encoding/base64" "errors" - "fmt" - "io" - "text/tabwriter" cmds "github.com/ipfs/go-ipfs-cmds" - "github.com/ipfs/kubo/core/commands/cmdenv" - "github.com/ipfs/kubo/core/commands/cmdutils" - - humanize "github.com/dustin/go-humanize" - dag "github.com/ipfs/boxo/ipld/merkledag" - "github.com/ipfs/go-cid" - ipld "github.com/ipfs/go-ipld-format" - "github.com/ipfs/kubo/core/coreiface/options" ) -type Node struct { - Links []Link - Data string -} - type Link struct { Name, Hash string Size uint64 @@ -35,16 +18,6 @@ type Object struct { var ErrDataEncoding = errors.New("unknown data field encoding") -const ( - headersOptionName = "headers" - encodingOptionName = "data-encoding" - inputencOptionName = "inputenc" - datafieldencOptionName = "datafieldenc" - pinOptionName = "pin" - quietOptionName = "quiet" - humanOptionName = "human" -) - var ObjectCmd = &cmds.Command{ Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7936 Helptext: cmds.HelpText{ @@ -55,516 +28,23 @@ directly. Deprecated, use more modern 'ipfs dag' and 'ipfs files' instead.`, }, Subcommands: map[string]*cmds.Command{ - "data": ObjectDataCmd, + "data": RemovedObjectCmd, "diff": ObjectDiffCmd, - "get": ObjectGetCmd, - "links": ObjectLinksCmd, - "new": ObjectNewCmd, + "get": RemovedObjectCmd, + "links": RemovedObjectCmd, + "new": RemovedObjectCmd, "patch": ObjectPatchCmd, - "put": ObjectPutCmd, - "stat": ObjectStatCmd, - }, -} - -// ObjectDataCmd object data command -var ObjectDataCmd = &cmds.Command{ - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7936 - Helptext: cmds.HelpText{ - Tagline: "Deprecated way to read the raw bytes of a dag-pb object: use 'dag get' instead.", - ShortDescription: ` -'ipfs object data' is a deprecated plumbing command for retrieving the raw -bytes stored in a dag-pb node. It outputs to stdout, and is a base58 -encoded multihash. Provided for legacy reasons. Use 'ipfs dag get' instead. -`, - LongDescription: ` -'ipfs object data' is a deprecated plumbing command for retrieving the raw -bytes stored in a dag-pb node. It outputs to stdout, and is a base58 -encoded multihash. Provided for legacy reasons. Use 'ipfs dag get' instead. - -Note that the "--encoding" option does not affect the output, since the output -is the raw data of the object. -`, - }, - - Arguments: []cmds.Argument{ - cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format.").EnableStdin(), - }, - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - api, err := cmdenv.GetApi(env, req) - if err != nil { - return err - } - - path, err := cmdutils.PathOrCidPath(req.Arguments[0]) - if err != nil { - return err - } - - data, err := api.Object().Data(req.Context, path) - if err != nil { - return err - } - - return res.Emit(data) - }, -} - -// ObjectLinksCmd object links command -var ObjectLinksCmd = &cmds.Command{ - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7936 - Helptext: cmds.HelpText{ - Tagline: "Deprecated way to output links in the specified dag-pb object: use 'dag get' instead.", - ShortDescription: ` -'ipfs object links' is a plumbing command for retrieving the links from -a dag-pb node. It outputs to stdout, and is a base58 encoded -multihash. Provided for legacy reasons. Use 'ipfs dag get' instead. -`, - }, - - Arguments: []cmds.Argument{ - cmds.StringArg("key", true, false, "Key of the dag-pb object to retrieve, in base58-encoded multihash format.").EnableStdin(), - }, - Options: []cmds.Option{ - cmds.BoolOption(headersOptionName, "v", "Print table headers (Hash, Size, Name)."), - }, - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - api, err := cmdenv.GetApi(env, req) - if err != nil { - return err - } - - enc, err := cmdenv.GetLowLevelCidEncoder(req) - if err != nil { - return err - } - - path, err := cmdutils.PathOrCidPath(req.Arguments[0]) - if err != nil { - return err - } - - rp, _, err := api.ResolvePath(req.Context, path) - if err != nil { - return err - } - - links, err := api.Object().Links(req.Context, rp) - if err != nil { - return err - } - - outLinks := make([]Link, len(links)) - for i, link := range links { - outLinks[i] = Link{ - Hash: enc.Encode(link.Cid), - Name: link.Name, - Size: link.Size, - } - } - - out := &Object{ - Hash: enc.Encode(rp.RootCid()), - Links: outLinks, - } - - return cmds.EmitOnce(res, out) - }, - Encoders: cmds.EncoderMap{ - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *Object) error { - tw := tabwriter.NewWriter(w, 1, 2, 1, ' ', 0) - headers, _ := req.Options[headersOptionName].(bool) - if headers { - fmt.Fprintln(tw, "Hash\tSize\tName") - } - for _, link := range out.Links { - fmt.Fprintf(tw, "%s\t%v\t%s\n", link.Hash, link.Size, cmdenv.EscNonPrint(link.Name)) - } - tw.Flush() - - return nil - }), - }, - Type: &Object{}, -} - -// ObjectGetCmd object get command -var ObjectGetCmd = &cmds.Command{ - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7936 - Helptext: cmds.HelpText{ - Tagline: "Deprecated way to get and serialize the dag-pb node. Use 'dag get' instead", - ShortDescription: ` -'ipfs object get' is a plumbing command for retrieving dag-pb nodes. -It serializes the DAG node to the format specified by the "--encoding" -flag. It outputs to stdout, and is a base58 encoded multihash. - -DEPRECATED and provided for legacy reasons. Use 'ipfs dag get' instead. -`, - }, - - Arguments: []cmds.Argument{ - cmds.StringArg("key", true, false, "Key of the dag-pb object to retrieve, in base58-encoded multihash format.").EnableStdin(), - }, - Options: []cmds.Option{ - cmds.StringOption(encodingOptionName, "Encoding type of the data field, either \"text\" or \"base64\".").WithDefault("text"), - }, - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - api, err := cmdenv.GetApi(env, req) - if err != nil { - return err - } - - enc, err := cmdenv.GetLowLevelCidEncoder(req) - if err != nil { - return err - } - - path, err := cmdutils.PathOrCidPath(req.Arguments[0]) - if err != nil { - return err - } - - datafieldenc, _ := req.Options[encodingOptionName].(string) - if err != nil { - return err - } - - nd, err := api.Object().Get(req.Context, path) - if err != nil { - return err - } - - r, err := api.Object().Data(req.Context, path) - if err != nil { - return err - } - - data, err := io.ReadAll(r) - if err != nil { - return err - } - - out, err := encodeData(data, datafieldenc) - if err != nil { - return err - } - - node := &Node{ - Links: make([]Link, len(nd.Links())), - Data: out, - } - - for i, link := range nd.Links() { - node.Links[i] = Link{ - Hash: enc.Encode(link.Cid), - Name: link.Name, - Size: link.Size, - } - } - - return cmds.EmitOnce(res, node) - }, - Type: Node{}, - Encoders: cmds.EncoderMap{ - cmds.Protobuf: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *Node) error { - // deserialize the Data field as text as this was the standard behaviour - object, err := deserializeNode(out, "text") - if err != nil { - return nil - } - - marshaled, err := object.Marshal() - if err != nil { - return err - } - _, err = w.Write(marshaled) - return err - }), - }, -} - -// ObjectStatCmd object stat command -var ObjectStatCmd = &cmds.Command{ - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7936 - Helptext: cmds.HelpText{ - Tagline: "Deprecated way to read stats for the dag-pb node. Use 'files stat' instead.", - ShortDescription: ` -'ipfs object stat' is a plumbing command to print dag-pb node statistics. - is a base58 encoded multihash. - -DEPRECATED: modern replacements are 'files stat' and 'dag stat' -`, - LongDescription: ` -'ipfs object stat' is a plumbing command to print dag-pb node statistics. - is a base58 encoded multihash. It outputs to stdout: - - NumLinks int number of links in link table - BlockSize int size of the raw, encoded data - LinksSize int size of the links segment - DataSize int size of the data segment - CumulativeSize int cumulative size of object and its references - -DEPRECATED: Provided for legacy reasons. Modern replacements: - - For unixfs, 'ipfs files stat' can be used: - - $ ipfs files stat --with-local /ipfs/QmWfVY9y3xjsixTgbd9AorQxH7VtMpzfx2HaWtsoUYecaX - QmWfVY9y3xjsixTgbd9AorQxH7VtMpzfx2HaWtsoUYecaX - Size: 5 - CumulativeSize: 13 - ChildBlocks: 0 - Type: file - Local: 13 B of 13 B (100.00%) - - Reported sizes are based on metadata present in root block, and should not be - trusted. A slower, but more secure alternative is 'ipfs dag stat', which - will work for every DAG type. It comes with a benefit of calculating the - size by walking the DAG: - - $ ipfs dag stat /ipfs/QmWfVY9y3xjsixTgbd9AorQxH7VtMpzfx2HaWtsoUYecaX - Size: 13, NumBlocks: 1 -`, - }, - - Arguments: []cmds.Argument{ - cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format.").EnableStdin(), - }, - Options: []cmds.Option{ - cmds.BoolOption(humanOptionName, "Print sizes in human readable format (e.g., 1K 234M 2G)"), - }, - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - api, err := cmdenv.GetApi(env, req) - if err != nil { - return err - } - - enc, err := cmdenv.GetLowLevelCidEncoder(req) - if err != nil { - return err - } - - p, err := cmdutils.PathOrCidPath(req.Arguments[0]) - if err != nil { - return err - } - - ns, err := api.Object().Stat(req.Context, p) - if err != nil { - return err - } - - oldStat := &ipld.NodeStat{ - Hash: enc.Encode(ns.Cid), - NumLinks: ns.NumLinks, - BlockSize: ns.BlockSize, - LinksSize: ns.LinksSize, - DataSize: ns.DataSize, - CumulativeSize: ns.CumulativeSize, - } - - return cmds.EmitOnce(res, oldStat) - }, - Type: ipld.NodeStat{}, - Encoders: cmds.EncoderMap{ - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *ipld.NodeStat) error { - wtr := tabwriter.NewWriter(w, 0, 0, 1, ' ', 0) - defer wtr.Flush() - fw := func(s string, n int) { - fmt.Fprintf(wtr, "%s:\t%d\n", s, n) - } - human, _ := req.Options[humanOptionName].(bool) - fw("NumLinks", out.NumLinks) - fw("BlockSize", out.BlockSize) - fw("LinksSize", out.LinksSize) - fw("DataSize", out.DataSize) - if human { - fmt.Fprintf(wtr, "%s:\t%s\n", "CumulativeSize", humanize.Bytes(uint64(out.CumulativeSize))) - } else { - fw("CumulativeSize", out.CumulativeSize) - } - - return nil - }), - }, -} - -// ObjectPutCmd object put command -var ObjectPutCmd = &cmds.Command{ - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7936 - Helptext: cmds.HelpText{ - Tagline: "Deprecated way to store input as a DAG object. Use 'dag put' instead.", - ShortDescription: ` -'ipfs object put' is a plumbing command for storing dag-pb nodes. -It reads from stdin, and the output is a base58 encoded multihash. - -DEPRECATED and provided for legacy reasons. Use 'ipfs dag put' instead. -`, - }, - - Arguments: []cmds.Argument{ - cmds.FileArg("data", true, false, "Data to be stored as a dag-pb object.").EnableStdin(), - }, - Options: []cmds.Option{ - cmds.StringOption(inputencOptionName, "Encoding type of input data. One of: {\"protobuf\", \"json\"}.").WithDefault("json"), - cmds.StringOption(datafieldencOptionName, "Encoding type of the data field, either \"text\" or \"base64\".").WithDefault("text"), - cmds.BoolOption(pinOptionName, "Pin this object when adding."), - cmds.BoolOption(quietOptionName, "q", "Write minimal output."), - }, - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - api, err := cmdenv.GetApi(env, req) - if err != nil { - return err - } - - enc, err := cmdenv.GetLowLevelCidEncoder(req) - if err != nil { - return err - } - - file, err := cmdenv.GetFileArg(req.Files.Entries()) - if err != nil { - return err - } - - inputenc, _ := req.Options[inputencOptionName].(string) - if err != nil { - return err - } - - datafieldenc, _ := req.Options[datafieldencOptionName].(string) - if err != nil { - return err - } - - dopin, _ := req.Options[pinOptionName].(bool) - if err != nil { - return err - } - - p, err := api.Object().Put(req.Context, file, - options.Object.DataType(datafieldenc), - options.Object.InputEnc(inputenc), - options.Object.Pin(dopin)) - if err != nil { - return err - } - - return cmds.EmitOnce(res, &Object{Hash: enc.Encode(p.RootCid())}) - }, - Encoders: cmds.EncoderMap{ - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *Object) error { - quiet, _ := req.Options[quietOptionName].(bool) - - o := out.Hash - if !quiet { - o = "added " + o - } - - fmt.Fprintln(w, o) - - return nil - }), + "put": RemovedObjectCmd, + "stat": RemovedObjectCmd, }, - Type: Object{}, } -// ObjectNewCmd object new command -var ObjectNewCmd = &cmds.Command{ - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7936 +var RemovedObjectCmd = &cmds.Command{ + Status: cmds.Removed, Helptext: cmds.HelpText{ - Tagline: "Deprecated way to create a new dag-pb object from a template.", - ShortDescription: ` -'ipfs object new' is a plumbing command for creating new dag-pb nodes. -DEPRECATED and provided for legacy reasons. Use 'dag put' and 'files' instead. -`, - LongDescription: ` -'ipfs object new' is a plumbing command for creating new dag-pb nodes. -By default it creates and returns a new empty merkledag node, but -you may pass an optional template argument to create a preformatted -node. - -Available templates: - * unixfs-dir - -DEPRECATED and provided for legacy reasons. Use 'dag put' and 'files' instead. -`, - }, - Arguments: []cmds.Argument{ - cmds.StringArg("template", false, false, "Template to use. Optional."), + Tagline: "Removed, use 'ipfs dag' or 'ipfs files' instead.", }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - api, err := cmdenv.GetApi(env, req) - if err != nil { - return err - } - - enc, err := cmdenv.GetLowLevelCidEncoder(req) - if err != nil { - return err - } - - template := "empty" - if len(req.Arguments) == 1 { - template = req.Arguments[0] - } - - nd, err := api.Object().New(req.Context, options.Object.Type(template)) - if err != nil && err != io.EOF { - return err - } - - return cmds.EmitOnce(res, &Object{Hash: enc.Encode(nd.Cid())}) + return errors.New("removed, use 'ipfs dag' or 'ipfs files' instead") }, - Encoders: cmds.EncoderMap{ - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *Object) error { - fmt.Fprintln(w, out.Hash) - return nil - }), - }, - Type: Object{}, -} - -// converts the Node object into a real dag.ProtoNode -func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error) { - dagnode := new(dag.ProtoNode) - switch dataFieldEncoding { - case "text": - dagnode.SetData([]byte(nd.Data)) - case "base64": - data, err := base64.StdEncoding.DecodeString(nd.Data) - if err != nil { - return nil, err - } - dagnode.SetData(data) - default: - return nil, ErrDataEncoding - } - - links := make([]*ipld.Link, len(nd.Links)) - for i, link := range nd.Links { - c, err := cid.Decode(link.Hash) - if err != nil { - return nil, err - } - links[i] = &ipld.Link{ - Name: link.Name, - Size: link.Size, - Cid: c, - } - } - if err := dagnode.SetLinks(links); err != nil { - return nil, err - } - - return dagnode, nil -} - -func encodeData(data []byte, encoding string) (string, error) { - switch encoding { - case "text": - return string(data), nil - case "base64": - return base64.StdEncoding.EncodeToString(data), nil - } - - return "", ErrDataEncoding } diff --git a/core/commands/object/patch.go b/core/commands/object/patch.go index 7c35151fbe2..5a82dfe0b69 100644 --- a/core/commands/object/patch.go +++ b/core/commands/object/patch.go @@ -37,128 +37,16 @@ For modern use cases, use MFS with 'files' commands: 'ipfs files --help'. }, Arguments: []cmds.Argument{}, Subcommands: map[string]*cmds.Command{ - "append-data": patchAppendDataCmd, + "append-data": RemovedObjectCmd, "add-link": patchAddLinkCmd, "rm-link": patchRmLinkCmd, - "set-data": patchSetDataCmd, + "set-data": RemovedObjectCmd, }, Options: []cmds.Option{ cmdutils.AllowBigBlockOption, }, } -var patchAppendDataCmd = &cmds.Command{ - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7936 - Helptext: cmds.HelpText{ - Tagline: "Deprecated way to append data to the data segment of a DAG node.", - ShortDescription: ` -Append data to what already exists in the data segment in the given object. - -Example: - - $ echo "hello" | ipfs object patch $HASH append-data - -NOTE: This does not append data to a file - it modifies the actual raw -data within a dag-pb object. Blocks have a max size of 1MiB and objects larger than -the limit will not be respected by the network. - -DEPRECATED and provided for legacy reasons. Use 'ipfs add' or 'ipfs files' instead. -`, - }, - Arguments: []cmds.Argument{ - cmds.StringArg("root", true, false, "The hash of the node to modify."), - cmds.FileArg("data", true, false, "Data to append.").EnableStdin(), - }, - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - api, err := cmdenv.GetApi(env, req) - if err != nil { - return err - } - - root, err := cmdutils.PathOrCidPath(req.Arguments[0]) - if err != nil { - return err - } - - file, err := cmdenv.GetFileArg(req.Files.Entries()) - if err != nil { - return err - } - - p, err := api.Object().AppendData(req.Context, root, file) - if err != nil { - return err - } - - if err := cmdutils.CheckCIDSize(req, p.RootCid(), api.Dag()); err != nil { - return err - } - - return cmds.EmitOnce(res, &Object{Hash: p.RootCid().String()}) - }, - Type: &Object{}, - Encoders: cmds.EncoderMap{ - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, obj *Object) error { - _, err := fmt.Fprintln(w, obj.Hash) - return err - }), - }, -} - -var patchSetDataCmd = &cmds.Command{ - Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7936 - Helptext: cmds.HelpText{ - Tagline: "Deprecated way to set the data field of dag-pb object.", - ShortDescription: ` -Set the data of an IPFS object from stdin or with the contents of a file. - -Example: - - $ echo "my data" | ipfs object patch $MYHASH set-data - -DEPRECATED and provided for legacy reasons. Use 'files cp' and 'dag put' instead. -`, - }, - Arguments: []cmds.Argument{ - cmds.StringArg("root", true, false, "The hash of the node to modify."), - cmds.FileArg("data", true, false, "The data to set the object to.").EnableStdin(), - }, - Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - api, err := cmdenv.GetApi(env, req) - if err != nil { - return err - } - - root, err := cmdutils.PathOrCidPath(req.Arguments[0]) - if err != nil { - return err - } - - file, err := cmdenv.GetFileArg(req.Files.Entries()) - if err != nil { - return err - } - - p, err := api.Object().SetData(req.Context, root, file) - if err != nil { - return err - } - - if err := cmdutils.CheckCIDSize(req, p.RootCid(), api.Dag()); err != nil { - return err - } - - return cmds.EmitOnce(res, &Object{Hash: p.RootCid().String()}) - }, - Type: Object{}, - Encoders: cmds.EncoderMap{ - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *Object) error { - fmt.Fprintln(w, out.Hash) - return nil - }), - }, -} - var patchRmLinkCmd = &cmds.Command{ Status: cmds.Deprecated, // https://github.com/ipfs/kubo/issues/7936 Helptext: cmds.HelpText{ diff --git a/core/commands/root.go b/core/commands/root.go index b4e563cdb3a..d062e75b45f 100644 --- a/core/commands/root.go +++ b/core/commands/root.go @@ -162,72 +162,9 @@ var rootSubcommands = map[string]*cmds.Command{ "multibase": MbaseCmd, } -// RootRO is the readonly version of Root -var RootRO = &cmds.Command{} - -var CommandsDaemonROCmd = CommandsCmd(RootRO) - -// RefsROCmd is `ipfs refs` command -var RefsROCmd = &cmds.Command{} - -// VersionROCmd is `ipfs version` command (without deps). -var VersionROCmd = &cmds.Command{} - -var rootROSubcommands = map[string]*cmds.Command{ - "commands": CommandsDaemonROCmd, - "cat": CatCmd, - "block": { - Subcommands: map[string]*cmds.Command{ - "stat": blockStatCmd, - "get": blockGetCmd, - }, - }, - "get": GetCmd, - "ls": LsCmd, - "name": { - Subcommands: map[string]*cmds.Command{ - "resolve": name.IpnsCmd, - }, - }, - "object": { - Subcommands: map[string]*cmds.Command{ - "data": ocmd.ObjectDataCmd, - "links": ocmd.ObjectLinksCmd, - "get": ocmd.ObjectGetCmd, - "stat": ocmd.ObjectStatCmd, - }, - }, - "dag": { - Subcommands: map[string]*cmds.Command{ - "get": dag.DagGetCmd, - "resolve": dag.DagResolveCmd, - "stat": dag.DagStatCmd, - "export": dag.DagExportCmd, - }, - }, - "resolve": ResolveCmd, -} - func init() { Root.ProcessHelp() - *RootRO = *Root - - // this was in the big map definition above before, - // but if we leave it there lgc.NewCommand will be executed - // before the value is updated (:/sanitize readonly refs command/) - - // sanitize readonly refs command - *RefsROCmd = *RefsCmd - RefsROCmd.Subcommands = map[string]*cmds.Command{} - rootROSubcommands["refs"] = RefsROCmd - - // sanitize readonly version command (no need to expose precise deps) - *VersionROCmd = *VersionCmd - VersionROCmd.Subcommands = map[string]*cmds.Command{} - rootROSubcommands["version"] = VersionROCmd - Root.Subcommands = rootSubcommands - RootRO.Subcommands = rootROSubcommands } type MessageOutput struct { diff --git a/core/commands/root_test.go b/core/commands/root_test.go index f5e5c248bda..d1bf2e610ef 100644 --- a/core/commands/root_test.go +++ b/core/commands/root_test.go @@ -18,5 +18,4 @@ func TestCommandTree(t *testing.T) { } } printErrors(Root.DebugValidate()) - printErrors(RootRO.DebugValidate()) } diff --git a/core/commands/routing.go b/core/commands/routing.go index 2442570acb5..3e503b014c9 100644 --- a/core/commands/routing.go +++ b/core/commands/routing.go @@ -426,7 +426,7 @@ identified by QmFoo. cmds.FileArg("value-file", true, false, "A path to a file containing the value to store.").EnableStdin(), }, Options: []cmds.Option{ - cmds.BoolOption(allowOfflineOptionName, "When offline, save the IPNS record to the the local datastore without broadcasting to the network instead of simply failing."), + cmds.BoolOption(allowOfflineOptionName, "When offline, save the IPNS record to the local datastore without broadcasting to the network instead of simply failing."), }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { api, err := cmdenv.GetApi(env, req) diff --git a/core/coreapi/coreapi.go b/core/coreapi/coreapi.go index 6c6aa4907e8..b757929a26c 100644 --- a/core/coreapi/coreapi.go +++ b/core/coreapi/coreapi.go @@ -130,12 +130,6 @@ func (api *CoreAPI) Pin() coreiface.PinAPI { return (*PinAPI)(api) } -// nolint deprecated -// Deprecated: use [CoreAPI.Routing] instead. -func (api *CoreAPI) Dht() coreiface.DhtAPI { - return (*DhtAPI)(api) -} - // Swarm returns the SwarmAPI interface implementation backed by the go-ipfs node func (api *CoreAPI) Swarm() coreiface.SwarmAPI { return (*SwarmAPI)(api) diff --git a/core/coreapi/dht.go b/core/coreapi/dht.go deleted file mode 100644 index f9155de008e..00000000000 --- a/core/coreapi/dht.go +++ /dev/null @@ -1,34 +0,0 @@ -package coreapi - -import ( - "context" - - "github.com/ipfs/boxo/path" - coreiface "github.com/ipfs/kubo/core/coreiface" - caopts "github.com/ipfs/kubo/core/coreiface/options" - peer "github.com/libp2p/go-libp2p/core/peer" -) - -type DhtAPI CoreAPI - -// nolint deprecated -// Deprecated: use [RoutingAPI.FindPeer] instead. -func (api *DhtAPI) FindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, error) { - return api.core().Routing().FindPeer(ctx, p) -} - -// nolint deprecated -// Deprecated: use [RoutingAPI.FindProviders] instead. -func (api *DhtAPI) FindProviders(ctx context.Context, p path.Path, opts ...caopts.DhtFindProvidersOption) (<-chan peer.AddrInfo, error) { - return api.core().Routing().FindProviders(ctx, p, opts...) -} - -// nolint deprecated -// Deprecated: use [RoutingAPI.Provide] instead. -func (api *DhtAPI) Provide(ctx context.Context, p path.Path, opts ...caopts.DhtProvideOption) error { - return api.core().Routing().Provide(ctx, p, opts...) -} - -func (api *DhtAPI) core() coreiface.CoreAPI { - return (*CoreAPI)(api) -} diff --git a/core/coreapi/object.go b/core/coreapi/object.go index fca98bc5fa4..0f6c2747a57 100644 --- a/core/coreapi/object.go +++ b/core/coreapi/object.go @@ -1,22 +1,12 @@ package coreapi import ( - "bytes" "context" - "encoding/base64" - "encoding/json" - "encoding/xml" - "errors" - "fmt" - "io" dag "github.com/ipfs/boxo/ipld/merkledag" "github.com/ipfs/boxo/ipld/merkledag/dagutils" ft "github.com/ipfs/boxo/ipld/unixfs" "github.com/ipfs/boxo/path" - pin "github.com/ipfs/boxo/pinning/pinner" - cid "github.com/ipfs/go-cid" - ipld "github.com/ipfs/go-ipld-format" coreiface "github.com/ipfs/kubo/core/coreiface" caopts "github.com/ipfs/kubo/core/coreiface/options" "go.opentelemetry.io/otel/attribute" @@ -25,8 +15,6 @@ import ( "github.com/ipfs/kubo/tracing" ) -const inputLimit = 2 << 20 - type ObjectAPI CoreAPI type Link struct { @@ -39,180 +27,6 @@ type Node struct { Data string } -func (api *ObjectAPI) New(ctx context.Context, opts ...caopts.ObjectNewOption) (ipld.Node, error) { - ctx, span := tracing.Span(ctx, "CoreAPI.ObjectAPI", "New") - defer span.End() - - options, err := caopts.ObjectNewOptions(opts...) - if err != nil { - return nil, err - } - - var n ipld.Node - switch options.Type { - case "empty": - n = new(dag.ProtoNode) - case "unixfs-dir": - n = ft.EmptyDirNode() - default: - return nil, fmt.Errorf("unknown node type: %s", options.Type) - } - - err = api.dag.Add(ctx, n) - if err != nil { - return nil, err - } - return n, nil -} - -func (api *ObjectAPI) Put(ctx context.Context, src io.Reader, opts ...caopts.ObjectPutOption) (path.ImmutablePath, error) { - ctx, span := tracing.Span(ctx, "CoreAPI.ObjectAPI", "Put") - defer span.End() - - options, err := caopts.ObjectPutOptions(opts...) - if err != nil { - return path.ImmutablePath{}, err - } - span.SetAttributes( - attribute.Bool("pin", options.Pin), - attribute.String("datatype", options.DataType), - attribute.String("inputenc", options.InputEnc), - ) - - data, err := io.ReadAll(io.LimitReader(src, inputLimit+10)) - if err != nil { - return path.ImmutablePath{}, err - } - - var dagnode *dag.ProtoNode - switch options.InputEnc { - case "json": - node := new(Node) - decoder := json.NewDecoder(bytes.NewReader(data)) - decoder.DisallowUnknownFields() - err = decoder.Decode(node) - if err != nil { - return path.ImmutablePath{}, err - } - - dagnode, err = deserializeNode(node, options.DataType) - if err != nil { - return path.ImmutablePath{}, err - } - - case "protobuf": - dagnode, err = dag.DecodeProtobuf(data) - - case "xml": - node := new(Node) - err = xml.Unmarshal(data, node) - if err != nil { - return path.ImmutablePath{}, err - } - - dagnode, err = deserializeNode(node, options.DataType) - if err != nil { - return path.ImmutablePath{}, err - } - - default: - return path.ImmutablePath{}, errors.New("unknown object encoding") - } - - if err != nil { - return path.ImmutablePath{}, err - } - - if options.Pin { - defer api.blockstore.PinLock(ctx).Unlock(ctx) - } - - err = api.dag.Add(ctx, dagnode) - if err != nil { - return path.ImmutablePath{}, err - } - - if options.Pin { - if err := api.pinning.PinWithMode(ctx, dagnode.Cid(), pin.Recursive, ""); err != nil { - return path.ImmutablePath{}, err - } - - err = api.pinning.Flush(ctx) - if err != nil { - return path.ImmutablePath{}, err - } - } - - return path.FromCid(dagnode.Cid()), nil -} - -func (api *ObjectAPI) Get(ctx context.Context, path path.Path) (ipld.Node, error) { - ctx, span := tracing.Span(ctx, "CoreAPI.ObjectAPI", "Get", trace.WithAttributes(attribute.String("path", path.String()))) - defer span.End() - return api.core().ResolveNode(ctx, path) -} - -func (api *ObjectAPI) Data(ctx context.Context, path path.Path) (io.Reader, error) { - ctx, span := tracing.Span(ctx, "CoreAPI.ObjectAPI", "Data", trace.WithAttributes(attribute.String("path", path.String()))) - defer span.End() - - nd, err := api.core().ResolveNode(ctx, path) - if err != nil { - return nil, err - } - - pbnd, ok := nd.(*dag.ProtoNode) - if !ok { - return nil, dag.ErrNotProtobuf - } - - return bytes.NewReader(pbnd.Data()), nil -} - -func (api *ObjectAPI) Links(ctx context.Context, path path.Path) ([]*ipld.Link, error) { - ctx, span := tracing.Span(ctx, "CoreAPI.ObjectAPI", "Links", trace.WithAttributes(attribute.String("path", path.String()))) - defer span.End() - - nd, err := api.core().ResolveNode(ctx, path) - if err != nil { - return nil, err - } - - links := nd.Links() - out := make([]*ipld.Link, len(links)) - for n, l := range links { - out[n] = (*ipld.Link)(l) - } - - return out, nil -} - -func (api *ObjectAPI) Stat(ctx context.Context, path path.Path) (*coreiface.ObjectStat, error) { - ctx, span := tracing.Span(ctx, "CoreAPI.ObjectAPI", "Stat", trace.WithAttributes(attribute.String("path", path.String()))) - defer span.End() - - nd, err := api.core().ResolveNode(ctx, path) - if err != nil { - return nil, err - } - - stat, err := nd.Stat() - if err != nil { - return nil, err - } - - out := &coreiface.ObjectStat{ - Cid: nd.Cid(), - NumLinks: stat.NumLinks, - BlockSize: stat.BlockSize, - LinksSize: stat.LinksSize, - DataSize: stat.DataSize, - CumulativeSize: stat.CumulativeSize, - } - - return out, nil -} - func (api *ObjectAPI) AddLink(ctx context.Context, base path.Path, name string, child path.Path, opts ...caopts.ObjectAddLinkOption) (path.ImmutablePath, error) { ctx, span := tracing.Span(ctx, "CoreAPI.ObjectAPI", "AddLink", trace.WithAttributes( attribute.String("base", base.String()), @@ -294,49 +108,6 @@ func (api *ObjectAPI) RmLink(ctx context.Context, base path.Path, link string) ( return path.FromCid(nnode.Cid()), nil } -func (api *ObjectAPI) AppendData(ctx context.Context, path path.Path, r io.Reader) (path.ImmutablePath, error) { - ctx, span := tracing.Span(ctx, "CoreAPI.ObjectAPI", "AppendData", trace.WithAttributes(attribute.String("path", path.String()))) - defer span.End() - - return api.patchData(ctx, path, r, true) -} - -func (api *ObjectAPI) SetData(ctx context.Context, path path.Path, r io.Reader) (path.ImmutablePath, error) { - ctx, span := tracing.Span(ctx, "CoreAPI.ObjectAPI", "SetData", trace.WithAttributes(attribute.String("path", path.String()))) - defer span.End() - - return api.patchData(ctx, path, r, false) -} - -func (api *ObjectAPI) patchData(ctx context.Context, p path.Path, r io.Reader, appendData bool) (path.ImmutablePath, error) { - nd, err := api.core().ResolveNode(ctx, p) - if err != nil { - return path.ImmutablePath{}, err - } - - pbnd, ok := nd.(*dag.ProtoNode) - if !ok { - return path.ImmutablePath{}, dag.ErrNotProtobuf - } - - data, err := io.ReadAll(r) - if err != nil { - return path.ImmutablePath{}, err - } - - if appendData { - data = append(pbnd.Data(), data...) - } - pbnd.SetData(data) - - err = api.dag.Add(ctx, pbnd) - if err != nil { - return path.ImmutablePath{}, err - } - - return path.FromCid(pbnd.Cid()), nil -} - func (api *ObjectAPI) Diff(ctx context.Context, before path.Path, after path.Path) ([]coreiface.ObjectChange, error) { ctx, span := tracing.Span(ctx, "CoreAPI.ObjectAPI", "Diff", trace.WithAttributes( attribute.String("before", before.String()), @@ -381,37 +152,3 @@ func (api *ObjectAPI) Diff(ctx context.Context, before path.Path, after path.Pat func (api *ObjectAPI) core() coreiface.CoreAPI { return (*CoreAPI)(api) } - -func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error) { - dagnode := new(dag.ProtoNode) - switch dataFieldEncoding { - case "text": - dagnode.SetData([]byte(nd.Data)) - case "base64": - data, err := base64.StdEncoding.DecodeString(nd.Data) - if err != nil { - return nil, err - } - dagnode.SetData(data) - default: - return nil, fmt.Errorf("unknown data field encoding") - } - - links := make([]*ipld.Link, len(nd.Links)) - for i, link := range nd.Links { - c, err := cid.Decode(link.Hash) - if err != nil { - return nil, err - } - links[i] = &ipld.Link{ - Name: link.Name, - Size: link.Size, - Cid: c, - } - } - if err := dagnode.SetLinks(links); err != nil { - return nil, err - } - - return dagnode, nil -} diff --git a/core/coreapi/unixfs.go b/core/coreapi/unixfs.go index 452e6017bc1..860574945d7 100644 --- a/core/coreapi/unixfs.go +++ b/core/coreapi/unixfs.go @@ -3,14 +3,6 @@ package coreapi import ( "context" "fmt" - "sync" - - "github.com/ipfs/kubo/core" - "github.com/ipfs/kubo/tracing" - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/trace" - - "github.com/ipfs/kubo/core/coreunix" blockservice "github.com/ipfs/boxo/blockservice" bstore "github.com/ipfs/boxo/blockstore" @@ -21,41 +13,23 @@ import ( ft "github.com/ipfs/boxo/ipld/unixfs" unixfile "github.com/ipfs/boxo/ipld/unixfs/file" uio "github.com/ipfs/boxo/ipld/unixfs/io" - mfs "github.com/ipfs/boxo/mfs" + "github.com/ipfs/boxo/mfs" "github.com/ipfs/boxo/path" cid "github.com/ipfs/go-cid" cidutil "github.com/ipfs/go-cidutil" + ds "github.com/ipfs/go-datastore" + dssync "github.com/ipfs/go-datastore/sync" ipld "github.com/ipfs/go-ipld-format" coreiface "github.com/ipfs/kubo/core/coreiface" options "github.com/ipfs/kubo/core/coreiface/options" + "github.com/ipfs/kubo/core/coreunix" + "github.com/ipfs/kubo/tracing" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" ) type UnixfsAPI CoreAPI -var ( - nilNode *core.IpfsNode - once sync.Once -) - -func getOrCreateNilNode() (*core.IpfsNode, error) { - once.Do(func() { - if nilNode != nil { - return - } - node, err := core.NewNode(context.Background(), &core.BuildCfg{ - // TODO: need this to be true or all files - // hashed will be stored in memory! - NilRepo: true, - }) - if err != nil { - panic(err) - } - nilNode = node - }) - - return nilNode, nil -} - // Add builds a merkledag node from a reader, adds it to the blockstore, // and returns the key representing that node. func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options.UnixfsAddOption) (path.ImmutablePath, error) { @@ -108,13 +82,12 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options pinning := api.pinning if settings.OnlyHash { - node, err := getOrCreateNilNode() - if err != nil { - return path.ImmutablePath{}, err - } - addblockstore = node.Blockstore - exch = node.Exchange - pinning = node.Pinning + // setup a /dev/null pipeline to simulate adding the data + dstore := dssync.MutexWrap(ds.NewNullDatastore()) + bs := bstore.NewBlockstore(dstore, bstore.WriteThrough()) + addblockstore = bstore.NewGCBlockstore(bs, nil) // gclocker will never be used + exch = nil // exchange will never be used + pinning = nil // pinner will never be used } bserv := blockservice.New(addblockstore, exch) // hash security 001 @@ -133,11 +106,11 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options syncDserv = &syncDagService{ DAGService: dserv, syncFn: func() error { - ds := api.repo.Datastore() - if err := ds.Sync(ctx, bstore.BlockPrefix); err != nil { + rds := api.repo.Datastore() + if err := rds.Sync(ctx, bstore.BlockPrefix); err != nil { return err } - return ds.Sync(ctx, filestore.FilestorePrefix) + return rds.Sync(ctx, filestore.FilestorePrefix) }, } } diff --git a/core/corehttp/commands.go b/core/corehttp/commands.go index 4feef3359a2..8e1f84422a5 100644 --- a/core/corehttp/commands.go +++ b/core/corehttp/commands.go @@ -9,7 +9,6 @@ import ( "strconv" "strings" - "github.com/ipfs/boxo/gateway" cmds "github.com/ipfs/go-ipfs-cmds" cmdsHttp "github.com/ipfs/go-ipfs-cmds/http" version "github.com/ipfs/kubo" @@ -122,14 +121,10 @@ func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) { c.SetAllowedOrigins(newOrigins...) } -func commandsOption(cctx oldcmds.Context, command *cmds.Command, allowGet bool) ServeOption { +func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { cfg := cmdsHttp.NewServerConfig() - cfg.AllowGet = allowGet corsAllowedMethods := []string{http.MethodPost} - if allowGet { - corsAllowedMethods = append(corsAllowedMethods, http.MethodGet) - } cfg.SetAllowedMethods(corsAllowedMethods...) cfg.APIPath = APIPath @@ -150,13 +145,6 @@ func commandsOption(cctx oldcmds.Context, command *cmds.Command, allowGet bool) cmdHandler = withAuthSecrets(authorizations, cmdHandler) } - // TODO[api-on-gw]: remove for Kubo 0.28 - if command == corecommands.RootRO && allowGet { - cmdHandler = gateway.NewHeaders(map[string][]string{ - "Link": {`; rel="deprecation"; type="text/html"`}, - }).Wrap(cmdHandler) - } - cmdHandler = otelhttp.NewHandler(cmdHandler, "corehttp.cmdsHandler") mux.Handle(APIPath+"/", cmdHandler) return mux, nil @@ -211,13 +199,7 @@ func withAuthSecrets(authorizations map[string]rpcAuthScopeWithUser, next http.H // CommandsOption constructs a ServerOption for hooking the commands into the // HTTP server. It will NOT allow GET requests. func CommandsOption(cctx oldcmds.Context) ServeOption { - return commandsOption(cctx, corecommands.Root, false) -} - -// CommandsROOption constructs a ServerOption for hooking the read-only commands -// into the HTTP server. It will allow GET requests. -func CommandsROOption(cctx oldcmds.Context) ServeOption { - return commandsOption(cctx, corecommands.RootRO, true) + return commandsOption(cctx, corecommands.Root) } // CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/kubo/` or `/go-ipfs/` diff --git a/core/corehttp/gateway.go b/core/corehttp/gateway.go index 67e3c242d7b..6ac3818856d 100644 --- a/core/corehttp/gateway.go +++ b/core/corehttp/gateway.go @@ -235,7 +235,7 @@ func (o *offlineGatewayErrWrapper) GetDNSLinkRecord(ctx context.Context, s strin var _ gateway.IPFSBackend = (*offlineGatewayErrWrapper)(nil) -var defaultPaths = []string{"/ipfs/", "/ipns/", "/api/", "/p2p/"} +var defaultPaths = []string{"/ipfs/", "/ipns/", "/p2p/"} var subdomainGatewaySpec = &gateway.PublicGateway{ Paths: defaultPaths, diff --git a/core/corehttp/webui.go b/core/corehttp/webui.go index 5ec6edf1580..2e31b22144f 100644 --- a/core/corehttp/webui.go +++ b/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp -// TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeidf7cpkwsjkq6xs3r6fbbxghbugilx3jtezbza7gua3k5wjixpmba" // v4.2.0 +// WebUI version confirmed to work with this Kubo version +const WebUIPath = "/ipfs/bafybeigggyffcf6yfhx5irtwzx3cgnk6n3dwylkvcpckzhqqrigsxowjwe" // v4.2.1 // WebUIPaths is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeidf7cpkwsjkq6xs3r6fbbxghbugilx3jtezbza7gua3k5wjixpmba", "/ipfs/bafybeiamycmd52xvg6k3nzr6z3n33de6a2teyhquhj4kspdtnvetnkrfim", "/ipfs/bafybeieqdeoqkf7xf4aozd524qncgiloh33qgr25lyzrkusbcre4c3fxay", "/ipfs/bafybeicyp7ssbnj3hdzehcibmapmpuc3atrsc4ch3q6acldfh4ojjdbcxe", diff --git a/core/coreiface/coreapi.go b/core/coreiface/coreapi.go index bcd94f3816c..dbb08dd7e9c 100644 --- a/core/coreiface/coreapi.go +++ b/core/coreiface/coreapi.go @@ -34,10 +34,6 @@ type CoreAPI interface { // Object returns an implementation of Object API Object() ObjectAPI - // nolint deprecated - // Deprecated: use [Routing] instead. - Dht() DhtAPI - // Swarm returns an implementation of Swarm API Swarm() SwarmAPI diff --git a/core/coreiface/dht.go b/core/coreiface/dht.go deleted file mode 100644 index 001f5856a1b..00000000000 --- a/core/coreiface/dht.go +++ /dev/null @@ -1,25 +0,0 @@ -package iface - -import ( - "context" - - "github.com/ipfs/boxo/path" - "github.com/ipfs/kubo/core/coreiface/options" - "github.com/libp2p/go-libp2p/core/peer" -) - -// nolint deprecated -// Deprecated: use [RoutingAPI] instead. -type DhtAPI interface { - // nolint deprecated - // Deprecated: use [RoutingAPI.FindPeer] instead. - FindPeer(context.Context, peer.ID) (peer.AddrInfo, error) - - // nolint deprecated - // Deprecated: use [RoutingAPI.FindProviders] instead. - FindProviders(context.Context, path.Path, ...options.DhtFindProvidersOption) (<-chan peer.AddrInfo, error) - - // nolint deprecated - // Deprecated: use [RoutingAPI.Provide] instead. - Provide(context.Context, path.Path, ...options.DhtProvideOption) error -} diff --git a/core/coreiface/object.go b/core/coreiface/object.go index fa378ac6c46..27bb8893583 100644 --- a/core/coreiface/object.go +++ b/core/coreiface/object.go @@ -2,36 +2,11 @@ package iface import ( "context" - "io" "github.com/ipfs/boxo/path" "github.com/ipfs/kubo/core/coreiface/options" - - "github.com/ipfs/go-cid" - ipld "github.com/ipfs/go-ipld-format" ) -// ObjectStat provides information about dag nodes -type ObjectStat struct { - // Cid is the CID of the node - Cid cid.Cid - - // NumLinks is number of links the node contains - NumLinks int - - // BlockSize is size of the raw serialized node - BlockSize int - - // LinksSize is size of the links block section - LinksSize int - - // DataSize is the size of data block section - DataSize int - - // CumulativeSize is size of the tree (BlockSize + link sizes) - CumulativeSize int -} - // ChangeType denotes type of change in ObjectChange type ChangeType int @@ -69,24 +44,6 @@ type ObjectChange struct { // ObjectAPI specifies the interface to MerkleDAG and contains useful utilities // for manipulating MerkleDAG data structures. type ObjectAPI interface { - // New creates new, empty (by default) dag-node. - New(context.Context, ...options.ObjectNewOption) (ipld.Node, error) - - // Put imports the data into merkledag - Put(context.Context, io.Reader, ...options.ObjectPutOption) (path.ImmutablePath, error) - - // Get returns the node for the path - Get(context.Context, path.Path) (ipld.Node, error) - - // Data returns reader for data of the node - Data(context.Context, path.Path) (io.Reader, error) - - // Links returns lint or links the node contains - Links(context.Context, path.Path) ([]*ipld.Link, error) - - // Stat returns information about the node - Stat(context.Context, path.Path) (*ObjectStat, error) - // AddLink adds a link under the specified path. child path can point to a // subdirectory within the patent which must be present (can be overridden // with WithCreate option). @@ -95,12 +52,6 @@ type ObjectAPI interface { // RmLink removes a link from the node RmLink(ctx context.Context, base path.Path, link string) (path.ImmutablePath, error) - // AppendData appends data to the node - AppendData(context.Context, path.Path, io.Reader) (path.ImmutablePath, error) - - // SetData sets the data contained in the node - SetData(context.Context, path.Path, io.Reader) (path.ImmutablePath, error) - // Diff returns a set of changes needed to transform the first object into the // second. Diff(context.Context, path.Path, path.Path) ([]ObjectChange, error) diff --git a/core/coreiface/options/object.go b/core/coreiface/options/object.go index b5625a1d61c..ab780ebd988 100644 --- a/core/coreiface/options/object.go +++ b/core/coreiface/options/object.go @@ -1,55 +1,13 @@ package options -type ObjectNewSettings struct { - Type string -} - -type ObjectPutSettings struct { - InputEnc string - DataType string - Pin bool -} - type ObjectAddLinkSettings struct { Create bool } type ( - ObjectNewOption func(*ObjectNewSettings) error - ObjectPutOption func(*ObjectPutSettings) error ObjectAddLinkOption func(*ObjectAddLinkSettings) error ) -func ObjectNewOptions(opts ...ObjectNewOption) (*ObjectNewSettings, error) { - options := &ObjectNewSettings{ - Type: "empty", - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - -func ObjectPutOptions(opts ...ObjectPutOption) (*ObjectPutSettings, error) { - options := &ObjectPutSettings{ - InputEnc: "json", - DataType: "text", - Pin: false, - } - - for _, opt := range opts { - err := opt(options) - if err != nil { - return nil, err - } - } - return options, nil -} - func ObjectAddLinkOptions(opts ...ObjectAddLinkOption) (*ObjectAddLinkSettings, error) { options := &ObjectAddLinkSettings{ Create: false, @@ -68,54 +26,6 @@ type objectOpts struct{} var Object objectOpts -// Type is an option for Object.New which allows to change the type of created -// dag node. -// -// Supported types: -// * 'empty' - Empty node -// * 'unixfs-dir' - Empty UnixFS directory -func (objectOpts) Type(t string) ObjectNewOption { - return func(settings *ObjectNewSettings) error { - settings.Type = t - return nil - } -} - -// InputEnc is an option for Object.Put which specifies the input encoding of the -// data. Default is "json". -// -// Supported encodings: -// * "protobuf" -// * "json" -func (objectOpts) InputEnc(e string) ObjectPutOption { - return func(settings *ObjectPutSettings) error { - settings.InputEnc = e - return nil - } -} - -// DataType is an option for Object.Put which specifies the encoding of data -// field when using Json or XML input encoding. -// -// Supported types: -// * "text" (default) -// * "base64" -func (objectOpts) DataType(t string) ObjectPutOption { - return func(settings *ObjectPutSettings) error { - settings.DataType = t - return nil - } -} - -// Pin is an option for Object.Put which specifies whether to pin the added -// objects, default is false -func (objectOpts) Pin(pin bool) ObjectPutOption { - return func(settings *ObjectPutSettings) error { - settings.Pin = pin - return nil - } -} - // Create is an option for Object.AddLink which specifies whether create required // directories for the child func (objectOpts) Create(create bool) ObjectAddLinkOption { diff --git a/core/coreiface/tests/object.go b/core/coreiface/tests/object.go index 9e0463ab690..239b022e14f 100644 --- a/core/coreiface/tests/object.go +++ b/core/coreiface/tests/object.go @@ -1,15 +1,15 @@ package tests import ( - "bytes" "context" - "encoding/hex" - "io" - "strings" "testing" + dag "github.com/ipfs/boxo/ipld/merkledag" + "github.com/ipfs/boxo/path" + ipld "github.com/ipfs/go-ipld-format" iface "github.com/ipfs/kubo/core/coreiface" opt "github.com/ipfs/kubo/core/coreiface/options" + "github.com/stretchr/testify/require" ) func (tp *TestSuite) TestObject(t *testing.T) { @@ -20,448 +20,125 @@ func (tp *TestSuite) TestObject(t *testing.T) { return nil }) - t.Run("TestNew", tp.TestNew) - t.Run("TestObjectPut", tp.TestObjectPut) - t.Run("TestObjectGet", tp.TestObjectGet) - t.Run("TestObjectData", tp.TestObjectData) - t.Run("TestObjectLinks", tp.TestObjectLinks) - t.Run("TestObjectStat", tp.TestObjectStat) t.Run("TestObjectAddLink", tp.TestObjectAddLink) t.Run("TestObjectAddLinkCreate", tp.TestObjectAddLinkCreate) t.Run("TestObjectRmLink", tp.TestObjectRmLink) - t.Run("TestObjectAddData", tp.TestObjectAddData) - t.Run("TestObjectSetData", tp.TestObjectSetData) t.Run("TestDiffTest", tp.TestDiffTest) } -func (tp *TestSuite) TestNew(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(t, ctx) - if err != nil { - t.Fatal(err) - } - - emptyNode, err := api.Object().New(ctx) - if err != nil { - t.Fatal(err) - } - - dirNode, err := api.Object().New(ctx, opt.Object.Type("unixfs-dir")) - if err != nil { - t.Fatal(err) - } - - if emptyNode.String() != "QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n" { - t.Errorf("Unexpected emptyNode path: %s", emptyNode.String()) - } - - if dirNode.String() != "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" { - t.Errorf("Unexpected dirNode path: %s", dirNode.String()) - } -} - -func (tp *TestSuite) TestObjectPut(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(t, ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"YmFy"}`), opt.Object.DataType("base64")) // bar - if err != nil { - t.Fatal(err) - } - - pbBytes, err := hex.DecodeString("0a0362617a") - if err != nil { - t.Fatal(err) - } - - p3, err := api.Object().Put(ctx, bytes.NewReader(pbBytes), opt.Object.InputEnc("protobuf")) - if err != nil { - t.Fatal(err) - } - - if p1.String() != "/ipfs/QmQeGyS87nyijii7kFt1zbe4n2PsXTFimzsdxyE9qh9TST" { - t.Errorf("unexpected path: %s", p1.String()) - } - - if p2.String() != "/ipfs/QmNeYRbCibmaMMK6Du6ChfServcLqFvLJF76PzzF76SPrZ" { - t.Errorf("unexpected path: %s", p2.String()) - } - - if p3.String() != "/ipfs/QmZreR7M2t7bFXAdb1V5FtQhjk4t36GnrvueLJowJbQM9m" { - t.Errorf("unexpected path: %s", p3.String()) - } -} - -func (tp *TestSuite) TestObjectGet(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(t, ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - nd, err := api.Object().Get(ctx, p1) - if err != nil { - t.Fatal(err) - } - - if string(nd.RawData()[len(nd.RawData())-3:]) != "foo" { - t.Fatal("got non-matching data") - } -} - -func (tp *TestSuite) TestObjectData(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(t, ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - r, err := api.Object().Data(ctx, p1) - if err != nil { - t.Fatal(err) - } - - data, err := io.ReadAll(r) - if err != nil { - t.Fatal(err) - } - - if string(data) != "foo" { - t.Fatal("got non-matching data") - } -} - -func (tp *TestSuite) TestObjectLinks(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(t, ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Links":[{"Name":"bar", "Hash":"`+p1.RootCid().String()+`"}]}`)) - if err != nil { - t.Fatal(err) - } - - links, err := api.Object().Links(ctx, p2) - if err != nil { - t.Fatal(err) - } - - if len(links) != 1 { - t.Errorf("unexpected number of links: %d", len(links)) - } - - if links[0].Cid.String() != p1.RootCid().String() { - t.Fatal("cids didn't batch") - } - - if links[0].Name != "bar" { - t.Fatal("unexpected link name") - } -} - -func (tp *TestSuite) TestObjectStat(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(t, ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"bazz", "Links":[{"Name":"bar", "Hash":"`+p1.RootCid().String()+`", "Size":3}]}`)) - if err != nil { - t.Fatal(err) - } - - stat, err := api.Object().Stat(ctx, p2) - if err != nil { - t.Fatal(err) - } +func putDagPbNode(t *testing.T, ctx context.Context, api iface.CoreAPI, data string, links []*ipld.Link) path.ImmutablePath { + dagnode := new(dag.ProtoNode) - if stat.Cid.String() != p2.RootCid().String() { - t.Error("unexpected stat.Cid") + if data != "" { + dagnode.SetData([]byte(data)) } - if stat.NumLinks != 1 { - t.Errorf("unexpected stat.NumLinks") + if links != nil { + err := dagnode.SetLinks(links) + require.NoError(t, err) } - if stat.BlockSize != 51 { - t.Error("unexpected stat.BlockSize") - } - - if stat.LinksSize != 47 { - t.Errorf("unexpected stat.LinksSize: %d", stat.LinksSize) - } + err := api.Dag().Add(ctx, dagnode) + require.NoError(t, err) - if stat.DataSize != 4 { - t.Error("unexpected stat.DataSize") - } - - if stat.CumulativeSize != 54 { - t.Error("unexpected stat.DataSize") - } + return path.FromCid(dagnode.Cid()) } func (tp *TestSuite) TestObjectAddLink(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() api, err := tp.makeAPI(t, ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"bazz", "Links":[{"Name":"bar", "Hash":"`+p1.RootCid().String()+`", "Size":3}]}`)) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) + + p1 := putDagPbNode(t, ctx, api, "foo", nil) + p2 := putDagPbNode(t, ctx, api, "bazz", []*ipld.Link{ + { + Name: "bar", + Cid: p1.RootCid(), + Size: 3, + }, + }) p3, err := api.Object().AddLink(ctx, p2, "abc", p2) - if err != nil { - t.Fatal(err) - } - - links, err := api.Object().Links(ctx, p3) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) - if len(links) != 2 { - t.Errorf("unexpected number of links: %d", len(links)) - } + nd, err := api.Dag().Get(ctx, p3.RootCid()) + require.NoError(t, err) - if links[0].Name != "abc" { - t.Errorf("unexpected link 0 name: %s", links[0].Name) - } - - if links[1].Name != "bar" { - t.Errorf("unexpected link 1 name: %s", links[1].Name) - } + links := nd.Links() + require.Len(t, links, 2) + require.Equal(t, "abc", links[0].Name) + require.Equal(t, "bar", links[1].Name) } func (tp *TestSuite) TestObjectAddLinkCreate(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() api, err := tp.makeAPI(t, ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"bazz", "Links":[{"Name":"bar", "Hash":"`+p1.RootCid().String()+`", "Size":3}]}`)) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) + + p1 := putDagPbNode(t, ctx, api, "foo", nil) + p2 := putDagPbNode(t, ctx, api, "bazz", []*ipld.Link{ + { + Name: "bar", + Cid: p1.RootCid(), + Size: 3, + }, + }) _, err = api.Object().AddLink(ctx, p2, "abc/d", p2) - if err == nil { - t.Fatal("expected an error") - } - if !strings.Contains(err.Error(), "no link by that name") { - t.Fatalf("unexpected error: %s", err.Error()) - } + require.ErrorContains(t, err, "no link by that name") p3, err := api.Object().AddLink(ctx, p2, "abc/d", p2, opt.Object.Create(true)) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) - links, err := api.Object().Links(ctx, p3) - if err != nil { - t.Fatal(err) - } - - if len(links) != 2 { - t.Errorf("unexpected number of links: %d", len(links)) - } - - if links[0].Name != "abc" { - t.Errorf("unexpected link 0 name: %s", links[0].Name) - } + nd, err := api.Dag().Get(ctx, p3.RootCid()) + require.NoError(t, err) - if links[1].Name != "bar" { - t.Errorf("unexpected link 1 name: %s", links[1].Name) - } + links := nd.Links() + require.Len(t, links, 2) + require.Equal(t, "abc", links[0].Name) + require.Equal(t, "bar", links[1].Name) } func (tp *TestSuite) TestObjectRmLink(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() api, err := tp.makeAPI(t, ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"bazz", "Links":[{"Name":"bar", "Hash":"`+p1.RootCid().String()+`", "Size":3}]}`)) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) + + p1 := putDagPbNode(t, ctx, api, "foo", nil) + p2 := putDagPbNode(t, ctx, api, "bazz", []*ipld.Link{ + { + Name: "bar", + Cid: p1.RootCid(), + Size: 3, + }, + }) p3, err := api.Object().RmLink(ctx, p2, "bar") - if err != nil { - t.Fatal(err) - } - - links, err := api.Object().Links(ctx, p3) - if err != nil { - t.Fatal(err) - } - - if len(links) != 0 { - t.Errorf("unexpected number of links: %d", len(links)) - } -} - -func (tp *TestSuite) TestObjectAddData(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(t, ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } - - p2, err := api.Object().AppendData(ctx, p1, strings.NewReader("bar")) - if err != nil { - t.Fatal(err) - } - - r, err := api.Object().Data(ctx, p2) - if err != nil { - t.Fatal(err) - } - - data, err := io.ReadAll(r) - if err != nil { - t.Fatal(err) - } - - if string(data) != "foobar" { - t.Error("unexpected data") - } -} - -func (tp *TestSuite) TestObjectSetData(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - api, err := tp.makeAPI(t, ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) - p2, err := api.Object().SetData(ctx, p1, strings.NewReader("bar")) - if err != nil { - t.Fatal(err) - } - - r, err := api.Object().Data(ctx, p2) - if err != nil { - t.Fatal(err) - } + nd, err := api.Dag().Get(ctx, p3.RootCid()) + require.NoError(t, err) - data, err := io.ReadAll(r) - if err != nil { - t.Fatal(err) - } - - if string(data) != "bar" { - t.Error("unexpected data") - } + links := nd.Links() + require.Len(t, links, 0) } func (tp *TestSuite) TestDiffTest(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() api, err := tp.makeAPI(t, ctx) - if err != nil { - t.Fatal(err) - } - - p1, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"foo"}`)) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) - p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"bar"}`)) - if err != nil { - t.Fatal(err) - } + p1 := putDagPbNode(t, ctx, api, "foo", nil) + p2 := putDagPbNode(t, ctx, api, "bar", nil) changes, err := api.Object().Diff(ctx, p1, p2) - if err != nil { - t.Fatal(err) - } - - if len(changes) != 1 { - t.Fatal("unexpected changes len") - } - - if changes[0].Type != iface.DiffMod { - t.Fatal("unexpected change type") - } - - if changes[0].Before.String() != p1.String() { - t.Fatal("unexpected before path") - } - - if changes[0].After.String() != p2.String() { - t.Fatal("unexpected before path") - } + require.NoError(t, err) + require.Len(t, changes, 1) + require.Equal(t, iface.DiffMod, changes[0].Type) + require.Equal(t, p1.String(), changes[0].Before.String()) + require.Equal(t, p2.String(), changes[0].After.String()) } diff --git a/core/coreiface/tests/unixfs.go b/core/coreiface/tests/unixfs.go index 538f4d8ed7c..9d3362b9aff 100644 --- a/core/coreiface/tests/unixfs.go +++ b/core/coreiface/tests/unixfs.go @@ -571,7 +571,7 @@ func (tp *TestSuite) TestAddHashOnly(t *testing.T) { } if p.String() != hello { - t.Errorf("unxepected path: %s", p.String()) + t.Errorf("unexpected path: %s", p.String()) } _, err = api.Block().Get(ctx, p) @@ -579,7 +579,7 @@ func (tp *TestSuite) TestAddHashOnly(t *testing.T) { t.Fatal("expected an error") } if !ipld.IsNotFound(err) { - t.Errorf("unxepected error: %s", err.Error()) + t.Errorf("unexpected error: %s", err.Error()) } } @@ -630,16 +630,11 @@ func (tp *TestSuite) TestGetDir(t *testing.T) { } p := path.FromCid(edir.Cid()) - emptyDir, err := api.Object().New(ctx, options.Object.Type("unixfs-dir")) - if err != nil { - t.Fatal(err) - } - - if p.String() != path.FromCid(emptyDir.Cid()).String() { - t.Fatalf("expected path %s, got: %s", emptyDir.Cid(), p.String()) + if p.String() != path.FromCid(edir.Cid()).String() { + t.Fatalf("expected path %s, got: %s", edir.Cid(), p.String()) } - r, err := api.Unixfs().Get(ctx, path.FromCid(emptyDir.Cid())) + r, err := api.Unixfs().Get(ctx, path.FromCid(edir.Cid())) if err != nil { t.Fatal(err) } @@ -779,17 +774,12 @@ func (tp *TestSuite) TestLsEmptyDir(t *testing.T) { t.Fatal(err) } - _, err = api.Unixfs().Add(ctx, files.NewSliceDirectory([]files.DirEntry{})) - if err != nil { - t.Fatal(err) - } - - emptyDir, err := api.Object().New(ctx, options.Object.Type("unixfs-dir")) + p, err := api.Unixfs().Add(ctx, files.NewSliceDirectory([]files.DirEntry{})) if err != nil { t.Fatal(err) } - links, err := api.Unixfs().Ls(ctx, path.FromCid(emptyDir.Cid())) + links, err := api.Unixfs().Ls(ctx, p) if err != nil { t.Fatal(err) } diff --git a/core/node/builder.go b/core/node/builder.go index 57fa209457a..411e3228c78 100644 --- a/core/node/builder.go +++ b/core/node/builder.go @@ -4,7 +4,6 @@ import ( "context" "crypto/rand" "encoding/base64" - "errors" "go.uber.org/fx" @@ -34,9 +33,6 @@ type BuildCfg struct { // DO NOT SET THIS UNLESS YOU'RE TESTING. DisableEncryptedConnections bool - // If NilRepo is set, a Repo backed by a nil datastore will be constructed - NilRepo bool - Routing libp2p.RoutingOption Host libp2p.HostOption Repo repo.Repo @@ -51,18 +47,8 @@ func (cfg *BuildCfg) getOpt(key string) bool { } func (cfg *BuildCfg) fillDefaults() error { - if cfg.Repo != nil && cfg.NilRepo { - return errors.New("cannot set a Repo and specify nilrepo at the same time") - } - if cfg.Repo == nil { - var d ds.Datastore - if cfg.NilRepo { - d = ds.NewNullDatastore() - } else { - d = ds.NewMapDatastore() - } - r, err := defaultRepo(dsync.MutexWrap(d)) + r, err := defaultRepo(dsync.MutexWrap(ds.NewMapDatastore())) if err != nil { return err } diff --git a/core/node/groups.go b/core/node/groups.go index 061087c276b..3df945fd2cc 100644 --- a/core/node/groups.go +++ b/core/node/groups.go @@ -178,7 +178,7 @@ func Storage(bcfg *BuildCfg, cfg *config.Config) fx.Option { return fx.Options( fx.Provide(RepoConfig), fx.Provide(Datastore), - fx.Provide(BaseBlockstoreCtor(cacheOpts, bcfg.NilRepo, cfg.Datastore.HashOnRead)), + fx.Provide(BaseBlockstoreCtor(cacheOpts, cfg.Datastore.HashOnRead)), finalBstore, ) } @@ -286,7 +286,7 @@ func Online(bcfg *BuildCfg, cfg *config.Config, userResourceOverrides rcmgr.Part cfg.Experimental.StrategicProviding, cfg.Reprovider.Strategy.WithDefault(config.DefaultReproviderStrategy), cfg.Reprovider.Interval.WithDefault(config.DefaultReproviderInterval), - cfg.Routing.AcceleratedDHTClient, + cfg.Routing.AcceleratedDHTClient.WithDefault(config.DefaultAcceleratedDHTClient), ), ) } diff --git a/core/node/libp2p/host.go b/core/node/libp2p/host.go index afbd2080c07..7950f3dc6bc 100644 --- a/core/node/libp2p/host.go +++ b/core/node/libp2p/host.go @@ -11,6 +11,7 @@ import ( "github.com/libp2p/go-libp2p/core/routing" routedhost "github.com/libp2p/go-libp2p/p2p/host/routed" + "github.com/ipfs/kubo/config" "github.com/ipfs/kubo/core/node/helpers" "github.com/ipfs/kubo/repo" @@ -60,6 +61,7 @@ func Host(mctx helpers.MetricsCtx, lc fx.Lifecycle, params P2PHostIn) (out P2PHo BootstrapPeers: bootstrappers, OptimisticProvide: cfg.Experimental.OptimisticProvide, OptimisticProvideJobsPoolSize: cfg.Experimental.OptimisticProvideJobsPoolSize, + LoopbackAddressesOnLanDHT: cfg.Routing.LoopbackAddressesOnLanDHT.WithDefault(config.DefaultLoopbackAddressesOnLanDHT), } opts = append(opts, libp2p.Routing(func(h host.Host) (routing.PeerRouting, error) { args := routingOptArgs diff --git a/core/node/libp2p/routing.go b/core/node/libp2p/routing.go index 98234f5ceda..697bf0f2e6a 100644 --- a/core/node/libp2p/routing.go +++ b/core/node/libp2p/routing.go @@ -90,7 +90,7 @@ func BaseRouting(cfg *config.Config) interface{} { } } - if dualDHT != nil && cfg.Routing.AcceleratedDHTClient { + if dualDHT != nil && cfg.Routing.AcceleratedDHTClient.WithDefault(config.DefaultAcceleratedDHTClient) { cfg, err := in.Repo.Config() if err != nil { return out, err diff --git a/core/node/libp2p/routingopt.go b/core/node/libp2p/routingopt.go index a58a8c49885..869b7ef0652 100644 --- a/core/node/libp2p/routingopt.go +++ b/core/node/libp2p/routingopt.go @@ -26,6 +26,7 @@ type RoutingOptionArgs struct { BootstrapPeers []peer.AddrInfo OptimisticProvide bool OptimisticProvideJobsPoolSize int + LoopbackAddressesOnLanDHT bool } type RoutingOption func(args RoutingOptionArgs) (routing.Routing, error) @@ -116,10 +117,18 @@ func constructDHTRouting(mode dht.ModeOpt) RoutingOption { if args.OptimisticProvideJobsPoolSize != 0 { dhtOpts = append(dhtOpts, dht.OptimisticProvideJobsPoolSize(args.OptimisticProvideJobsPoolSize)) } + wanOptions := []dht.Option{ + dht.BootstrapPeers(args.BootstrapPeers...), + } + lanOptions := []dht.Option{} + if args.LoopbackAddressesOnLanDHT { + lanOptions = append(lanOptions, dht.AddressFilter(nil)) + } return dual.New( args.Ctx, args.Host, dual.DHTOption(dhtOpts...), - dual.WanDHTOption(dht.BootstrapPeers(args.BootstrapPeers...)), + dual.WanDHTOption(wanOptions...), + dual.LanDHTOption(lanOptions...), ) } } diff --git a/core/node/provider.go b/core/node/provider.go index c1c99e6003f..b274584ef3c 100644 --- a/core/node/provider.go +++ b/core/node/provider.go @@ -129,11 +129,13 @@ func OnlineProviders(useStrategicProviding bool, reprovideStrategy string, repro var keyProvider fx.Option switch reprovideStrategy { case "all", "": - keyProvider = fx.Provide(provider.NewBlockstoreProvider) + keyProvider = fx.Provide(newProvidingStrategy(false, false)) case "roots": - keyProvider = fx.Provide(pinnedProviderStrategy(true)) + keyProvider = fx.Provide(newProvidingStrategy(true, true)) case "pinned": - keyProvider = fx.Provide(pinnedProviderStrategy(false)) + keyProvider = fx.Provide(newProvidingStrategy(true, false)) + case "flat": + keyProvider = fx.Provide(provider.NewBlockstoreProvider) default: return fx.Error(fmt.Errorf("unknown reprovider strategy %q", reprovideStrategy)) } @@ -149,13 +151,25 @@ func OfflineProviders() fx.Option { return fx.Provide(provider.NewNoopProvider) } -func pinnedProviderStrategy(onlyRoots bool) interface{} { +func newProvidingStrategy(onlyPinned, onlyRoots bool) interface{} { type input struct { fx.In Pinner pin.Pinner + Blockstore blockstore.Blockstore IPLDFetcher fetcher.Factory `name:"ipldFetcher"` } return func(in input) provider.KeyChanFunc { - return provider.NewPinnedProvider(onlyRoots, in.Pinner, in.IPLDFetcher) + if onlyRoots { + return provider.NewPinnedProvider(true, in.Pinner, in.IPLDFetcher) + } + + if onlyPinned { + return provider.NewPinnedProvider(false, in.Pinner, in.IPLDFetcher) + } + + return provider.NewPrioritizedProvider( + provider.NewPinnedProvider(true, in.Pinner, in.IPLDFetcher), + provider.NewBlockstoreProvider(in.Blockstore), + ) } } diff --git a/core/node/storage.go b/core/node/storage.go index 782ff58f043..a303ddc23a3 100644 --- a/core/node/storage.go +++ b/core/node/storage.go @@ -27,17 +27,14 @@ func Datastore(repo repo.Repo) datastore.Datastore { type BaseBlocks blockstore.Blockstore // BaseBlockstoreCtor creates cached blockstore backed by the provided datastore -func BaseBlockstoreCtor(cacheOpts blockstore.CacheOpts, nilRepo bool, hashOnRead bool) func(mctx helpers.MetricsCtx, repo repo.Repo, lc fx.Lifecycle) (bs BaseBlocks, err error) { +func BaseBlockstoreCtor(cacheOpts blockstore.CacheOpts, hashOnRead bool) func(mctx helpers.MetricsCtx, repo repo.Repo, lc fx.Lifecycle) (bs BaseBlocks, err error) { return func(mctx helpers.MetricsCtx, repo repo.Repo, lc fx.Lifecycle) (bs BaseBlocks, err error) { // hash security bs = blockstore.NewBlockstore(repo.Datastore()) bs = &verifbs.VerifBS{Blockstore: bs} - - if !nilRepo { - bs, err = blockstore.CachedBlockstore(helpers.LifecycleCtx(mctx, lc), bs, cacheOpts) - if err != nil { - return nil, err - } + bs, err = blockstore.CachedBlockstore(helpers.LifecycleCtx(mctx, lc), bs, cacheOpts) + if err != nil { + return nil, err } bs = blockstore.NewIdStore(bs) diff --git a/docs/RELEASE_CHECKLIST.md b/docs/RELEASE_CHECKLIST.md index d9fbd9348cf..767709db542 100644 --- a/docs/RELEASE_CHECKLIST.md +++ b/docs/RELEASE_CHECKLIST.md @@ -90,7 +90,7 @@ This section covers tasks to be done during each release. - [ ] create and merge the PR which updates `dists/kubo/versions` and `dists/go-ipfs/versions` (![](https://img.shields.io/badge/only-FINAL-green?style=flat-square) and `dists/kubo/current_version` and `dists/go-ipfs/current_version`) - [example](https://github.com/ipfs/distributions/pull/760) - [ ] wait for the [CI](https://github.com/ipfs/distributions/actions/workflows/main.yml) workflow run initiated by the merge to master to finish - - [ ] verify the release is available on [dist.ipfs.io](https://dist.ipfs.io/#kubo) + - [ ] verify the release is available on [dist.ipfs.tech](https://dist.ipfs.tech/#kubo) - [ ] Publish the release to [NPM](https://www.npmjs.com/package/go-ipfs?activeTab=versions)
using `./kuboreleaser release --version vX.Y.Z(-rcN) publish-to-npm` (⚠️ you might need to run the command a couple of times because GHA might not be able to see the new distribution straight away due to caching) or ... - [ ] run the [Release to npm](https://github.com/ipfs/npm-go-ipfs/actions/workflows/main.yml) workflow diff --git a/docs/changelogs/v0.28.md b/docs/changelogs/v0.28.md new file mode 100644 index 00000000000..6dfd33386be --- /dev/null +++ b/docs/changelogs/v0.28.md @@ -0,0 +1,130 @@ +# Kubo changelog v0.28 + +- [v0.28.0](#v0280) + +## v0.28.0 + +- [Overview](#overview) +- [🔦 Highlights](#-highlights) + - [RPC client: removed deprecated DHT API](#rpc-client-removed-deprecated-dht-api) + - [Gateway: `/api/v0` is removed](#gateway-apiv0-is-removed) + - [Removed deprecated Object API commands](#removed-deprecated-object-api-commands) + - [No longer publishes loopback and private addresses on DHT](#no-longer-publishes-loopback-and-private-addresses-on-dht) + - [Pin roots are now prioritized when announcing](#pin-roots-are-now-prioritized-when-announcing) +- [📝 Changelog](#-changelog) +- [👨‍👩‍👧‍👦 Contributors](#-contributors) + +### Overview + +#### RPC client: removed deprecated DHT API + +The deprecated DHT API commands in the RPC client have been removed. Instead, use the Routing API. + +#### Gateway: `/api/v0` is removed + +The legacy subset of the Kubo RPC that was available via the Gateway port and was deprecated is now completely removed. You can read more in . + +If you have a legacy software that relies on this behavior, and want to expose parts of `/api/v0` next to `/ipfs`, use reverse-proxy in front of Kubo to mount both Gateway and RPC on the same port. NOTE: exposing RPC to the internet comes with security risk: make sure to specify access control via [API.Authorizations](https://github.com/ipfs/kubo/blob/master/docs/config.md#apiauthorizations). + +#### Removed deprecated Object API commands + +The Object API commands deprecated back in [2021](https://github.com/ipfs/kubo/issues/7936) have been removed, except for `object diff`, `object patch add-link` and `object patch rm-link`, whose alternatives have not yet been built (see issues [4801](https://github.com/ipfs/kubo/issues/4801) and [4782](https://github.com/ipfs/kubo/issues/4782)). + +##### Kubo ignores loopback addresses on LAN DHT and private addresses on WAN DHT + +Kubo no longer keeps track of loopback and private addresses on the LAN and WAN DHTs, respectively. This means that other nodes will not try to dial likely undialable addresses. + +To support testing scenarios where multiple Kubo instances run on the same machine, [`Routing.LoopbackAddressesOnLanDHT`](https://github.com/ipfs/kubo/blob/master/docs/config.md#routingloopbackaddressesonlandht) is set to `true` when the `test` profile is applied. + +#### Pin roots are now prioritized when announcing + +The root CIDs of pinned content are now prioritized when announcing to the Amino DHT with [`Reprovider.Strategy`](https://github.com/ipfs/kubo/blob/master/docs/config.md#reproviderstrategy) set to `all` (default) or `pinned`, making the important CIDs accessible faster. + +### 📝 Changelog + +
Full Changelog + +- github.com/ipfs/kubo: + - chore: update version + - chore: update version + - core/node: prioritize announcing pin roots, and flat strategy (#10376) ([ipfs/kubo#10376](https://github.com/ipfs/kubo/pull/10376)) + - chore: webui v4.2.1 (#10391) ([ipfs/kubo#10391](https://github.com/ipfs/kubo/pull/10391)) + - docs(config): clarify RPC vs Gateway + - chore: upgrade go-libp2p-kad-dht (#10378) ([ipfs/kubo#10378](https://github.com/ipfs/kubo/pull/10378)) + - chore(config): make Routing.AcceleratedDHTClient a Flag (#10384) ([ipfs/kubo#10384](https://github.com/ipfs/kubo/pull/10384)) + - fix: switch lowpower profile to autoclient + - core: fix some typos (#10382) ([ipfs/kubo#10382](https://github.com/ipfs/kubo/pull/10382)) + - docs: fix some typos (#10377) ([ipfs/kubo#10377](https://github.com/ipfs/kubo/pull/10377)) + - core/commands!: remove deprecated object APIs (#10375) ([ipfs/kubo#10375](https://github.com/ipfs/kubo/pull/10375)) + - docs: update default ipns lifetime + - coreapi/unixfs: don't create an additional IpfsNode for --only-hash + - chore: cleanup old workaround (#10369) ([ipfs/kubo#10369](https://github.com/ipfs/kubo/pull/10369)) + - chore: finish reframe removal + - docs: remove repetitive words (#10370) ([ipfs/kubo#10370](https://github.com/ipfs/kubo/pull/10370)) + - docs: updated links and refs to external resources (#10368) ([ipfs/kubo#10368](https://github.com/ipfs/kubo/pull/10368)) + - core/corehttp!: remove /api/v0 from gateway port + - client/rpc!: remove deprecated DHT commands + - ci: upgrade to go 1.22 (#10355) ([ipfs/kubo#10355](https://github.com/ipfs/kubo/pull/10355)) + - chore: create next changelog + - Merge Release: v0.27.0 [skip changelog] ([ipfs/kubo#10362](https://github.com/ipfs/kubo/pull/10362)) + - test: cleanup content blocking tests (#10360) ([ipfs/kubo#10360](https://github.com/ipfs/kubo/pull/10360)) + - docs: improve release issue template + - chore: update version +- github.com/ipfs/boxo (v0.18.0 -> v0.19.0): + - Release v0.19.0 ([ipfs/boxo#598](https://github.com/ipfs/boxo/pull/598)) +- github.com/libp2p/go-libp2p (v0.33.0 -> v0.33.2): + - chore: release v0.33.2 (#2755) ([libp2p/go-libp2p#2755](https://github.com/libp2p/go-libp2p/pull/2755)) + - Update quic-go to v0.42.0. Release v0.33.1 (#2741) ([libp2p/go-libp2p#2741](https://github.com/libp2p/go-libp2p/pull/2741)) +- github.com/libp2p/go-libp2p-kad-dht (v0.24.4 -> v0.25.2): + - chore: release v0.25.2 ([libp2p/go-libp2p-kad-dht#961](https://github.com/libp2p/go-libp2p-kad-dht/pull/961)) + - add ctx canceled err check ([libp2p/go-libp2p-kad-dht#960](https://github.com/libp2p/go-libp2p-kad-dht/pull/960)) + - chore: release v0.25.1 + - perf: don't buffer the output of FindProvidersAsync + - chore: use go-libp2p-routing-helpers for tracing needs + - fix: properly iterate in tracing for protocol messenger + - fix: apply addrFilters in the dht (#872) ([libp2p/go-libp2p-kad-dht#872](https://github.com/libp2p/go-libp2p-kad-dht/pull/872)) + - Add provider record addresses to peerstore ([libp2p/go-libp2p-kad-dht#870](https://github.com/libp2p/go-libp2p-kad-dht/pull/870)) + - chore: release v0.25.0 + - tracing: add protocol messages client tracing + - Enhance handleNewMessage Server Mode Logging: Convert Error Logs to Debug Level ([libp2p/go-libp2p-kad-dht#860](https://github.com/libp2p/go-libp2p-kad-dht/pull/860)) + - tracing: fix DHT keys as string attribute not being valid utf-8 ([libp2p/go-libp2p-kad-dht#859](https://github.com/libp2p/go-libp2p-kad-dht/pull/859)) + - merge: fix: issues discovered in kubo v0.21.0-rc2 (#853) ([libp2p/go-libp2p-kad-dht#853](https://github.com/libp2p/go-libp2p-kad-dht/pull/853)) + - merge: fix: issues discovered in kubo v0.21.0-rc1 (#851) ([libp2p/go-libp2p-kad-dht#851](https://github.com/libp2p/go-libp2p-kad-dht/pull/851)) + - Release v0.24.0 ([libp2p/go-libp2p-kad-dht#844](https://github.com/libp2p/go-libp2p-kad-dht/pull/844)) + - fix: don't add unresponsive DHT servers to the Routing Table (#820) ([libp2p/go-libp2p-kad-dht#820](https://github.com/libp2p/go-libp2p-kad-dht/pull/820)) + - filter local addresses (for WAN) and localhost addresses (for LAN) ([libp2p/go-libp2p-kad-dht#839](https://github.com/libp2p/go-libp2p-kad-dht/pull/839)) +- github.com/multiformats/go-multiaddr (v0.12.2 -> v0.12.3): + - chore: release v0.12.3 ([multiformats/go-multiaddr#240](https://github.com/multiformats/go-multiaddr/pull/240)) + - chore: Expand comment ForEach ([multiformats/go-multiaddr#238](https://github.com/multiformats/go-multiaddr/pull/238)) + - .Decapsulate by Components ([multiformats/go-multiaddr#239](https://github.com/multiformats/go-multiaddr/pull/239)) +- github.com/whyrusleeping/cbor-gen (v0.0.0-20240109153615-66e95c3e8a87 -> v0.1.0): + - Nullable ints (#93) ([whyrusleeping/cbor-gen#93](https://github.com/whyrusleeping/cbor-gen/pull/93)) + - Introduce Gen{} struct for configurability ([whyrusleeping/cbor-gen#94](https://github.com/whyrusleeping/cbor-gen/pull/94)) + - Transparent encoding ([whyrusleeping/cbor-gen#91](https://github.com/whyrusleeping/cbor-gen/pull/91)) + - turn max length consts into global vars ([whyrusleeping/cbor-gen#92](https://github.com/whyrusleeping/cbor-gen/pull/92)) + +
+ +### 👨‍👩‍👧‍👦 Contributors + +| Contributor | Commits | Lines ± | Files Changed | +|-------------|---------|---------|---------------| +| Henrique Dias | 19 | +867/-2806 | 96 | +| Rod Vagg | 7 | +921/-475 | 25 | +| Marcin Rataj | 8 | +358/-344 | 18 | +| Guillaume Michel - guissou | 1 | +145/-485 | 13 | +| Jorropo | 8 | +429/-136 | 22 | +| Łukasz Magiera | 4 | +284/-48 | 11 | +| whyrusleeping | 1 | +90/-90 | 2 | +| Michael Muré | 2 | +48/-73 | 9 | +| Marco Munizaga | 6 | +86/-29 | 10 | +| guillaumemichel | 3 | +93/-1 | 3 | +| Marten Seemann | 1 | +31/-4 | 4 | +| godeamon | 3 | +11/-8 | 3 | +| shuangcui | 1 | +6/-6 | 5 | +| occupyhabit | 1 | +3/-3 | 3 | +| crazehang | 1 | +2/-2 | 1 | +| Dennis Trautwein | 1 | +1/-2 | 1 | +| “GheisMohammadi” | 1 | +1/-1 | 1 | +| web3-bot | 1 | +2/-0 | 1 | +| Daniel Norman | 1 | +1/-1 | 1 | diff --git a/docs/changelogs/v0.4.md b/docs/changelogs/v0.4.md index 5abf5df67b5..bdc0f004b04 100644 --- a/docs/changelogs/v0.4.md +++ b/docs/changelogs/v0.4.md @@ -335,7 +335,7 @@ browsers (see [#4143](https://github.com/ipfs/go-ipfs/issues/4143). #### Human Readable Numbers -The `ipfs bitswap stat` and and `ipfs object stat` commands now support a +The `ipfs bitswap stat` and `ipfs object stat` commands now support a `--humanize` flag that formats numbers with human-readable units (GiB, MiB, etc.). @@ -2114,7 +2114,7 @@ approach: a local IPFS node). To fix the security issue, we intend to switch IPFS gateway links -`https://ipfs.io/ipfs/CID` to to `https://CID.ipfs.dweb.link`. This way, the CID +`https://ipfs.io/ipfs/CID` to `https://CID.ipfs.dweb.link`. This way, the CID will be a part of the ["origin"](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin) so each IPFS website will get a separate security origin. diff --git a/docs/changelogs/v0.5.md b/docs/changelogs/v0.5.md index dd154a6b4c2..aa5f9c95789 100644 --- a/docs/changelogs/v0.5.md +++ b/docs/changelogs/v0.5.md @@ -993,7 +993,7 @@ As usual, this release contains several Windows specific fixes and improvements: - fix(dagreader): remove a buggy workaround for a gateway issue ([ipfs/go-unixfs#80](https://github.com/ipfs/go-unixfs/pull/80)) - fix: correctly handle symlink file sizes ([ipfs/go-unixfs#78](https://github.com/ipfs/go-unixfs/pull/78)) - fix: return the correct error from RemoveChild ([ipfs/go-unixfs#76](https://github.com/ipfs/go-unixfs/pull/76)) - - update the the last go-merkledag ([ipfs/go-unixfs#75](https://github.com/ipfs/go-unixfs/pull/75)) + - update the last go-merkledag ([ipfs/go-unixfs#75](https://github.com/ipfs/go-unixfs/pull/75)) - fix: enumerate children ([ipfs/go-unixfs#74](https://github.com/ipfs/go-unixfs/pull/74)) - github.com/ipfs/interface-go-ipfs-core (v0.0.8 -> v0.2.7): - Add pin ls tests for indirect pin traversal and pin type precedence ([ipfs/interface-go-ipfs-core#47](https://github.com/ipfs/interface-go-ipfs-core/pull/47)) diff --git a/docs/config.md b/docs/config.md index ca24c2d0f87..e36ffebb73e 100644 --- a/docs/config.md +++ b/docs/config.md @@ -117,6 +117,7 @@ config file at runtime. - [`Routing`](#routing) - [`Routing.Type`](#routingtype) - [`Routing.AcceleratedDHTClient`](#routingaccelerateddhtclient) + - [`Routing.LoopbackAddressesOnLanDHT`](#routingloopbackaddressesonlandht) - [`Routing.Routers`](#routingrouters) - [`Routing.Routers: Type`](#routingrouters-type) - [`Routing.Routers: Parameters`](#routingrouters-parameters) @@ -344,8 +345,8 @@ Contains information about various listener addresses to be used by this node. ### `Addresses.API` -Multiaddr or array of multiaddrs describing the address to serve the local HTTP -API on. +Multiaddr or array of multiaddrs describing the address to serve +the local [Kubo RPC API](https://docs.ipfs.tech/reference/kubo/rpc/) (`/api/v0`). Supported Transports: @@ -358,8 +359,8 @@ Type: `strings` (multiaddrs) ### `Addresses.Gateway` -Multiaddr or array of multiaddrs describing the address to serve the local -gateway on. +Multiaddr or array of multiaddrs describing the address to serve +the local [HTTP gateway](https://specs.ipfs.tech/http-gateways/) (`/ipfs`, `/ipns`) on. Supported Transports: @@ -426,10 +427,12 @@ Default: `[]` Type: `array[string]` (multiaddrs) ## `API` -Contains information used by the API gateway. + +Contains information used by the [Kubo RPC API](https://docs.ipfs.tech/reference/kubo/rpc/). ### `API.HTTPHeaders` -Map of HTTP headers to set on responses from the API HTTP server. + +Map of HTTP headers to set on responses from the RPC (`/api/v0`) HTTP server. Example: ```json @@ -1130,7 +1133,7 @@ Type: `interval` or an empty string for the default. A time duration specifying the value to set on ipns records for their validity lifetime. -Default: 24 hours. +Default: 48 hours. Type: `interval` or an empty string for the default. @@ -1500,7 +1503,9 @@ Type: `optionalDuration` (unset for the default) Tells reprovider what should be announced. Valid strategies are: - `"all"` - announce all CIDs of stored blocks + - Order: root blocks of direct and recursive pins are announced first, then the rest of blockstore - `"pinned"` - only announce pinned CIDs recursively (both roots and child blocks) + - Order: root blocks of direct and recursive pins are announced first, then the child blocks of recursive pins - `"roots"` - only announce the root block of explicitly pinned CIDs - **⚠️ BE CAREFUL:** node with `roots` strategy will not announce child blocks. It makes sense only for use cases where the entire DAG is fetched in full, @@ -1509,6 +1514,7 @@ Tells reprovider what should be announced. Valid strategies are: providers for the missing block in the middle of a file, unless the peer happens to already be connected to a provider and ask for child CID over bitswap. +- `"flat"` - same as `all`, announce all CIDs of stored blocks, but without prioritizing anything Default: `"all"` @@ -1610,6 +1616,18 @@ them Default: `false` +Type: `flag` + +### `Routing.LoopbackAddressesOnLanDHT` + +**EXPERIMENTAL: `Routing.LoopbackAddressesOnLanDHT` configuration may change in future release** + +Whether loopback addresses (e.g. 127.0.0.1) should not be ignored on the local LAN DHT. + +Most users do not need this setting. It can be useful during testing, when multiple Kubo nodes run on the same machine but some of them do not have `Discovery.MDNS.Enabled`. + +Default: `false` + Type: `bool` (missing means `false`) ### `Routing.Routers` diff --git a/docs/delegated-routing.md b/docs/delegated-routing.md index f4207f409e4..6f15972ed27 100644 --- a/docs/delegated-routing.md +++ b/docs/delegated-routing.md @@ -11,8 +11,8 @@ Previously we only used the Amino DHT for content routing and content providing. -Kubo 0.14 introduced experimental support for [delegated routing using Reframe protocol](https://github.com/ipfs/kubo/pull/8997). -Since then, Reframe got deprecated and superseded by [Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/). +Kubo 0.14 introduced experimental support for [delegated routing](https://github.com/ipfs/kubo/pull/8997), +which then got changed and standardized as [Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/). Kubo 0.23.0 release added support for [self-hosting Routing V1 HTTP API server](https://github.com/ipfs/kubo/blob/master/docs/changelogs/v0.23.md#self-hosting-routingv1-endpoint-for-delegated-routing-needs). @@ -42,15 +42,15 @@ The `Routing` configuration section will contain the following keys: #### Routers -`Routers` will be a key-value list of routers that will be available to use. The key is the router name and the value is all the needed configurations for that router. the `Type` will define the routing kind. The main router types will be `reframe` and `dht`, but we will implement two special routers used to execute a set of routers in parallel or sequentially: `parallel` router and `sequential` router. +`Routers` will be a key-value list of routers that will be available to use. The key is the router name and the value is all the needed configurations for that router. the `Type` will define the routing kind. The main router types will be `http` and `dht`, but we will implement two special routers used to execute a set of routers in parallel or sequentially: `parallel` router and `sequential` router. Depending on the routing type, it will use different parameters: -##### Reframe +##### HTTP Params: -- `"Endpoint"`: URL endpoint implementing Reframe protocol. +- `"Endpoint"`: URL of HTTP server with endpoints that implement [Delegated Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/) protocol. ##### Amino DHT @@ -89,10 +89,10 @@ The value will contain: "Routing": { "Type": "custom", "Routers": { - "storetheindex": { - "Type": "reframe", + "http-delegated": { + "Type": "http", "Parameters": { - "Endpoint": "https://cid.contact/reframe" + "Endpoint": "https://delegated-ipfs.dev" // /routing/v1 (https://specs.ipfs.tech/routing/http-routing-v1/) } }, "dht-lan": { @@ -123,7 +123,7 @@ The value will contain: "RouterName": "dht-wan" }, { - "RouterName": "storetheindex" + "RouterName": "http-delegated" } ] } @@ -142,7 +142,7 @@ The value will contain: "Timeout": "100ms" }, { - "RouterName": "storetheindex", + "RouterName": "http-delegated", "ExecuteAfter": "100ms" } ] @@ -161,7 +161,7 @@ The value will contain: "Timeout": "300ms" }, { - "RouterName": "storetheindex", + "RouterName": "http-delegated", "Timeout": "300ms" } ] @@ -178,7 +178,7 @@ The value will contain: "RouterName": "dht-wan" }, { - "RouterName": "storetheindex" + "RouterName": "http-delegated" } ] } @@ -201,75 +201,6 @@ The value will contain: } ``` -Added YAML for clarity: - -```yaml ---- -Type: custom -Routers: - storetheindex: - Type: reframe - Parameters: - Endpoint: https://cid.contact/reframe - dht-lan: - Type: dht - Parameters: - Mode: server - PublicIPNetwork: false - AcceleratedDHTClient: false - dht-wan: - Type: dht - Parameters: - Mode: auto - PublicIPNetwork: true - AcceleratedDHTClient: false - find-providers-router: - Type: parallel - Parameters: - Routers: - - RouterName: dht-lan - IgnoreErrors: true - - RouterName: dht-wan - - RouterName: storetheindex - provide-router: - Type: parallel - Parameters: - Routers: - - RouterName: dht-lan - IgnoreErrors: true - - RouterName: dht-wan - ExecuteAfter: 100ms - Timeout: 100ms - - RouterName: storetheindex - ExecuteAfter: 100ms - get-ipns-router: - Type: sequential - Parameters: - Routers: - - RouterName: dht-lan - IgnoreErrors: true - - RouterName: dht-wan - Timeout: 300ms - - RouterName: storetheindex - Timeout: 300ms - put-ipns-router: - Type: parallel - Parameters: - Routers: - - RouterName: dht-lan - - RouterName: dht-wan - - RouterName: storetheindex -Methods: - find-providers: - RouterName: find-providers-router - provide: - RouterName: provide-router - get-ipns: - RouterName: get-ipns-router - put-ipns: - RouterName: put-ipns-router -``` - ### Error cases - If any of the routers fails, the output will be an error by default. - You can use `IgnoreErrors:true` to ignore errors for a specific router output @@ -402,48 +333,6 @@ As test fixtures we can add different use cases here and see how the configurati } } ``` -YAML representation for clarity: - -```yaml ---- -Type: custom -Routers: - dht-lan: - Type: dht - Parameters: - Mode: server - PublicIPNetwork: false - dht-wan: - Type: dht - Parameters: - Mode: auto - PublicIPNetwork: true - parallel-dht-strict: - Type: parallel - Parameters: - Routers: - - RouterName: dht-lan - - RouterName: dht-wan - parallel-dht: - Type: parallel - Parameters: - Routers: - - RouterName: dht-lan - IgnoreError: true - - RouterName: dht-wan -Methods: - provide: - RouterName: dht-wan - find-providers: - RouterName: parallel-dht-strict - find-peers: - RouterName: parallel-dht-strict - get-ipns: - RouterName: parallel-dht - put-ipns: - RouterName: parallel-dht - -``` ### Compatibility diff --git a/docs/examples/kubo-as-a-library/go.mod b/docs/examples/kubo-as-a-library/go.mod index 263925581b8..5bfa4b7be12 100644 --- a/docs/examples/kubo-as-a-library/go.mod +++ b/docs/examples/kubo-as-a-library/go.mod @@ -1,18 +1,18 @@ module github.com/ipfs/kubo/examples/kubo-as-a-library -go 1.21 +go 1.22 -toolchain go1.21.7 +toolchain go1.22.0 // Used to keep this in sync with the current version of kubo. You should remove // this if you copy this example. replace github.com/ipfs/kubo => ./../../.. require ( - github.com/ipfs/boxo v0.18.0 + github.com/ipfs/boxo v0.19.0 github.com/ipfs/kubo v0.0.0-00010101000000-000000000000 - github.com/libp2p/go-libp2p v0.33.0 - github.com/multiformats/go-multiaddr v0.12.2 + github.com/libp2p/go-libp2p v0.33.2 + github.com/multiformats/go-multiaddr v0.12.3 ) require ( @@ -54,7 +54,7 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/google/gopacket v1.1.19 // indirect github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 // indirect - github.com/google/uuid v1.5.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.1 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -103,7 +103,7 @@ require ( github.com/libp2p/go-doh-resolver v0.4.0 // indirect github.com/libp2p/go-flow-metrics v0.1.0 // indirect github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect - github.com/libp2p/go-libp2p-kad-dht v0.24.4 // indirect + github.com/libp2p/go-libp2p-kad-dht v0.25.2 // indirect github.com/libp2p/go-libp2p-kbucket v0.6.3 // indirect github.com/libp2p/go-libp2p-pubsub v0.10.0 // indirect github.com/libp2p/go-libp2p-pubsub-router v0.6.0 // indirect @@ -158,12 +158,12 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polydawn/refmt v0.89.0 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/quic-go/qpack v0.4.0 // indirect - github.com/quic-go/quic-go v0.41.0 // indirect + github.com/quic-go/quic-go v0.42.0 // indirect github.com/quic-go/webtransport-go v0.6.0 // indirect github.com/raulk/go-watchdog v1.3.0 // indirect github.com/samber/lo v1.39.0 // indirect @@ -173,20 +173,20 @@ require ( github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb // indirect github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 // indirect - github.com/whyrusleeping/cbor-gen v0.0.0-20240109153615-66e95c3e8a87 // indirect + github.com/whyrusleeping/cbor-gen v0.1.0 // indirect github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/otel v1.22.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect go.opentelemetry.io/otel/exporters/zipkin v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.22.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.22.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/dig v1.17.1 // indirect go.uber.org/fx v1.20.1 // indirect @@ -194,8 +194,8 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect go4.org v0.0.0-20230225012048-214862532bf5 // indirect - golang.org/x/crypto v0.19.0 // indirect - golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect + golang.org/x/crypto v0.20.0 // indirect + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect diff --git a/docs/examples/kubo-as-a-library/go.sum b/docs/examples/kubo-as-a-library/go.sum index 7238b76c17a..4ee081aa808 100644 --- a/docs/examples/kubo-as-a-library/go.sum +++ b/docs/examples/kubo-as-a-library/go.sum @@ -224,8 +224,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4 github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= -github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= @@ -266,8 +266,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw= -github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= +github.com/ipfs/boxo v0.19.0 h1:UbX9FBJQF19ACLqRZOgdEla6jR/sC4H1O+iGE0NToXA= +github.com/ipfs/boxo v0.19.0/go.mod h1:V5gJzbIMwKEXrg3IdvAxIdF7UPgU4RsXmNGS8MQ/0D4= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-block-format v0.0.3/go.mod h1:4LmD4ZUw0mhO+JSKdpWwrzATiEfM7WWgQ8H5l6P8MVk= @@ -278,7 +278,6 @@ github.com/ipfs/go-blockservice v0.5.0/go.mod h1:W6brZ5k20AehbmERplmERn8o2Ni3ZZu github.com/ipfs/go-cid v0.0.3/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= github.com/ipfs/go-cid v0.0.4/go.mod h1:4LLaPOQwmk5z9LBgQnpkivrx8BJjUyGwTXCd5Xfj6+M= github.com/ipfs/go-cid v0.0.5/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67FexhXog= -github.com/ipfs/go-cid v0.0.6/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= @@ -423,14 +422,14 @@ github.com/libp2p/go-flow-metrics v0.0.1/go.mod h1:Iv1GH0sG8DtYN3SVJ2eG221wMiNpZ github.com/libp2p/go-flow-metrics v0.0.3/go.mod h1:HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs= github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= -github.com/libp2p/go-libp2p v0.33.0 h1:yTPSr8sJRbfeEYXyeN8VPVSlTlFjtMUwGDRniwaf/xQ= -github.com/libp2p/go-libp2p v0.33.0/go.mod h1:RIJFRQVUBKy82dnW7J5f1homqqv6NcsDJAl3e7CRGfE= +github.com/libp2p/go-libp2p v0.33.2 h1:vCdwnFxoGOXMKmaGHlDSnL4bM3fQeW8pgIa9DECnb40= +github.com/libp2p/go-libp2p v0.33.2/go.mod h1:zTeppLuCvUIkT118pFVzA8xzP/p2dJYOMApCkFh0Yww= github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= github.com/libp2p/go-libp2p-core v0.2.4/go.mod h1:STh4fdfa5vDYr0/SzYYeqnt+E6KfEV5VxfIrm0bcI0g= github.com/libp2p/go-libp2p-core v0.3.0/go.mod h1:ACp3DmS3/N64c2jDzcV429ukDpicbL6+TrrxANBjPGw= -github.com/libp2p/go-libp2p-kad-dht v0.24.4 h1:ktNiJe7ffsJ1wX3ULpMCwXts99mPqGFSE/Qn1i8pErQ= -github.com/libp2p/go-libp2p-kad-dht v0.24.4/go.mod h1:ybWBJ5Fbvz9sSLkNtXt+2+bK0JB8+tRPvhBbRGHegRU= +github.com/libp2p/go-libp2p-kad-dht v0.25.2 h1:FOIk9gHoe4YRWXTu8SY9Z1d0RILol0TrtApsMDPjAVQ= +github.com/libp2p/go-libp2p-kad-dht v0.25.2/go.mod h1:6za56ncRHYXX4Nc2vn8z7CZK0P4QiMcrn77acKLM2Oo= github.com/libp2p/go-libp2p-kbucket v0.3.1/go.mod h1:oyjT5O7tS9CQurok++ERgc46YLwEpuGoFq9ubvoUOio= github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0= github.com/libp2p/go-libp2p-kbucket v0.6.3/go.mod h1:RCseT7AH6eJWxxk2ol03xtP9pEHetYSPXOaJnOiD8i0= @@ -515,8 +514,8 @@ github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a github.com/multiformats/go-multiaddr v0.1.0/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= github.com/multiformats/go-multiaddr v0.1.1/go.mod h1:aMKBKNEYmzmDmxfX88/vz+J5IU55txyt0p4aiWVohjo= github.com/multiformats/go-multiaddr v0.2.0/go.mod h1:0nO36NvPpyV4QzvTLi/lafl2y95ncPj0vFwVF6k6wJ4= -github.com/multiformats/go-multiaddr v0.12.2 h1:9G9sTY/wCYajKa9lyfWPmpZAwe6oV+Wb1zcmMS1HG24= -github.com/multiformats/go-multiaddr v0.12.2/go.mod h1:GKyaTYjZRdcUhyOetrxTk9z0cW+jA/YrnqTOvKgi44M= +github.com/multiformats/go-multiaddr v0.12.3 h1:hVBXvPRcKG0w80VinQ23P5t7czWgg65BmIvQKjDydU8= +github.com/multiformats/go-multiaddr v0.12.3/go.mod h1:sBXrNzucqkFJhvKOiwwLyqamGa/P5EIXNPLovyhQCII= github.com/multiformats/go-multiaddr-dns v0.3.0/go.mod h1:mNzQ4eTGDg0ll1N9jKPOUogZPoJ30W8a7zk66FQPpdQ= github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= github.com/multiformats/go-multiaddr-dns v0.3.1/go.mod h1:G/245BRQ6FJGmryJCrOuTdB37AMA5AMOVuO6NY3JwTk= @@ -637,22 +636,22 @@ github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e/go.mod h1:uIp+gprXx github.com/polydawn/refmt v0.89.0 h1:ADJTApkvkeBZsN0tBTx8QjpD9JkmxbKp0cxfr9qszm4= github.com/polydawn/refmt v0.89.0/go.mod h1:/zvteZs/GwLtCgZ4BL6CBsk9IKIlexP43ObX9AxTqTw= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4k= -github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA= +github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM= +github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M= github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFDD3NxaZLY= github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc= github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= @@ -757,8 +756,8 @@ github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc h1:BCPnHtcboa github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc/go.mod h1:r45hJU7yEoA81k6MWNhpMj/kms0n14dkzkxYHoB96UM= github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 h1:5HZfQkwe0mIfyDmc1Em5GqlNRzcdtlv4HTNmdpt7XH0= github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11/go.mod h1:Wlo/SzPmxVp6vXpGt/zaXhHH0fn4IxgqZc82aKg6bpQ= -github.com/whyrusleeping/cbor-gen v0.0.0-20240109153615-66e95c3e8a87 h1:S4wCk+ZL4WGGaI+GsmqCRyt68ISbnZWsK9dD9jYL0fA= -github.com/whyrusleeping/cbor-gen v0.0.0-20240109153615-66e95c3e8a87/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= +github.com/whyrusleeping/cbor-gen v0.1.0 h1:Jneeq3V5enErVcuL0NKEbD1Gi+iOvEeFhXOV1S1Fc6g= +github.com/whyrusleeping/cbor-gen v0.1.0/go.mod h1:pM99HXyEbSQHcosHc0iW7YFmwnscr+t9Te4ibko05so= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= @@ -780,8 +779,8 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/otel v1.22.0 h1:xS7Ku+7yTFvDfDraDIJVpw7XPyuHlB9MCiqqX5mcJ6Y= -go.opentelemetry.io/otel v1.22.0/go.mod h1:eoV4iAi3Ea8LkAEI9+GFT44O6T/D0GWAVFyZVCC6pMI= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0/go.mod h1:zgBdWWAu7oEEMC06MMKc5NLbA/1YDXV1sMpSqEeLQLg= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 h1:tIqheXEFWAZ7O8A7m+J0aPTmpJN3YQ7qetUAdkkkKpk= @@ -792,12 +791,12 @@ go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 h1:VhlEQAPp9R1ktYf go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0/go.mod h1:kB3ufRbfU+CQ4MlUcqtW8Z7YEOBeK2DJ6CmR5rYYF3E= go.opentelemetry.io/otel/exporters/zipkin v1.21.0 h1:D+Gv6lSfrFBWmQYyxKjDd0Zuld9SRXpIrEsKZvE4DO4= go.opentelemetry.io/otel/exporters/zipkin v1.21.0/go.mod h1:83oMKR6DzmHisFOW3I+yIMGZUTjxiWaiBI8M8+TU5zE= -go.opentelemetry.io/otel/metric v1.22.0 h1:lypMQnGyJYeuYPhOM/bgjbFM6WE44W1/T45er4d8Hhg= -go.opentelemetry.io/otel/metric v1.22.0/go.mod h1:evJGjVpZv0mQ5QBRJoBF64yMuOf4xCWdXjK8pzFvliY= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= -go.opentelemetry.io/otel/trace v1.22.0 h1:Hg6pPujv0XG9QaVbGOBVHunyuLcCC3jN7WEhPx83XD0= -go.opentelemetry.io/otel/trace v1.22.0/go.mod h1:RbbHXVqKES9QhzZq/fE5UnOSILqRt40a21sPw2He1xo= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -852,8 +851,8 @@ golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45 golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= +golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -862,8 +861,8 @@ golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1039,6 +1038,8 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/docs/gateway.md b/docs/gateway.md index 531c8c6f94e..3a616a15803 100644 --- a/docs/gateway.md +++ b/docs/gateway.md @@ -13,7 +13,9 @@ Kubo's Gateway implementation follows [ipfs/specs: Specification for HTTP Gatewa By default, Kubo nodes run a [path gateway](https://docs.ipfs.tech/how-to/address-ipfs-on-web/#path-gateway) at `http://127.0.0.1:8080/` and a [subdomain gateway](https://docs.ipfs.tech/how-to/address-ipfs-on-web/#subdomain-gateway) at `http://localhost:8080/`. -Both support [trustless responses](https://docs.ipfs.tech/reference/http/gateway/#trustless-verifiable-retrieval) as opt-in via `Accept` header. + +The path one also implements [trustless gateway spec](https://specs.ipfs.tech/http-gateways/trustless-gateway/) +and supports [trustless responses](https://docs.ipfs.tech/reference/http/gateway/#trustless-verifiable-retrieval) as opt-in via `Accept` header. Additional listening addresses and gateway behaviors can be set in the [config](#configuration) file. @@ -65,7 +67,7 @@ Gateway](https://dnslink.dev/#example-ipfs-gateway) for instructions. When downloading files, browsers will usually guess a file's filename by looking at the last component of the path. Unfortunately, when linking *directly* to a file (with no containing directory), the final component is just a CID -(`Qm...`). This isn't exactly user-friendly. +(`bafy..` or `Qm...`). This isn't exactly user-friendly. To work around this issue, you can add a `filename=some_filename` parameter to your query string to explicitly specify the filename. For example: @@ -89,6 +91,11 @@ or by sending `Accept: application/vnd.ipld.{format}` HTTP header with one of su ## Content-Types +Majority of resources can be retrieved trustlessly by requesting specific content type via `Accept` header or `?format=raw|car|ipns-record` URL query parameter. + +See [trustless gateway specification](https://specs.ipfs.tech/http-gateways/trustless-gateway/) +and [verifiable retrieval documentation](https://docs.ipfs.tech/reference/http/gateway/#trustless-verifiable-retrieval) for more details. + ### `application/vnd.ipld.raw` Returns a byte array for a single `raw` block. @@ -107,11 +114,9 @@ Support for user-provided IPLD selectors is tracked in https://github.com/ipfs/k This is a rough equivalent of `ipfs dag export`. -## Deprecated Subset of RPC API +### `application/vnd.ipfs.ipns-record` -For legacy reasons, some gateways may expose a small subset of RPC API under `/api/v0/`. -While this read-only API exposes a read-only, "safe" subset of the normal API, -it is deprecated and should not be used for greenfield projects. +Only works on `/ipns/{ipns-name}` content paths that use cryptographically signed [IPNS Records](https://specs.ipfs.tech/ipns/ipns-record/). -Where possible, leverage `/ipfs/` and `/ipns/` endpoints. -along with `application/vnd.ipld.*` Content-Types instead. +Returns [IPNS Record in Protobuf Serialization Format](https://specs.ipfs.tech/ipns/ipns-record/#record-serialization-format) +which can be verified on end client, without trusting gateway. diff --git a/docs/http-rpc-clients.md b/docs/http-rpc-clients.md index 31448cb863c..c53c0b5d0ec 100644 --- a/docs/http-rpc-clients.md +++ b/docs/http-rpc-clients.md @@ -6,3 +6,8 @@ Kubo provides official HTTP RPC (`/api/v0`) clients for selected languages: |:--------:|:-------------------:|--------------------------------------------| | JS | kubo-rpc-client | https://github.com/ipfs/js-kubo-rpc-client | | Go | `rpc` | [`../client/rpc`](../client/rpc) | + +There are community-maintained libraries for other languages, +but the Kubo team does provide support for them, YMMV: + +- https://docs.ipfs.tech/reference/kubo-rpc-cli/ diff --git a/docs/implement-api-bindings.md b/docs/implement-api-bindings.md index 996a6b8ac80..3587ac21f47 100644 --- a/docs/implement-api-bindings.md +++ b/docs/implement-api-bindings.md @@ -39,10 +39,9 @@ function calls. For example: #### CLI API Transport In the commandline, IPFS uses a traditional flag and arg-based mapping, where: -- the first arguments selects the command, as in git - e.g. `ipfs object get` +- the first arguments selects the command, as in git - e.g. `ipfs dag get` - the flags specify options - e.g. `--enc=protobuf -q` -- the rest are positional arguments - e.g. - `ipfs object patch add-linkfoo ` +- the rest are positional arguments - e.g. `ipfs key rename ` - files are specified by filename, or through stdin (NOTE: When kubo runs the daemon, the CLI API is actually converted to HTTP diff --git a/docs/windows.md b/docs/windows.md index 590f270af32..3ed0e4ab261 100644 --- a/docs/windows.md +++ b/docs/windows.md @@ -153,6 +153,6 @@ If you get authentication problems with Git, you might want to take a look at ht `git config --global credential.helper wincred` - **Anything else** -Please search [https://discuss.ipfs.io](https://discuss.ipfs.io/search?q=windows%20category%3A13) for any additional issues you may encounter. If you can't find any existing resolution, feel free to post a question asking for help. +Please search [https://discuss.ipfs.tech](https://discuss.ipfs.tech/search?q=windows%20category%3A13) for any additional issues you may encounter. If you can't find any existing resolution, feel free to post a question asking for help. If you encounter a bug with `kubo` itself (not related to building) please use the [issue tracker](https://github.com/ipfs/kubo/issues) to report it. diff --git a/go.mod b/go.mod index fae6f2f9681..04971b5691a 100644 --- a/go.mod +++ b/go.mod @@ -13,11 +13,11 @@ require ( github.com/elgris/jsondiff v0.0.0-20160530203242-765b5c24c302 github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 github.com/fsnotify/fsnotify v1.6.0 - github.com/google/uuid v1.5.0 + github.com/google/uuid v1.6.0 github.com/hashicorp/go-multierror v1.1.1 github.com/ipfs-shipyard/nopfs v0.0.12 github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c - github.com/ipfs/boxo v0.18.0 + github.com/ipfs/boxo v0.19.0 github.com/ipfs/go-block-format v0.2.0 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-cidutil v0.1.0 @@ -47,9 +47,9 @@ require ( github.com/jbenet/goprocess v0.1.4 github.com/julienschmidt/httprouter v1.3.0 github.com/libp2p/go-doh-resolver v0.4.0 - github.com/libp2p/go-libp2p v0.33.0 + github.com/libp2p/go-libp2p v0.33.2 github.com/libp2p/go-libp2p-http v0.5.0 - github.com/libp2p/go-libp2p-kad-dht v0.24.4 + github.com/libp2p/go-libp2p-kad-dht v0.25.2 github.com/libp2p/go-libp2p-kbucket v0.6.3 github.com/libp2p/go-libp2p-pubsub v0.10.0 github.com/libp2p/go-libp2p-pubsub-router v0.6.0 @@ -58,7 +58,7 @@ require ( github.com/libp2p/go-libp2p-testing v0.12.0 github.com/libp2p/go-socket-activation v0.1.0 github.com/mitchellh/go-homedir v1.1.0 - github.com/multiformats/go-multiaddr v0.12.2 + github.com/multiformats/go-multiaddr v0.12.3 github.com/multiformats/go-multiaddr-dns v0.3.1 github.com/multiformats/go-multibase v0.2.0 github.com/multiformats/go-multicodec v0.9.0 @@ -66,7 +66,7 @@ require ( github.com/opentracing/opentracing-go v1.2.0 github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.18.0 + github.com/prometheus/client_golang v1.19.0 github.com/stretchr/testify v1.8.4 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tidwall/gjson v1.14.4 @@ -76,15 +76,15 @@ require ( go.opencensus.io v0.24.0 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 go.opentelemetry.io/contrib/propagators/autoprop v0.46.1 - go.opentelemetry.io/otel v1.22.0 + go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/sdk v1.21.0 - go.opentelemetry.io/otel/trace v1.22.0 + go.opentelemetry.io/otel/trace v1.24.0 go.uber.org/dig v1.17.1 go.uber.org/fx v1.20.1 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 - golang.org/x/crypto v0.19.0 - golang.org/x/exp v0.0.0-20240213143201-ec583247a57a + golang.org/x/crypto v0.20.0 + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 golang.org/x/mod v0.15.0 golang.org/x/sync v0.6.0 golang.org/x/sys v0.17.0 @@ -200,11 +200,11 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polydawn/refmt v0.89.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/prometheus/statsd_exporter v0.22.7 // indirect github.com/quic-go/qpack v0.4.0 // indirect - github.com/quic-go/quic-go v0.41.0 // indirect + github.com/quic-go/quic-go v0.42.0 // indirect github.com/quic-go/webtransport-go v0.6.0 // indirect github.com/raulk/go-watchdog v1.3.0 // indirect github.com/rs/cors v1.7.0 // indirect @@ -216,7 +216,7 @@ require ( github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb // indirect github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 // indirect - github.com/whyrusleeping/cbor-gen v0.0.0-20240109153615-66e95c3e8a87 // indirect + github.com/whyrusleeping/cbor-gen v0.1.0 // indirect github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect go.opentelemetry.io/contrib/propagators/aws v1.21.1 // indirect @@ -228,13 +228,13 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect go.opentelemetry.io/otel/exporters/zipkin v1.21.0 // indirect - go.opentelemetry.io/otel/metric v1.22.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/mock v0.4.0 // indirect go4.org v0.0.0-20230225012048-214862532bf5 // indirect golang.org/x/net v0.21.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect + golang.org/x/oauth2 v0.17.0 // indirect golang.org/x/term v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect @@ -250,6 +250,4 @@ require ( lukechampine.com/blake3 v1.2.1 // indirect ) -go 1.21 - -toolchain go1.21.7 +go 1.22 diff --git a/go.sum b/go.sum index 004c018092d..fcd51a181f1 100644 --- a/go.sum +++ b/go.sum @@ -287,8 +287,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4 github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= -github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= @@ -329,8 +329,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw= -github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= +github.com/ipfs/boxo v0.19.0 h1:UbX9FBJQF19ACLqRZOgdEla6jR/sC4H1O+iGE0NToXA= +github.com/ipfs/boxo v0.19.0/go.mod h1:V5gJzbIMwKEXrg3IdvAxIdF7UPgU4RsXmNGS8MQ/0D4= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ= @@ -345,7 +345,6 @@ github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUP github.com/ipfs/go-cid v0.0.3/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= github.com/ipfs/go-cid v0.0.4/go.mod h1:4LLaPOQwmk5z9LBgQnpkivrx8BJjUyGwTXCd5Xfj6+M= github.com/ipfs/go-cid v0.0.5/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67FexhXog= -github.com/ipfs/go-cid v0.0.6/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= @@ -509,8 +508,8 @@ github.com/libp2p/go-flow-metrics v0.0.1/go.mod h1:Iv1GH0sG8DtYN3SVJ2eG221wMiNpZ github.com/libp2p/go-flow-metrics v0.0.3/go.mod h1:HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs= github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= -github.com/libp2p/go-libp2p v0.33.0 h1:yTPSr8sJRbfeEYXyeN8VPVSlTlFjtMUwGDRniwaf/xQ= -github.com/libp2p/go-libp2p v0.33.0/go.mod h1:RIJFRQVUBKy82dnW7J5f1homqqv6NcsDJAl3e7CRGfE= +github.com/libp2p/go-libp2p v0.33.2 h1:vCdwnFxoGOXMKmaGHlDSnL4bM3fQeW8pgIa9DECnb40= +github.com/libp2p/go-libp2p v0.33.2/go.mod h1:zTeppLuCvUIkT118pFVzA8xzP/p2dJYOMApCkFh0Yww= github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= github.com/libp2p/go-libp2p-core v0.2.4/go.mod h1:STh4fdfa5vDYr0/SzYYeqnt+E6KfEV5VxfIrm0bcI0g= @@ -519,8 +518,8 @@ github.com/libp2p/go-libp2p-gostream v0.6.0 h1:QfAiWeQRce6pqnYfmIVWJFXNdDyfiR/qk github.com/libp2p/go-libp2p-gostream v0.6.0/go.mod h1:Nywu0gYZwfj7Jc91PQvbGU8dIpqbQQkjWgDuOrFaRdA= github.com/libp2p/go-libp2p-http v0.5.0 h1:+x0AbLaUuLBArHubbbNRTsgWz0RjNTy6DJLOxQ3/QBc= github.com/libp2p/go-libp2p-http v0.5.0/go.mod h1:glh87nZ35XCQyFsdzZps6+F4HYI6DctVFY5u1fehwSg= -github.com/libp2p/go-libp2p-kad-dht v0.24.4 h1:ktNiJe7ffsJ1wX3ULpMCwXts99mPqGFSE/Qn1i8pErQ= -github.com/libp2p/go-libp2p-kad-dht v0.24.4/go.mod h1:ybWBJ5Fbvz9sSLkNtXt+2+bK0JB8+tRPvhBbRGHegRU= +github.com/libp2p/go-libp2p-kad-dht v0.25.2 h1:FOIk9gHoe4YRWXTu8SY9Z1d0RILol0TrtApsMDPjAVQ= +github.com/libp2p/go-libp2p-kad-dht v0.25.2/go.mod h1:6za56ncRHYXX4Nc2vn8z7CZK0P4QiMcrn77acKLM2Oo= github.com/libp2p/go-libp2p-kbucket v0.3.1/go.mod h1:oyjT5O7tS9CQurok++ERgc46YLwEpuGoFq9ubvoUOio= github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0= github.com/libp2p/go-libp2p-kbucket v0.6.3/go.mod h1:RCseT7AH6eJWxxk2ol03xtP9pEHetYSPXOaJnOiD8i0= @@ -620,8 +619,8 @@ github.com/multiformats/go-multiaddr v0.1.0/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lg github.com/multiformats/go-multiaddr v0.1.1/go.mod h1:aMKBKNEYmzmDmxfX88/vz+J5IU55txyt0p4aiWVohjo= github.com/multiformats/go-multiaddr v0.2.0/go.mod h1:0nO36NvPpyV4QzvTLi/lafl2y95ncPj0vFwVF6k6wJ4= github.com/multiformats/go-multiaddr v0.4.0/go.mod h1:YcpyLH8ZPudLxQlemYBPhSm0/oCXAT8Z4mzFpyoPyRc= -github.com/multiformats/go-multiaddr v0.12.2 h1:9G9sTY/wCYajKa9lyfWPmpZAwe6oV+Wb1zcmMS1HG24= -github.com/multiformats/go-multiaddr v0.12.2/go.mod h1:GKyaTYjZRdcUhyOetrxTk9z0cW+jA/YrnqTOvKgi44M= +github.com/multiformats/go-multiaddr v0.12.3 h1:hVBXvPRcKG0w80VinQ23P5t7czWgg65BmIvQKjDydU8= +github.com/multiformats/go-multiaddr v0.12.3/go.mod h1:sBXrNzucqkFJhvKOiwwLyqamGa/P5EIXNPLovyhQCII= github.com/multiformats/go-multiaddr-dns v0.3.0/go.mod h1:mNzQ4eTGDg0ll1N9jKPOUogZPoJ30W8a7zk66FQPpdQ= github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= github.com/multiformats/go-multiaddr-dns v0.3.1/go.mod h1:G/245BRQ6FJGmryJCrOuTdB37AMA5AMOVuO6NY3JwTk= @@ -753,8 +752,8 @@ github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqr github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -769,8 +768,8 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9 github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.35.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -785,8 +784,8 @@ github.com/prometheus/statsd_exporter v0.22.7 h1:7Pji/i2GuhK6Lu7DHrtTkFmNBCudCPT github.com/prometheus/statsd_exporter v0.22.7/go.mod h1:N/TevpjkIh9ccs6nuzY3jQn9dFqnUakOjnEuMPJJJnI= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4k= -github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA= +github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM= +github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M= github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFDD3NxaZLY= github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc= github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= @@ -907,8 +906,8 @@ github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc h1:BCPnHtcboa github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc/go.mod h1:r45hJU7yEoA81k6MWNhpMj/kms0n14dkzkxYHoB96UM= github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 h1:5HZfQkwe0mIfyDmc1Em5GqlNRzcdtlv4HTNmdpt7XH0= github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11/go.mod h1:Wlo/SzPmxVp6vXpGt/zaXhHH0fn4IxgqZc82aKg6bpQ= -github.com/whyrusleeping/cbor-gen v0.0.0-20240109153615-66e95c3e8a87 h1:S4wCk+ZL4WGGaI+GsmqCRyt68ISbnZWsK9dD9jYL0fA= -github.com/whyrusleeping/cbor-gen v0.0.0-20240109153615-66e95c3e8a87/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= +github.com/whyrusleeping/cbor-gen v0.1.0 h1:Jneeq3V5enErVcuL0NKEbD1Gi+iOvEeFhXOV1S1Fc6g= +github.com/whyrusleeping/cbor-gen v0.1.0/go.mod h1:pM99HXyEbSQHcosHc0iW7YFmwnscr+t9Te4ibko05so= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= @@ -948,8 +947,8 @@ go.opentelemetry.io/contrib/propagators/jaeger v1.21.1 h1:f4beMGDKiVzg9IcX7/VuWV go.opentelemetry.io/contrib/propagators/jaeger v1.21.1/go.mod h1:U9jhkEl8d1LL+QXY7q3kneJWJugiN3kZJV2OWz3hkBY= go.opentelemetry.io/contrib/propagators/ot v1.21.1 h1:3TN5vkXjKYWp0YdMcnUEC/A+pBPvqz9V3nCS2xmcurk= go.opentelemetry.io/contrib/propagators/ot v1.21.1/go.mod h1:oy0MYCbS/b3cqUDW37wBWtlwBIsutngS++Lklpgh+fc= -go.opentelemetry.io/otel v1.22.0 h1:xS7Ku+7yTFvDfDraDIJVpw7XPyuHlB9MCiqqX5mcJ6Y= -go.opentelemetry.io/otel v1.22.0/go.mod h1:eoV4iAi3Ea8LkAEI9+GFT44O6T/D0GWAVFyZVCC6pMI= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0/go.mod h1:zgBdWWAu7oEEMC06MMKc5NLbA/1YDXV1sMpSqEeLQLg= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 h1:tIqheXEFWAZ7O8A7m+J0aPTmpJN3YQ7qetUAdkkkKpk= @@ -960,12 +959,12 @@ go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 h1:VhlEQAPp9R1ktYf go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0/go.mod h1:kB3ufRbfU+CQ4MlUcqtW8Z7YEOBeK2DJ6CmR5rYYF3E= go.opentelemetry.io/otel/exporters/zipkin v1.21.0 h1:D+Gv6lSfrFBWmQYyxKjDd0Zuld9SRXpIrEsKZvE4DO4= go.opentelemetry.io/otel/exporters/zipkin v1.21.0/go.mod h1:83oMKR6DzmHisFOW3I+yIMGZUTjxiWaiBI8M8+TU5zE= -go.opentelemetry.io/otel/metric v1.22.0 h1:lypMQnGyJYeuYPhOM/bgjbFM6WE44W1/T45er4d8Hhg= -go.opentelemetry.io/otel/metric v1.22.0/go.mod h1:evJGjVpZv0mQ5QBRJoBF64yMuOf4xCWdXjK8pzFvliY= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= -go.opentelemetry.io/otel/trace v1.22.0 h1:Hg6pPujv0XG9QaVbGOBVHunyuLcCC3jN7WEhPx83XD0= -go.opentelemetry.io/otel/trace v1.22.0/go.mod h1:RbbHXVqKES9QhzZq/fE5UnOSILqRt40a21sPw2He1xo= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -1020,8 +1019,8 @@ golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45 golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= +golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1032,8 +1031,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1127,8 +1126,8 @@ golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ= +golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA= golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1260,6 +1259,8 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/test/3nodetest/bin/save_profiling_data.sh b/test/3nodetest/bin/save_profiling_data.sh index 03c0cbabec4..639b5d38342 100644 --- a/test/3nodetest/bin/save_profiling_data.sh +++ b/test/3nodetest/bin/save_profiling_data.sh @@ -6,7 +6,7 @@ for container in 3nodetest_bootstrap_1 3nodetest_client_1 3nodetest_server_1; do done # since the nodes are executed with the --debug flag, profiling data is written -# to the the working dir. by default, the working dir is /go. +# to the working dir. by default, the working dir is /go. for container in 3nodetest_bootstrap_1 3nodetest_client_1 3nodetest_server_1; do docker cp $container:/go/ipfs.cpuprof build/profiling_data_$container diff --git a/test/cli/basic_commands_test.go b/test/cli/basic_commands_test.go index 69b0cc63bc8..603a03d9dea 100644 --- a/test/cli/basic_commands_test.go +++ b/test/cli/basic_commands_test.go @@ -147,7 +147,6 @@ func TestCommandDocsWidth(t *testing.T) { "ipfs swarm addrs listen": true, "ipfs dag resolve": true, "ipfs dag get": true, - "ipfs object stat": true, "ipfs pin remote add": true, "ipfs config show": true, "ipfs config edit": true, @@ -164,8 +163,6 @@ func TestCommandDocsWidth(t *testing.T) { "ipfs object diff": true, "ipfs object patch add-link": true, "ipfs name": true, - "ipfs object patch append-data": true, - "ipfs object patch set-data": true, "ipfs diag profile": true, "ipfs diag cmds": true, "ipfs swarm addrs local": true, diff --git a/test/cli/dag_test.go b/test/cli/dag_test.go index d17b71cfb12..1a3defc3c00 100644 --- a/test/cli/dag_test.go +++ b/test/cli/dag_test.go @@ -36,7 +36,7 @@ type Data struct { // The Fixture file represents a dag where 2 nodes of size = 46B each, have a common child of 7B // when traversing the DAG from the root's children (node1 and node2) we count (46 + 7)x2 bytes (counting redundant bytes) = 106 // since both nodes share a common child of 7 bytes we actually had to read (46)x2 + 7 = 99 bytes -// we should get a dedup ratio of 106/99 that results in approximatelly 1.0707071 +// we should get a dedup ratio of 106/99 that results in approximately 1.0707071 func TestDag(t *testing.T) { t.Parallel() diff --git a/test/cli/gateway_test.go b/test/cli/gateway_test.go index 71fb38d41c7..33212a90f32 100644 --- a/test/cli/gateway_test.go +++ b/test/cli/gateway_test.go @@ -14,7 +14,6 @@ import ( "github.com/ipfs/kubo/config" "github.com/ipfs/kubo/test/cli/harness" - . "github.com/ipfs/kubo/test/cli/testutils" "github.com/libp2p/go-libp2p/core/peer" "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr/net" @@ -344,76 +343,6 @@ func TestGateway(t *testing.T) { }) }) - t.Run("readonly API", func(t *testing.T) { - t.Parallel() - - client := node.GatewayClient() - - fileContents := "12345" - h.WriteFile("readonly/dir/test", fileContents) - cids := node.IPFS("add", "-r", "-q", filepath.Join(h.Dir, "readonly/dir")).Stdout.Lines() - - rootCID := cids[len(cids)-1] - client.TemplateData = map[string]string{"RootCID": rootCID} - - t.Run("Get IPFS directory file through readonly API succeeds", func(t *testing.T) { - t.Parallel() - resp := client.Get("/api/v0/cat?arg={{.RootCID}}/test") - assert.Equal(t, 200, resp.StatusCode) - assert.Equal(t, fileContents, resp.Body) - }) - - t.Run("refs IPFS directory file through readonly API succeeds", func(t *testing.T) { - t.Parallel() - resp := client.Get("/api/v0/refs?arg={{.RootCID}}/test") - assert.Equal(t, 200, resp.StatusCode) - }) - - t.Run("test gateway API is sanitized", func(t *testing.T) { - t.Parallel() - for _, cmd := range []string{ - "add", - "block/put", - "bootstrap", - "config", - "dag/put", - "dag/import", - "dht", - "diag", - "id", - "mount", - "name/publish", - "object/put", - "object/new", - "object/patch", - "pin", - "ping", - "repo", - "stats", - "swarm", - "file", - "update", - "bitswap", - } { - t.Run(cmd, func(t *testing.T) { - cmd := cmd - t.Parallel() - assert.Equal(t, 404, client.Get("/api/v0/"+cmd).StatusCode) - }) - } - }) - }) - - t.Run("refs/local", func(t *testing.T) { - t.Parallel() - gatewayAddr := URLStrToMultiaddr(node.GatewayURL()) - res := node.RunIPFS("--api", gatewayAddr.String(), "refs", "local") - assert.Contains(t, - res.Stderr.Trimmed(), - `Error: invalid path "local":`, - ) - }) - t.Run("raw leaves node", func(t *testing.T) { t.Parallel() contents := "This is RAW!" diff --git a/test/cli/harness/node.go b/test/cli/harness/node.go index d030c7c9404..ad8ac263bad 100644 --- a/test/cli/harness/node.go +++ b/test/cli/harness/node.go @@ -208,6 +208,7 @@ func (n *Node) Init(ipfsArgs ...string) *Node { cfg.Addresses.Gateway = []string{n.GatewayListenAddr.String()} cfg.Swarm.DisableNatPortMap = true cfg.Discovery.MDNS.Enabled = n.EnableMDNS + cfg.Routing.LoopbackAddressesOnLanDHT = config.True }) return n } diff --git a/test/cli/provider_test.go b/test/cli/provider_test.go new file mode 100644 index 00000000000..5ecf8f3cab7 --- /dev/null +++ b/test/cli/provider_test.go @@ -0,0 +1,165 @@ +package cli + +import ( + "bytes" + "testing" + "time" + + "github.com/ipfs/kubo/test/cli/harness" + "github.com/ipfs/kubo/test/cli/testutils" + "github.com/stretchr/testify/require" +) + +func TestProvider(t *testing.T) { + t.Parallel() + + initNodes := func(t *testing.T, n int, fn func(n *harness.Node)) harness.Nodes { + nodes := harness.NewT(t).NewNodes(n).Init() + nodes.ForEachPar(fn) + return nodes.StartDaemons().Connect() + } + + expectNoProviders := func(t *testing.T, cid string, nodes ...*harness.Node) { + for _, node := range nodes { + res := node.IPFS("routing", "findprovs", "-n=1", cid) + require.Empty(t, res.Stdout.String()) + } + } + + expectProviders := func(t *testing.T, cid, expectedProvider string, nodes ...*harness.Node) { + for _, node := range nodes { + res := node.IPFS("routing", "findprovs", "-n=1", cid) + require.Equal(t, expectedProvider, res.Stdout.Trimmed()) + } + } + + t.Run("Basic Providing", func(t *testing.T) { + t.Parallel() + + nodes := initNodes(t, 2, func(n *harness.Node) { + n.SetIPFSConfig("Experimental.StrategicProviding", false) + }) + defer nodes.StopDaemons() + + cid := nodes[0].IPFSAddStr(time.Now().String()) + expectProviders(t, cid, nodes[0].PeerID().String(), nodes[1:]...) + }) + + t.Run("Basic Strategic Providing", func(t *testing.T) { + t.Parallel() + + nodes := initNodes(t, 2, func(n *harness.Node) { + n.SetIPFSConfig("Experimental.StrategicProviding", true) + }) + defer nodes.StopDaemons() + + cid := nodes[0].IPFSAddStr(time.Now().String()) + expectNoProviders(t, cid, nodes[1:]...) + }) + + t.Run("Reprovides with 'all' strategy", func(t *testing.T) { + t.Parallel() + + nodes := initNodes(t, 2, func(n *harness.Node) { + n.SetIPFSConfig("Reprovider.Strategy", "all") + }) + defer nodes.StopDaemons() + + cid := nodes[0].IPFSAddStr(time.Now().String(), "--local") + + expectNoProviders(t, cid, nodes[1:]...) + + nodes[0].IPFS("bitswap", "reprovide") + + expectProviders(t, cid, nodes[0].PeerID().String(), nodes[1:]...) + }) + + t.Run("Reprovides with 'flat' strategy", func(t *testing.T) { + t.Parallel() + + nodes := initNodes(t, 2, func(n *harness.Node) { + n.SetIPFSConfig("Reprovider.Strategy", "flat") + }) + defer nodes.StopDaemons() + + cid := nodes[0].IPFSAddStr(time.Now().String(), "--local") + + expectNoProviders(t, cid, nodes[1:]...) + + nodes[0].IPFS("bitswap", "reprovide") + + expectProviders(t, cid, nodes[0].PeerID().String(), nodes[1:]...) + }) + + t.Run("Reprovides with 'pinned' strategy", func(t *testing.T) { + t.Parallel() + + foo := testutils.RandomBytes(1000) + bar := testutils.RandomBytes(1000) + + nodes := initNodes(t, 2, func(n *harness.Node) { + n.SetIPFSConfig("Reprovider.Strategy", "pinned") + }) + defer nodes.StopDaemons() + + cidFoo := nodes[0].IPFSAdd(bytes.NewReader(foo), "--offline", "--pin=false") + cidBar := nodes[0].IPFSAdd(bytes.NewReader(bar), "--offline", "--pin=false") + cidBarDir := nodes[0].IPFSAdd(bytes.NewReader(bar), "-Q", "--offline", "-w") + + expectNoProviders(t, cidFoo, nodes[1:]...) + expectNoProviders(t, cidBar, nodes[1:]...) + expectNoProviders(t, cidBarDir, nodes[1:]...) + + nodes[0].IPFS("bitswap", "reprovide") + + expectNoProviders(t, cidFoo, nodes[1:]...) + expectProviders(t, cidBar, nodes[0].PeerID().String(), nodes[1:]...) + expectProviders(t, cidBarDir, nodes[0].PeerID().String(), nodes[1:]...) + }) + + t.Run("Reprovides with 'roots' strategy", func(t *testing.T) { + t.Parallel() + + foo := testutils.RandomBytes(1000) + bar := testutils.RandomBytes(1000) + baz := testutils.RandomBytes(1000) + + nodes := initNodes(t, 2, func(n *harness.Node) { + n.SetIPFSConfig("Reprovider.Strategy", "roots") + }) + defer nodes.StopDaemons() + + cidFoo := nodes[0].IPFSAdd(bytes.NewReader(foo), "--offline", "--pin=false") + cidBar := nodes[0].IPFSAdd(bytes.NewReader(bar), "--offline", "--pin=false") + cidBaz := nodes[0].IPFSAdd(bytes.NewReader(baz), "--offline") + cidBarDir := nodes[0].IPFSAdd(bytes.NewReader(bar), "-Q", "--offline", "-w") + + expectNoProviders(t, cidFoo, nodes[1:]...) + expectNoProviders(t, cidBar, nodes[1:]...) + expectNoProviders(t, cidBarDir, nodes[1:]...) + + nodes[0].IPFS("bitswap", "reprovide") + + expectNoProviders(t, cidFoo, nodes[1:]...) + expectNoProviders(t, cidBar, nodes[1:]...) + expectProviders(t, cidBaz, nodes[0].PeerID().String(), nodes[1:]...) + expectProviders(t, cidBarDir, nodes[0].PeerID().String(), nodes[1:]...) + }) + + t.Run("Providing works without ticking", func(t *testing.T) { + t.Parallel() + + nodes := initNodes(t, 2, func(n *harness.Node) { + n.SetIPFSConfig("Reprovider.Interval", "0") + }) + defer nodes.StopDaemons() + + cid := nodes[0].IPFSAddStr(time.Now().String(), "--offline") + + expectNoProviders(t, cid, nodes[1:]...) + + nodes[0].IPFS("bitswap", "reprovide") + + expectProviders(t, cid, nodes[0].PeerID().String(), nodes[1:]...) + }) +} diff --git a/test/dependencies/go.mod b/test/dependencies/go.mod index 9e38a70869d..6b6ecea994c 100644 --- a/test/dependencies/go.mod +++ b/test/dependencies/go.mod @@ -1,8 +1,8 @@ module github.com/ipfs/kubo/test/dependencies -go 1.21 +go 1.22 -toolchain go1.21.7 +toolchain go1.22.0 replace github.com/ipfs/kubo => ../../ @@ -16,7 +16,7 @@ require ( github.com/ipfs/iptb-plugins v0.5.0 github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c github.com/jbenet/go-random-files v0.0.0-20190219210431-31b3f20ebded - github.com/multiformats/go-multiaddr v0.12.2 + github.com/multiformats/go-multiaddr v0.12.3 github.com/multiformats/go-multihash v0.2.3 gotest.tools/gotestsum v0.4.2 ) @@ -89,7 +89,7 @@ require ( github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gopacket v1.1.19 // indirect - github.com/google/uuid v1.5.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/gordonklaus/ineffassign v0.0.0-20230610083614-0e73809eb601 // indirect github.com/gostaticanalysis/analysisutil v0.7.1 // indirect github.com/gostaticanalysis/comment v1.4.2 // indirect @@ -105,7 +105,7 @@ require ( github.com/hexops/gotextdiff v1.0.3 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/ipfs/bbloom v0.0.4 // indirect - github.com/ipfs/boxo v0.18.0 // indirect + github.com/ipfs/boxo v0.19.0 // indirect github.com/ipfs/go-block-format v0.2.0 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/ipfs/go-datastore v0.6.0 // indirect @@ -135,9 +135,9 @@ require ( github.com/leonklingele/grouper v1.1.1 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/libp2p/go-cidranger v1.1.0 // indirect - github.com/libp2p/go-libp2p v0.33.0 // indirect + github.com/libp2p/go-libp2p v0.33.2 // indirect github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect - github.com/libp2p/go-libp2p-kad-dht v0.24.4 // indirect + github.com/libp2p/go-libp2p-kad-dht v0.25.2 // indirect github.com/libp2p/go-libp2p-kbucket v0.6.3 // indirect github.com/libp2p/go-libp2p-record v0.2.0 // indirect github.com/libp2p/go-libp2p-routing-helpers v0.7.3 // indirect @@ -180,9 +180,9 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polydawn/refmt v0.89.0 // indirect github.com/polyfloyd/go-errorlint v1.4.3 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/quasilyte/go-ruleguard v0.4.0 // indirect github.com/quasilyte/gogrep v0.5.0 // indirect @@ -234,14 +234,14 @@ require ( github.com/ykadowak/zerologlint v0.1.3 // indirect gitlab.com/bosi/decorder v0.4.0 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/otel v1.22.0 // indirect - go.opentelemetry.io/otel/metric v1.22.0 // indirect - go.opentelemetry.io/otel/trace v1.22.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect go.tmz.dev/musttag v0.7.1 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.19.0 // indirect - golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect + golang.org/x/crypto v0.20.0 // indirect + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect diff --git a/test/dependencies/go.sum b/test/dependencies/go.sum index 163c393abe7..18d82929d56 100644 --- a/test/dependencies/go.sum +++ b/test/dependencies/go.sum @@ -309,8 +309,8 @@ github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 h1:E/LAvt58di64hlYjx7 github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= -github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= @@ -362,8 +362,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw= -github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= +github.com/ipfs/boxo v0.19.0 h1:UbX9FBJQF19ACLqRZOgdEla6jR/sC4H1O+iGE0NToXA= +github.com/ipfs/boxo v0.19.0/go.mod h1:V5gJzbIMwKEXrg3IdvAxIdF7UPgU4RsXmNGS8MQ/0D4= github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs= github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= @@ -480,12 +480,12 @@ github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38y github.com/libp2p/go-cidranger v1.1.0/go.mod h1:KWZTfSr+r9qEo9OkI9/SIEeAtw+NNoU0dXIXt15Okic= github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= -github.com/libp2p/go-libp2p v0.33.0 h1:yTPSr8sJRbfeEYXyeN8VPVSlTlFjtMUwGDRniwaf/xQ= -github.com/libp2p/go-libp2p v0.33.0/go.mod h1:RIJFRQVUBKy82dnW7J5f1homqqv6NcsDJAl3e7CRGfE= +github.com/libp2p/go-libp2p v0.33.2 h1:vCdwnFxoGOXMKmaGHlDSnL4bM3fQeW8pgIa9DECnb40= +github.com/libp2p/go-libp2p v0.33.2/go.mod h1:zTeppLuCvUIkT118pFVzA8xzP/p2dJYOMApCkFh0Yww= github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= -github.com/libp2p/go-libp2p-kad-dht v0.24.4 h1:ktNiJe7ffsJ1wX3ULpMCwXts99mPqGFSE/Qn1i8pErQ= -github.com/libp2p/go-libp2p-kad-dht v0.24.4/go.mod h1:ybWBJ5Fbvz9sSLkNtXt+2+bK0JB8+tRPvhBbRGHegRU= +github.com/libp2p/go-libp2p-kad-dht v0.25.2 h1:FOIk9gHoe4YRWXTu8SY9Z1d0RILol0TrtApsMDPjAVQ= +github.com/libp2p/go-libp2p-kad-dht v0.25.2/go.mod h1:6za56ncRHYXX4Nc2vn8z7CZK0P4QiMcrn77acKLM2Oo= github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0= github.com/libp2p/go-libp2p-kbucket v0.6.3/go.mod h1:RCseT7AH6eJWxxk2ol03xtP9pEHetYSPXOaJnOiD8i0= github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= @@ -563,8 +563,8 @@ github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYg github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= github.com/multiformats/go-multiaddr v0.2.0/go.mod h1:0nO36NvPpyV4QzvTLi/lafl2y95ncPj0vFwVF6k6wJ4= -github.com/multiformats/go-multiaddr v0.12.2 h1:9G9sTY/wCYajKa9lyfWPmpZAwe6oV+Wb1zcmMS1HG24= -github.com/multiformats/go-multiaddr v0.12.2/go.mod h1:GKyaTYjZRdcUhyOetrxTk9z0cW+jA/YrnqTOvKgi44M= +github.com/multiformats/go-multiaddr v0.12.3 h1:hVBXvPRcKG0w80VinQ23P5t7czWgg65BmIvQKjDydU8= +github.com/multiformats/go-multiaddr v0.12.3/go.mod h1:sBXrNzucqkFJhvKOiwwLyqamGa/P5EIXNPLovyhQCII= github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= github.com/multiformats/go-multiaddr-dns v0.3.1/go.mod h1:G/245BRQ6FJGmryJCrOuTdB37AMA5AMOVuO6NY3JwTk= github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= @@ -635,8 +635,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -647,8 +647,8 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= @@ -666,8 +666,8 @@ github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4l github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4k= -github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA= +github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM= +github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M= github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFDD3NxaZLY= github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc= github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= @@ -817,12 +817,12 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/otel v1.22.0 h1:xS7Ku+7yTFvDfDraDIJVpw7XPyuHlB9MCiqqX5mcJ6Y= -go.opentelemetry.io/otel v1.22.0/go.mod h1:eoV4iAi3Ea8LkAEI9+GFT44O6T/D0GWAVFyZVCC6pMI= -go.opentelemetry.io/otel/metric v1.22.0 h1:lypMQnGyJYeuYPhOM/bgjbFM6WE44W1/T45er4d8Hhg= -go.opentelemetry.io/otel/metric v1.22.0/go.mod h1:evJGjVpZv0mQ5QBRJoBF64yMuOf4xCWdXjK8pzFvliY= -go.opentelemetry.io/otel/trace v1.22.0 h1:Hg6pPujv0XG9QaVbGOBVHunyuLcCC3jN7WEhPx83XD0= -go.opentelemetry.io/otel/trace v1.22.0/go.mod h1:RbbHXVqKES9QhzZq/fE5UnOSILqRt40a21sPw2He1xo= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.tmz.dev/musttag v0.7.1 h1:9lFmeSFnFfPuMq4IksHGomItE6NgKMNW2Nt2FPOhCfU= go.tmz.dev/musttag v0.7.1/go.mod h1:oJLkpR56EsIryktZJk/B0IroSMi37YWver47fibGh5U= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -856,8 +856,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= +golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -868,8 +868,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 h1:jWGQJV4niP+CCmFW9ekjA9Zx8vYORzOUH2/Nl5WPuLQ= diff --git a/test/sharness/lib/iptb-lib.sh b/test/sharness/lib/iptb-lib.sh index 3d2e95a4916..8b2d956c2e9 100644 --- a/test/sharness/lib/iptb-lib.sh +++ b/test/sharness/lib/iptb-lib.sh @@ -34,6 +34,10 @@ startup_cluster() { other_args="$@" bound=$(expr "$num_nodes" - 1) + test_expect_success "set Routing.LoopbackAddressesOnLanDHT to true" ' + iptb run [0-$bound] -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true + ' + if test -n "$other_args"; then test_expect_success "start up nodes with additional args" " iptb start -wait [0-$bound] -- ${other_args[@]} diff --git a/test/sharness/t0002-docker-image.sh b/test/sharness/t0002-docker-image.sh index 11ccf01b74e..2ff827806ba 100755 --- a/test/sharness/t0002-docker-image.sh +++ b/test/sharness/t0002-docker-image.sh @@ -50,7 +50,7 @@ test_expect_success "docker image runs" ' ' test_expect_success "docker container gateway is up" ' - pollEndpoint -host=/ip4/127.0.0.1/tcp/8080 -http-url http://localhost:8080/api/v0/version -v -tries 30 -tout 1s + pollEndpoint -host=/ip4/127.0.0.1/tcp/8080 -http-url http://localhost:8080/ipfs/bafkqaddimvwgy3zao5xxe3debi -v -tries 30 -tout 1s ' test_expect_success "docker container API is up" ' diff --git a/test/sharness/t0051-object-data/testPut.pb b/test/sharness/t0050-block-data/testPut.pb similarity index 100% rename from test/sharness/t0051-object-data/testPut.pb rename to test/sharness/t0050-block-data/testPut.pb diff --git a/test/sharness/t0050-block.sh b/test/sharness/t0050-block.sh index 9ecf2087596..05502adaf5e 100755 --- a/test/sharness/t0050-block.sh +++ b/test/sharness/t0050-block.sh @@ -42,12 +42,12 @@ test_expect_success "'ipfs block put' output looks good" ' ' test_expect_success "can set cid codec on block put" ' - CODEC_HASH=$(ipfs block put --cid-codec=dag-pb ../t0051-object-data/testPut.pb) + CODEC_HASH=$(ipfs block put --cid-codec=dag-pb ../t0050-block-data/testPut.pb) ' test_expect_success "block get output looks right" ' ipfs block get $CODEC_HASH > pb_block_out && - test_cmp pb_block_out ../t0051-object-data/testPut.pb + test_cmp pb_block_out ../t0050-block-data/testPut.pb ' # @@ -210,33 +210,33 @@ test_expect_success "multi-block 'ipfs block rm -q' produces no output" ' # --format used 'protobuf' for 'dag-pb' which was invalid, but we keep # for backward-compatibility test_expect_success "can set deprecated --format=protobuf on block put" ' - HASH=$(ipfs block put --format=protobuf ../t0051-object-data/testPut.pb) + HASH=$(ipfs block put --format=protobuf ../t0050-block-data/testPut.pb) ' test_expect_success "created an object correctly!" ' - ipfs object get $HASH > obj_out && - echo "{\"Links\":[],\"Data\":\"test json for sharness test\"}" > obj_exp && + ipfs dag get $HASH > obj_out && + echo -n "{\"Data\":{\"/\":{\"bytes\":\"dGVzdCBqc29uIGZvciBzaGFybmVzcyB0ZXN0\"}},\"Links\":[]}" > obj_exp && test_cmp obj_out obj_exp ' test_expect_success "block get output looks right" ' ipfs block get $HASH > pb_block_out && - test_cmp pb_block_out ../t0051-object-data/testPut.pb + test_cmp pb_block_out ../t0050-block-data/testPut.pb ' test_expect_success "can set --cid-codec=dag-pb on block put" ' - HASH=$(ipfs block put --cid-codec=dag-pb ../t0051-object-data/testPut.pb) + HASH=$(ipfs block put --cid-codec=dag-pb ../t0050-block-data/testPut.pb) ' test_expect_success "created an object correctly!" ' - ipfs object get $HASH > obj_out && - echo "{\"Links\":[],\"Data\":\"test json for sharness test\"}" > obj_exp && + ipfs dag get $HASH > obj_out && + echo -n "{\"Data\":{\"/\":{\"bytes\":\"dGVzdCBqc29uIGZvciBzaGFybmVzcyB0ZXN0\"}},\"Links\":[]}" > obj_exp && test_cmp obj_out obj_exp ' test_expect_success "block get output looks right" ' ipfs block get $HASH > pb_block_out && - test_cmp pb_block_out ../t0051-object-data/testPut.pb + test_cmp pb_block_out ../t0050-block-data/testPut.pb ' test_expect_success "can set multihash type and length on block put with --format=raw (deprecated)" ' @@ -248,7 +248,7 @@ test_expect_success "output looks good" ' ' test_expect_success "can't use both legacy format and custom cid-codec at the same time" ' - test_expect_code 1 ipfs block put --format=dag-cbor --cid-codec=dag-json < ../t0051-object-data/testPut.pb 2> output && + test_expect_code 1 ipfs block put --format=dag-cbor --cid-codec=dag-json < ../t0050-block-data/testPut.pb 2> output && test_should_contain "unable to use \"format\" (deprecated) and a custom \"cid-codec\" at the same time" output ' diff --git a/test/sharness/t0051-object-data/UTF-8-test.txt b/test/sharness/t0051-object-data/UTF-8-test.txt deleted file mode 100644 index 56213a84a98..00000000000 Binary files a/test/sharness/t0051-object-data/UTF-8-test.txt and /dev/null differ diff --git a/test/sharness/t0051-object-data/brokenPut.json b/test/sharness/t0051-object-data/brokenPut.json deleted file mode 100644 index 6ba2d6f3b62..00000000000 --- a/test/sharness/t0051-object-data/brokenPut.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "this": "should", - "return": "an", - "error":"not valid dag object" -} \ No newline at end of file diff --git a/test/sharness/t0051-object-data/brokenPut.xml b/test/sharness/t0051-object-data/brokenPut.xml deleted file mode 100644 index 331bbac9901..00000000000 --- a/test/sharness/t0051-object-data/brokenPut.xml +++ /dev/null @@ -1 +0,0 @@ -This is not a valid dag object fail diff --git a/test/sharness/t0051-object-data/expected_getOut b/test/sharness/t0051-object-data/expected_getOut deleted file mode 100644 index dc12f63ba14..00000000000 --- a/test/sharness/t0051-object-data/expected_getOut +++ /dev/null @@ -1 +0,0 @@ -{"Links":[],"Data":"\u0008\u0002\u0012\nHello Mars\u0018\n"} diff --git a/test/sharness/t0051-object-data/mixed.json b/test/sharness/t0051-object-data/mixed.json deleted file mode 100644 index b8de2b8d886..00000000000 --- a/test/sharness/t0051-object-data/mixed.json +++ /dev/null @@ -1,5 +0,0 @@ -{"Data": "another", - "Links": [ - {"Name": "some link", "Hash": "QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V", "Size": 8}, - {"Name": "inlined", "Hash": "z4CrgyEyhm4tAw1pgzQtNNuP7", "Size": 14} -]} diff --git a/test/sharness/t0051-object-data/testPut.json b/test/sharness/t0051-object-data/testPut.json deleted file mode 100644 index c97f4ec0bf9..00000000000 --- a/test/sharness/t0051-object-data/testPut.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Data": "test json for sharness test" -} diff --git a/test/sharness/t0051-object-data/testPut.xml b/test/sharness/t0051-object-data/testPut.xml deleted file mode 100644 index 5cc290b2709..00000000000 --- a/test/sharness/t0051-object-data/testPut.xml +++ /dev/null @@ -1 +0,0 @@ -Test xml for sharness test diff --git a/test/sharness/t0051-object.sh b/test/sharness/t0051-object.sh index 316c220abd5..4bac6137488 100755 --- a/test/sharness/t0051-object.sh +++ b/test/sharness/t0051-object.sh @@ -27,204 +27,21 @@ test_patch_create_path() { } test_object_cmd() { - - test_expect_success "'ipfs add testData' succeeds" ' - printf "Hello Mars" >expected_in && - ipfs add expected_in >actual_Addout - ' - - test_expect_success "'ipfs add testData' output looks good" ' - HASH="QmWkHFpYBZ9mpPRreRbMhhYWXfUhBAue3JkbbpFqwowSRb" && - echo "added $HASH expected_in" >expected_Addout && - test_cmp expected_Addout actual_Addout - ' - - test_expect_success "'ipfs object get' succeeds" ' - ipfs object get $HASH >actual_getOut - ' - - test_expect_success "'ipfs object get' output looks good" ' - test_cmp ../t0051-object-data/expected_getOut actual_getOut - ' - - test_expect_success "'ipfs object get' can specify data encoding as base64" ' - ipfs object get --data-encoding base64 $HASH > obj_out && - echo "{\"Links\":[],\"Data\":\"CAISCkhlbGxvIE1hcnMYCg==\"}" > obj_exp && - test_cmp obj_out obj_exp - ' - - test_expect_success "'ipfs object get' can specify data encoding as text" ' - echo "{\"Links\":[],\"Data\":\"Hello Mars\"}" | ipfs object put && - ipfs object get --data-encoding text QmS3hVY6eYrMQ6L22agwrx3YHBEsc3LJxVXCtyQHqRBukH > obj_out && - echo "{\"Links\":[],\"Data\":\"Hello Mars\"}" > obj_exp && - test_cmp obj_out obj_exp - ' - - test_expect_failure "'ipfs object get' requires known data encoding" ' - ipfs object get --data-encoding nonsensical-encoding $HASH - ' - - test_expect_success "'ipfs object stat' succeeds" ' - ipfs object stat $HASH >actual_stat - ' - - test_expect_success "'ipfs object get' output looks good" ' - echo "NumLinks: 0" > expected_stat && - echo "BlockSize: 18" >> expected_stat && - echo "LinksSize: 2" >> expected_stat && - echo "DataSize: 16" >> expected_stat && - echo "CumulativeSize: 18" >> expected_stat && - test_cmp expected_stat actual_stat - ' - - test_expect_success "'ipfs object put file.json' succeeds" ' - ipfs object put ../t0051-object-data/testPut.json > actual_putOut - ' - - test_expect_success "'ipfs object put file.json' output looks good" ' - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && - printf "added $HASH\n" > expected_putOut && - test_cmp expected_putOut actual_putOut - ' - - test_expect_success "'ipfs object put --quiet file.json' succeeds" ' - ipfs object put --quiet ../t0051-object-data/testPut.json > actual_putOut - ' - - test_expect_success "'ipfs object put --quiet file.json' output looks good" ' - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && - printf "$HASH\n" > expected_putOut && - test_cmp expected_putOut actual_putOut - ' - - test_expect_success "'ipfs object put file.xml' succeeds" ' - ipfs object put ../t0051-object-data/testPut.xml --inputenc=xml > actual_putOut - ' - - test_expect_success "'ipfs object put file.xml' output looks good" ' - HASH="QmQzNKUHy4HyEUGkqKe3q3t796ffPLQXYCkHCcXUNT5JNK" && - printf "added $HASH\n" > expected_putOut && - test_cmp expected_putOut actual_putOut - ' - - test_expect_success "'ipfs object put' from stdin succeeds" ' - cat ../t0051-object-data/testPut.xml | ipfs object put --inputenc=xml > actual_putStdinOut - ' - - test_expect_failure "'ipfs object put broken.xml' should fail" ' - test_expect_code 1 ipfs object put ../t0051-object-data/brokenPut.xml --inputenc=xml 2>actual_putBrokenErr >actual_putBroken - ' - - test_expect_failure "'ipfs object put broken.hxml' output looks good" ' - touch expected_putBroken && - printf "Error: no data or links in this node\n" > expected_putBrokenErr && - test_cmp expected_putBroken actual_putBroken && - test_cmp expected_putBrokenErr actual_putBrokenErr - ' - test_expect_success "'ipfs object get --enc=xml' succeeds" ' - ipfs object get --enc=xml $HASH >utf8_xml - ' - - test_expect_success "'ipfs object put --inputenc=xml' succeeds" ' - ipfs object put --inputenc=xml actual - ' - - test_expect_failure "'ipfs object put --inputenc=xml' output looks good" ' - echo "added $HASH\n" >expected && - test_cmp expected actual - ' - - test_expect_success "'ipfs object put file.pb' succeeds" ' - ipfs object put --inputenc=protobuf ../t0051-object-data/testPut.pb > actual_putOut - ' - - test_expect_success "'ipfs object put file.pb' output looks good" ' - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && - printf "added $HASH\n" > expected_putOut && - test_cmp expected_putOut actual_putOut - ' - - test_expect_success "'ipfs object put' from stdin succeeds" ' - cat ../t0051-object-data/testPut.json | ipfs object put > actual_putStdinOut - ' - - test_expect_success "'ipfs object put' from stdin output looks good" ' - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && - printf "added $HASH\n" > expected_putStdinOut && - test_cmp expected_putStdinOut actual_putStdinOut - ' - - test_expect_success "'ipfs object put' from stdin (pb) succeeds" ' - cat ../t0051-object-data/testPut.pb | ipfs object put --inputenc=protobuf > actual_putPbStdinOut - ' - - test_expect_success "'ipfs object put' from stdin (pb) output looks good" ' - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && - printf "added $HASH\n" > expected_putStdinOut && - test_cmp expected_putStdinOut actual_putPbStdinOut - ' - - test_expect_success "'ipfs object put broken.json' should fail" ' - test_expect_code 1 ipfs object put ../t0051-object-data/brokenPut.json 2>actual_putBrokenErr >actual_putBroken - ' - - test_expect_success "'ipfs object put broken.hjson' output looks good" ' - touch expected_putBroken && - printf "Error: json: unknown field \"this\"\n" > expected_putBrokenErr && - test_cmp expected_putBroken actual_putBroken && - test_cmp expected_putBrokenErr actual_putBrokenErr - ' - - test_expect_success "setup: add UTF-8 test file" ' - HASH="QmNY5sQeH9ttVCg24sizH71dNbcZTpGd7Yb3YwsKZ4jiFP" && - ipfs add ../t0051-object-data/UTF-8-test.txt >actual && - echo "added $HASH UTF-8-test.txt" >expected && - test_cmp expected actual - ' - - test_expect_success "'ipfs object get --enc=json' succeeds" ' - ipfs object get --enc=json $HASH >utf8_json - ' - - test_expect_success "'ipfs object put --inputenc=json' succeeds" ' - ipfs object put --inputenc=json actual - ' - - test_expect_failure "'ipfs object put --inputenc=json' output looks good" ' - echo "added $HASH" >expected && - test_cmp expected actual - ' - - test_expect_success "'ipfs object put --pin' succeeds" ' - HASH="QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V" && - echo "added $HASH" >expected && - echo "{ \"Data\": \"abc\" }" | ipfs object put --pin >actual - ' - - test_expect_success "'ipfs object put --pin' output looks good" ' - echo "added $HASH" >expected && - test_cmp expected actual - ' - - test_expect_success "after gc, objects still accessible" ' - ipfs repo gc > /dev/null && - ipfs refs -r --timeout=2s $HASH > /dev/null - ' + EMPTY_DIR=$(echo '{"Links":[]}' | ipfs dag put --store-codec dag-pb) + EMPTY_UNIXFS_DIR=$(echo '{"Data":{"/":{"bytes":"CAE"}},"Links":[]}' | ipfs dag put --store-codec dag-pb) test_expect_success "'ipfs object patch' should work (no unixfs-dir)" ' - EMPTY_DIR=$(ipfs object new) && OUTPUT=$(ipfs object patch $EMPTY_DIR add-link foo $EMPTY_DIR) && - ipfs object stat $OUTPUT + ipfs dag stat $OUTPUT ' test_expect_success "'ipfs object patch' should work" ' - EMPTY_DIR=$(ipfs object new unixfs-dir) && - OUTPUT=$(ipfs object patch $EMPTY_DIR add-link foo $EMPTY_DIR) && - ipfs object stat $OUTPUT + OUTPUT=$(ipfs object patch $EMPTY_UNIXFS_DIR add-link foo $EMPTY_UNIXFS_DIR) && + ipfs dag stat $OUTPUT ' test_expect_success "'ipfs object patch' check output block size" ' - DIR=$(ipfs object new unixfs-dir) + DIR=$EMPTY_UNIXFS_DIR for i in {1..13} do DIR=$(ipfs object patch "$DIR" add-link "$DIR.jpg" "$DIR") @@ -241,32 +58,20 @@ test_object_cmd() { test_expect_code 0 ipfs object patch --allow-big-block=true "$DIR" add-link "$DIR.jpg" "$DIR" ' - test_expect_success "'ipfs object new foo' shouldn't crash" ' - test_expect_code 1 ipfs object new foo - ' - - test_expect_success "'ipfs object links' gives the correct results" ' - echo "$EMPTY_DIR" 4 foo > expected && - ipfs object links "$OUTPUT" > actual && - test_cmp expected actual - ' - test_expect_success "'ipfs object patch add-link' should work with paths" ' - EMPTY_DIR=$(ipfs object new unixfs-dir) && - N1=$(ipfs object patch $EMPTY_DIR add-link baz $EMPTY_DIR) && - N2=$(ipfs object patch $EMPTY_DIR add-link bar $N1) && - N3=$(ipfs object patch $EMPTY_DIR add-link foo /ipfs/$N2/bar) && - ipfs object stat /ipfs/$N3 > /dev/null && - ipfs object stat $N3/foo > /dev/null && - ipfs object stat /ipfs/$N3/foo/baz > /dev/null + N1=$(ipfs object patch $EMPTY_UNIXFS_DIR add-link baz $EMPTY_UNIXFS_DIR) && + N2=$(ipfs object patch $EMPTY_UNIXFS_DIR add-link bar $N1) && + N3=$(ipfs object patch $EMPTY_UNIXFS_DIR add-link foo /ipfs/$N2/bar) && + ipfs dag stat /ipfs/$N3 > /dev/null && + ipfs dag stat $N3/foo > /dev/null && + ipfs dag stat /ipfs/$N3/foo/baz > /dev/null ' test_expect_success "'ipfs object patch add-link' allow linking IPLD objects" ' - EMPTY_DIR=$(ipfs object new unixfs-dir) && OBJ=$(echo "123" | ipfs dag put) && - N1=$(ipfs object patch $EMPTY_DIR add-link foo $OBJ) && + N1=$(ipfs object patch $EMPTY_UNIXFS_DIR add-link foo $OBJ) && - ipfs object stat /ipfs/$N1 > /dev/null && + ipfs dag stat /ipfs/$N1 > /dev/null && ipfs resolve /ipfs/$N1/foo > actual && echo /ipfs/$OBJ > expected && @@ -274,7 +79,7 @@ test_object_cmd() { ' test_expect_success "object patch creation looks right" ' - echo "QmPc73aWK9dgFBXe86P4PvQizHo9e5Qt7n7DAMXWuigFuG" > hash_exp && + echo "bafybeiakusqwohnt7bs75kx6jhmt4oi47l634bmudxfv4qxhpco6xuvgna" > hash_exp && echo $N3 > hash_actual && test_cmp hash_exp hash_actual ' @@ -282,7 +87,7 @@ test_object_cmd() { test_expect_success "multilayer ipfs patch works" ' echo "hello world" > hwfile && FILE=$(ipfs add -q hwfile) && - EMPTY=$(ipfs object new unixfs-dir) && + EMPTY=$EMPTY_UNIXFS_DIR && ONE=$(ipfs object patch $EMPTY add-link b $EMPTY) && TWO=$(ipfs object patch $EMPTY add-link a $ONE) && ipfs object patch $TWO add-link a/b/c $FILE > multi_patch @@ -293,49 +98,12 @@ test_object_cmd() { test_cmp hwfile hwfile_out ' - test_expect_success "ipfs object stat path succeeds" ' - ipfs object stat $(cat multi_patch)/a > obj_stat_out - ' - - test_expect_success "ipfs object stat output looks good" ' - echo "NumLinks: 1" > obj_stat_exp && - echo "BlockSize: 47" >> obj_stat_exp && - echo "LinksSize: 45" >> obj_stat_exp && - echo "DataSize: 2" >> obj_stat_exp && - echo "CumulativeSize: 114" >> obj_stat_exp && - - test_cmp obj_stat_exp obj_stat_out - ' - - test_expect_success "'ipfs object stat --human' succeeds" ' - ipfs object stat $(cat multi_patch)/a --human > obj_stat_human_out - ' - - test_expect_success "ipfs object stat --human output looks good" ' - echo "NumLinks: 1" > obj_stat_human_exp && - echo "BlockSize: 47" >> obj_stat_human_exp && - echo "LinksSize: 45" >> obj_stat_human_exp && - echo "DataSize: 2" >> obj_stat_human_exp && - echo "CumulativeSize: 114 B" >> obj_stat_human_exp && - - test_cmp obj_stat_human_exp obj_stat_human_out - ' - - test_expect_success "should have created dir within a dir" ' - ipfs ls $OUTPUT > patched_output - ' - - test_expect_success "output looks good" ' - echo "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn - foo/" > patched_exp && - test_cmp patched_exp patched_output - ' - test_expect_success "can remove the directory" ' ipfs object patch $OUTPUT rm-link foo > rmlink_output ' test_expect_success "output should be empty" ' - echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn > rmlink_exp && + echo bafybeiczsscdsbs7ffqz55asqdf3smv6klcw3gofszvwlyarci47bgf354 > rmlink_exp && test_cmp rmlink_exp rmlink_output ' @@ -344,7 +112,7 @@ test_object_cmd() { ' test_expect_success "output looks good" ' - echo "QmZD3r9cZjzU8huNY2JS9TC6n8daDfT8TmE8zBSqG31Wvq" > multi_link_rm_exp && + echo "bafybeicourxysmtbe5hacxqico4d5hyvh7gqkrwlmqa4ew7zufn3pj3juu" > multi_link_rm_exp && test_cmp multi_link_rm_exp multi_link_rm_out ' @@ -355,7 +123,7 @@ test_object_cmd() { test_patch_create_path $EMPTY a/b/b/b/b $FILE test_expect_success "can create blank object" ' - BLANK=$(ipfs object new) + BLANK=$EMPTY_DIR ' test_patch_create_path $BLANK a $FILE @@ -363,98 +131,6 @@ test_object_cmd() { test_expect_success "create bad path fails" ' test_must_fail ipfs object patch $EMPTY add-link --create / $FILE ' - - test_expect_success "patch set-data works" ' - EMPTY=$(ipfs object new) && - HASH=$(printf "foo" | ipfs object patch $EMPTY set-data) - ' - - test_expect_success "output looks good" ' - echo "{\"Links\":[],\"Data\":\"foo\"}" > exp_data_set && - ipfs object get $HASH > actual_data_set && - test_cmp exp_data_set actual_data_set - ' - - test_expect_success "patch append-data works" ' - HASH=$(printf "bar" | ipfs object patch $HASH append-data) - ' - - test_expect_success "output looks good" ' - echo "{\"Links\":[],\"Data\":\"foobar\"}" > exp_data_append && - ipfs object get $HASH > actual_data_append && - test_cmp exp_data_append actual_data_append - ' - - # - # CidBase Tests - # - - test_expect_success "'ipfs object put file.json --cid-base=base32' succeeds" ' - ipfs object put --cid-base=base32 ../t0051-object-data/testPut.json > actual_putOut - ' - - test_expect_success "'ipfs object put file.json --cid-base=base32' output looks good" ' - HASH="QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD" && - printf "added $HASH\n" > expected_putOut && - test_cmp expected_putOut actual_putOut - ' - - test_expect_success "'ipfs object put file.json --cid-base=base32 --upgrade-cidv0-in-output=true' succeeds" ' - ipfs object put --cid-base=base32 --upgrade-cidv0-in-output=true ../t0051-object-data/testPut.json > actual_putOut - ' - - test_expect_success "'ipfs object put file.json --cid-base=base32 --upgrade-cidv0-in-output=true' output looks good" ' - HASH=$(ipfs cid base32 "QmUTSAdDi2xsNkDtLqjFgQDMEn5di3Ab9eqbrt4gaiNbUD") && - printf "added $HASH\n" > expected_putOut && - test_cmp expected_putOut actual_putOut - ' - - test_expect_success "'insert json dag with both CidV0 and CidV1 links'" ' - MIXED=$(ipfs object put ../t0051-object-data/mixed.json -q) && - echo $MIXED - ' - - test_expect_success "ipfs object get then put creates identical object with --cid-base=base32" ' - ipfs object get --cid-base=base32 $MIXED > mixedv2.json && - MIXED2=$(ipfs object put -q mixedv2.json) && - echo "$MIXED =? $MIXED2" && - test "$MIXED" = "$MIXED2" - ' - - HASHv0=QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V - HASHv1=bafkqadsimvwgy3zajb2w2yloeefau - - test_expect_success "ipfs object get with --cid-base=base32 uses base32 for CidV1 link only" ' - ipfs object get --cid-base=base32 $MIXED > mixed.actual && - grep -q $HASHv0 mixed.actual && - grep -q $(ipfs cid base32 $HASHv1) mixed.actual - ' - - test_expect_success "ipfs object links --cid-base=base32 --upgrade-cidv0-in-output=true converts both links" ' - ipfs object links --cid-base=base32 --upgrade-cidv0-in-output=true $MIXED | awk "{print \$1}" | sort > links.actual && - echo $(ipfs cid base32 $HASHv1) > links.expected - echo $(ipfs cid base32 $HASHv0) >> links.expected - test_cmp links.actual links.expected - ' -} - -test_object_content_type() { - - test_expect_success "'ipfs object get --encoding=protobuf' returns the correct content type" ' - curl -X POST -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=protobuf" | grep -q "^Content-Type: application/protobuf" - ' - - test_expect_success "'ipfs object get --encoding=json' returns the correct content type" ' - curl -X POST -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=json" | grep -q "^Content-Type: application/json" - ' - - test_expect_success "'ipfs object get --encoding=text' returns the correct content type" ' - curl -X POST -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=text" | grep -q "^Content-Type: text/plain" - ' - - test_expect_success "'ipfs object get --encoding=xml' returns the correct content type" ' - curl -X POST -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=xml" | grep -q "^Content-Type: application/xml" - ' } # should work offline @@ -463,7 +139,6 @@ test_object_cmd # should work online test_launch_ipfs_daemon test_object_cmd -test_object_content_type test_kill_ipfs_daemon test_done diff --git a/test/sharness/t0081-repo-pinning.sh b/test/sharness/t0081-repo-pinning.sh index 030f3fa3d06..92cb71c3858 100755 --- a/test/sharness/t0081-repo-pinning.sh +++ b/test/sharness/t0081-repo-pinning.sh @@ -114,8 +114,8 @@ test_expect_success "objects are there" ' ' # saving this output for later -test_expect_success "ipfs object links $HASH_DIR1 works" ' - ipfs object links $HASH_DIR1 > DIR1_objlink +test_expect_success "ipfs dag get $HASH_DIR1 works" ' + ipfs dag get $HASH_DIR1 | jq -r ".Links[] | .Hash | .[\"/\"]" > DIR1_objlink ' @@ -224,7 +224,7 @@ test_expect_success "some objects are still there" ' ipfs cat "$HASH_FILE1" >>actual8 && ipfs ls "$HASH_DIR4" >>actual8 && ipfs ls "$HASH_DIR2" >>actual8 && - ipfs object links "$HASH_DIR1" >>actual8 && + ipfs dag get "$HASH_DIR1" | jq -r ".Links[] | .Hash | .[\"/\"]" >>actual8 && test_cmp expected8 actual8 ' diff --git a/test/sharness/t0090-get.sh b/test/sharness/t0090-get.sh index 67fee89093a..6a803080e85 100755 --- a/test/sharness/t0090-get.sh +++ b/test/sharness/t0090-get.sh @@ -157,13 +157,13 @@ test_get_cmd() { test_get_fail() { test_expect_success "create an object that has unresolvable links" ' cat <<-\EOF >bad_object && -{ "Links": [ { "Name": "foo", "Hash": "QmZzaC6ydNXiR65W8VjGA73ET9MZ6VFAqUT1ngYMXcpihn", "Size": 1897 }, { "Name": "bar", "Hash": "Qmd4mG6pDFDmDTn6p3hX1srP8qTbkyXKj5yjpEsiHDX3u8", "Size": 56 }, { "Name": "baz", "Hash": "QmUTjwRnG28dSrFFVTYgbr6LiDLsBmRr2SaUSTGheK2YqG", "Size": 24266 } ], "Data": "\b\u0001" } +{"Data":{"/":{"bytes":"CAE"}},"Links":[{"Hash":{"/":"Qmd4mG6pDFDmDTn6p3hX1srP8qTbkyXKj5yjpEsiHDX3u8"},"Name":"bar","Tsize":56},{"Hash":{"/":"QmUTjwRnG28dSrFFVTYgbr6LiDLsBmRr2SaUSTGheK2YqG"},"Name":"baz","Tsize":24266},{"Hash":{"/":"QmZzaC6ydNXiR65W8VjGA73ET9MZ6VFAqUT1ngYMXcpihn"},"Name":"foo","Tsize":1897}]} EOF - cat bad_object | ipfs object put > put_out + cat bad_object | ipfs dag put --store-codec dag-pb > put_out ' test_expect_success "output looks good" ' - echo "added QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr" > put_exp && + echo "bafybeifrjjol3gixedca6etdwccnvwfvhurc4wb3i5mnk2rvwvyfcgwxd4" > put_exp && test_cmp put_exp put_out ' diff --git a/test/sharness/t0112-gateway-cors.sh b/test/sharness/t0112-gateway-cors.sh index 37027c188a4..90813ad6a21 100755 --- a/test/sharness/t0112-gateway-cors.sh +++ b/test/sharness/t0112-gateway-cors.sh @@ -127,70 +127,6 @@ test_expect_success "Access-Control-Allow-Origin replaces the implicit list" ' test_should_contain "< Access-Control-Allow-Origin: localhost" curl_output ' -# Read-Only /api/v0 RPC API (legacy subset, exposed on the Gateway Port) -# TODO: we want to remove it, but for now this guards the legacy behavior to not go any further - -# also check this, as due to legacy reasons Kubo exposes small subset of /api/v0 on GW port -test_expect_success "Assert the default API.HTTPHeaders config is empty" ' - echo "{}" > expected && - ipfs config --json API.HTTPHeaders > actual && - test_cmp expected actual -' - -# HTTP GET Request -test_expect_success "Default CORS GET to {gw}/api/v0" ' - curl -svX GET -H "Origin: https://example.com" "http://127.0.0.1:$GWAY_PORT/api/v0/cat?arg=$thash" >/dev/null 2>curl_output -' -# HTTP 403 is returned because Kubo has additional protections on top of regular CORS, -# namely it only allows browser requests with localhost Origin header. -test_expect_success "Default CORS GET response from {gw}/api/v0 is 403 Forbidden and has regular CORS headers" ' - test_should_contain "HTTP/1.1 403 Forbidden" curl_output && - test_should_contain "< Access-Control-" curl_output -' - -# HTTP OPTIONS Request -test_expect_success "Default OPTIONS to {gw}/api/v0" ' - curl -svX OPTIONS -H "Origin: https://example.com" "http://127.0.0.1:$GWAY_PORT/api/v0/cat?arg=$thash" 2>curl_output -' -# OPTIONS Response from the API should NOT contain CORS headers -test_expect_success "OPTIONS response from {gw}/api/v0 has CORS headers" ' - test_should_contain "< Access-Control-" curl_output -' - -test_kill_ipfs_daemon - -# TODO: /api/v0 with CORS headers set in API.HTTPHeaders does not really work, -# as not all headers are correctly set. Below is only a basic regression test that documents -# current state. Fixing CORS on /api/v0 (RPC and Gateway port) is tracked in https://github.com/ipfs/kubo/issues/7667 - -test_expect_success "Manually set API.HTTPHeaders config to be as relaxed as Gateway.HTTPHeaders" " - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '[\"https://example.com\"]' -" -# TODO: ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '[\"GET\",\"POST\"]' && -# TODO: ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers '[\"X-Requested-With\", \"Range\", \"User-Agent\"]' - -test_launch_ipfs_daemon - -# HTTP GET Request -test_expect_success "Manually relaxed CORS GET to {gw}/api/v0" ' - curl -svX GET -H "Origin: https://example.com" "http://127.0.0.1:$GWAY_PORT/api/v0/cat?arg=$thash" >/dev/null 2>curl_output -' -test_expect_success "Manually relaxed CORS GET response from {gw}/api/v0 is the same as Gateway" ' - test_should_contain "HTTP/1.1 200 OK" curl_output && - test_should_contain "< Access-Control-Allow-Origin: https://example.com" curl_output -' -# TODO: test_should_contain "< Access-Control-Allow-Methods: GET" curl_output - -# HTTP OPTIONS Request -test_expect_success "Manually relaxed OPTIONS to {gw}/api/v0" ' - curl -svX OPTIONS -H "Origin: https://example.com" "http://127.0.0.1:$GWAY_PORT/api/v0/cat?arg=$thash" 2>curl_output -' -# OPTIONS Response from the API should NOT contain CORS headers -test_expect_success "Manually relaxed OPTIONS response from {gw}/api/v0 is the same as Gateway" ' - test_should_contain "< Access-Control-Allow-Origin: https://example.com" curl_output -' -# TODO: test_should_contain "< Access-Control-Allow-Methods: GET" curl_output - test_kill_ipfs_daemon test_done diff --git a/test/sharness/t0114-gateway-subdomains.sh b/test/sharness/t0114-gateway-subdomains.sh index 2596bb49254..5d9927d8e46 100755 --- a/test/sharness/t0114-gateway-subdomains.sh +++ b/test/sharness/t0114-gateway-subdomains.sh @@ -203,25 +203,6 @@ test_localhost_gateway_response_should_contain \ # end Kubo specific end-to-end test -# API on localhost subdomain gateway - -# /api/v0 present on the root hostname -test_localhost_gateway_response_should_contain \ - "request for localhost/api" \ - "http://localhost:$GWAY_PORT/api/v0/refs?arg=${DIR_CID}&r=true" \ - "Ref" - -# /api/v0 not mounted on content root subdomains -test_localhost_gateway_response_should_contain \ - "request for {cid}.ipfs.localhost/api returns data if present on the content root" \ - "http://${DIR_CID}.ipfs.localhost:$GWAY_PORT/api/file.txt" \ - "I am a txt file" - -test_localhost_gateway_response_should_contain \ - "request for {cid}.ipfs.localhost/api/v0/refs returns 404" \ - "http://${DIR_CID}.ipfs.localhost:$GWAY_PORT/api/v0/refs?arg=${DIR_CID}&r=true" \ - "404 Not Found" - ## ============================================================================ ## Test subdomain-based requests to a local gateway with default config ## (origin per content root at http://*.localhost) @@ -308,14 +289,6 @@ test_localhost_gateway_response_should_contain \ "http://$DNSLINK_FQDN.ipns.localhost:$GWAY_PORT" \ "$CID_VAL" -# api.localhost/api - -# Note: we use DIR_CID so refs -r returns some CIDs for child nodes -test_localhost_gateway_response_should_contain \ - "request for api.localhost returns API response" \ - "http://api.localhost:$GWAY_PORT/api/v0/refs?arg=$DIR_CID&r=true" \ - "Ref" - ## ============================================================================ ## Test DNSLink inlining on HTTP gateways ## ============================================================================ @@ -518,54 +491,6 @@ test_hostname_gateway_response_should_contain \ "http://127.0.0.1:$GWAY_PORT" \ "Location: http://${ED25519_IPNS_IDv1}.ipns.example.com/" -# API on subdomain gateway example.com -# ============================================================================ - -# present at the root domain -test_hostname_gateway_response_should_contain \ - "request for example.com/api/v0/refs returns expected payload when /api is on Paths whitelist" \ - "example.com" \ - "http://127.0.0.1:$GWAY_PORT/api/v0/refs?arg=${DIR_CID}&r=true" \ - "Ref" - -# not mounted on content root subdomains -test_hostname_gateway_response_should_contain \ - "request for {cid}.ipfs.example.com/api returns data if present on the content root" \ - "$DIR_CID.ipfs.example.com" \ - "http://127.0.0.1:$GWAY_PORT/api/file.txt" \ - "I am a txt file" - -test_hostname_gateway_response_should_contain \ - "request for {cid}.ipfs.example.com/api/v0/refs returns 404" \ - "$CIDv1.ipfs.example.com" \ - "http://127.0.0.1:$GWAY_PORT/api/v0/refs?arg=${DIR_CID}&r=true" \ - "404 Not Found" - -# disable /api on example.com -ipfs config --json Gateway.PublicGateways '{ - "example.com": { - "UseSubdomains": true, - "Paths": ["/ipfs", "/ipns"] - } -}' || exit 1 -# restart daemon to apply config changes -test_kill_ipfs_daemon -test_launch_ipfs_daemon_without_network - -# not mounted at the root domain -test_hostname_gateway_response_should_contain \ - "request for example.com/api/v0/refs returns 404 if /api not on Paths whitelist" \ - "example.com" \ - "http://127.0.0.1:$GWAY_PORT/api/v0/refs?arg=${DIR_CID}&r=true" \ - "404 Not Found" - -# not mounted on content root subdomains -test_hostname_gateway_response_should_contain \ - "request for {cid}.ipfs.example.com/api returns data if present on the content root" \ - "$DIR_CID.ipfs.example.com" \ - "http://127.0.0.1:$GWAY_PORT/api/file.txt" \ - "I am a txt file" - # DNSLink: .ipns.example.com # (not really useful outside of localhost, as setting TLS for more than one # level of wildcard is a pain, but we support it if someone really wants it) diff --git a/test/sharness/t0119-prometheus.sh b/test/sharness/t0119-prometheus.sh index 0e00f088ac2..fef204e2312 100755 --- a/test/sharness/t0119-prometheus.sh +++ b/test/sharness/t0119-prometheus.sh @@ -33,7 +33,7 @@ test_expect_success "make sure metrics haven't changed" ' # Check what was added by enabling ResourceMgr.Enabled # # NOTE: we won't see all the dynamic ones, but that is ok: the point of the -# test here is to detect regression when rcmgr metrics dissapear due to +# test here is to detect regression when rcmgr metrics disappear due to # refactor/human error. test_expect_success "enable ResourceMgr in the config" ' diff --git a/test/sharness/t0131-multinode-client-routing.sh b/test/sharness/t0131-multinode-client-routing.sh index b62c9790b9c..8949a1bdfd8 100755 --- a/test/sharness/t0131-multinode-client-routing.sh +++ b/test/sharness/t0131-multinode-client-routing.sh @@ -43,7 +43,8 @@ run_single_file_test() { NNODES=10 test_expect_success "set up testbed" ' - iptb testbed create -type localipfs -count $NNODES -force -init + iptb testbed create -type localipfs -count $NNODES -force -init && + iptb run -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true ' test_expect_success "start up nodes" ' diff --git a/test/sharness/t0142-testfilter.sh b/test/sharness/t0142-testfilter.sh index 971aa68397a..bdd7e4f76b1 100755 --- a/test/sharness/t0142-testfilter.sh +++ b/test/sharness/t0142-testfilter.sh @@ -13,7 +13,8 @@ AF="/ip4/127.0.0.0/ipcidr/24" NUM_NODES=3 test_expect_success "set up testbed" ' - iptb testbed create -type localipfs -count $NUM_NODES -force -init + iptb testbed create -type localipfs -count $NUM_NODES -force -init && + iptb run -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true ' test_expect_success 'filter 127.0.0.0/24 on node 1' ' diff --git a/test/sharness/t0175-provider.sh b/test/sharness/t0175-provider.sh deleted file mode 100755 index cca110fe101..00000000000 --- a/test/sharness/t0175-provider.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -test_description="Test reprovider" - -. lib/test-lib.sh - -NUM_NODES=2 - -test_expect_success 'init iptb' ' - iptb testbed create -type localipfs -force -count $NUM_NODES -init -' - -test_expect_success 'peer ids' ' - PEERID_0=$(iptb attr get 0 id) && - PEERID_1=$(iptb attr get 1 id) -' - -test_expect_success 'use strategic providing' ' - iptb run -- ipfs config --json Experimental.StrategicProviding false -' - -startup_cluster ${NUM_NODES} - -test_expect_success 'add test object' ' - HASH_0=$(date +"%FT%T.%N%z" | ipfsi 0 add -q) -' - -findprovs_expect '$HASH_0' '$PEERID_0' - -test_expect_success 'stop node 1' ' - iptb stop -' - -test_done diff --git a/test/sharness/t0175-reprovider.sh b/test/sharness/t0175-reprovider.sh deleted file mode 100755 index 09535ecc4f5..00000000000 --- a/test/sharness/t0175-reprovider.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env bash - -test_description="Test reprovider" - -. lib/test-lib.sh - -NUM_NODES=6 - -init_strategy() { - test_expect_success 'init iptb' ' - iptb testbed create -type localipfs -force -count $NUM_NODES -init - ' - - test_expect_success 'peer ids' ' - PEERID_0=$(iptb attr get 0 id) && - PEERID_1=$(iptb attr get 1 id) - ' - - test_expect_success 'use pinning strategy for reprovider' ' - ipfsi 0 config Reprovider.Strategy '$1' - ' - - startup_cluster ${NUM_NODES} -} - -reprovide() { - test_expect_success 'reprovide' ' - # TODO: this hangs, though only after reprovision was done - ipfsi 0 bitswap reprovide - ' -} - -# Test 'all' strategy -init_strategy 'all' - -test_expect_success 'add test object' ' - HASH_0=$(date +"%FT%T.%N%z" | ipfsi 0 add -q --local) -' - -findprovs_empty '$HASH_0' -reprovide -findprovs_expect '$HASH_0' '$PEERID_0' - -test_expect_success 'Stop iptb' ' - iptb stop -' - -# Test 'pinned' strategy -init_strategy 'pinned' - -test_expect_success 'prepare test files' ' - date +"%FT%T.%N%z" > f1 && - date +"%FT%T.%N%z" > f2 -' - -test_expect_success 'add test objects' ' - HASH_FOO=$(ipfsi 0 add -q --offline --pin=false f1) && - HASH_BAR=$(ipfsi 0 add -q --offline --pin=false f2) && - HASH_BAR_DIR=$(ipfsi 0 add -q --offline -w f2) -' - -findprovs_empty '$HASH_FOO' -findprovs_empty '$HASH_BAR' -findprovs_empty '$HASH_BAR_DIR' - -reprovide - -findprovs_empty '$HASH_FOO' -findprovs_expect '$HASH_BAR' '$PEERID_0' -findprovs_expect '$HASH_BAR_DIR' '$PEERID_0' - -test_expect_success 'Stop iptb' ' - iptb stop -' - -# Test 'roots' strategy -init_strategy 'roots' - -test_expect_success 'prepare test files' ' - date +"%FT%T.%N%z" > f1 && - date +"%FT%T.%N%z" > f2 && - date +"%FT%T.%N%z" > f3 -' - -test_expect_success 'add test objects' ' - HASH_FOO=$(ipfsi 0 add -q --offline --pin=false f1) && - HASH_BAR=$(ipfsi 0 add -q --offline --pin=false f2) && - HASH_BAZ=$(ipfsi 0 add -q --offline f3) && - HASH_BAR_DIR=$(ipfsi 0 add -Q --offline -w f2) -' - -findprovs_empty '$HASH_FOO' -findprovs_empty '$HASH_BAR' -findprovs_empty '$HASH_BAR_DIR' - -reprovide - -findprovs_empty '$HASH_FOO' -findprovs_empty '$HASH_BAR' -findprovs_expect '$HASH_BAZ' '$PEERID_0' -findprovs_expect '$HASH_BAR_DIR' '$PEERID_0' - -test_expect_success 'Stop iptb' ' - iptb stop -' - -# Test reprovider working with ticking disabled -test_expect_success 'init iptb' ' - iptb testbed create -type localipfs -force -count $NUM_NODES -init -' - -test_expect_success 'peer ids' ' - PEERID_0=$(iptb attr get 0 id) && - PEERID_1=$(iptb attr get 1 id) -' - -test_expect_success 'Disable reprovider ticking' ' - ipfsi 0 config Reprovider.Interval 0 -' - -startup_cluster ${NUM_NODES} - -test_expect_success 'add test object' ' - HASH_0=$(date +"%FT%T.%N%z" | ipfsi 0 add -q --offline) -' - -findprovs_empty '$HASH_0' -reprovide -findprovs_expect '$HASH_0' '$PEERID_0' - -test_expect_success 'resolve object $HASH_0' ' - HASH_WITH_PREFIX=$(ipfsi 1 resolve $HASH_0) -' -findprovs_expect '$HASH_WITH_PREFIX' '$PEERID_0' - -test_expect_success 'Stop iptb' ' - iptb stop -' - -test_done diff --git a/test/sharness/t0175-strategic-provider.sh b/test/sharness/t0175-strategic-provider.sh deleted file mode 100755 index fafd6e5388c..00000000000 --- a/test/sharness/t0175-strategic-provider.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -test_description="Test reprovider" - -. lib/test-lib.sh - -NUM_NODES=2 - -test_expect_success 'init iptb' ' - iptb testbed create -type localipfs -force -count $NUM_NODES -init -' - -test_expect_success 'peer ids' ' - PEERID_0=$(iptb attr get 0 id) && - PEERID_1=$(iptb attr get 1 id) -' - -test_expect_success 'use strategic providing' ' - iptb run -- ipfs config --json Experimental.StrategicProviding true -' - -startup_cluster ${NUM_NODES} - -test_expect_success 'add test object' ' - HASH_0=$(date +"%FT%T.%N%z" | ipfsi 0 add -q) -' - -findprovs_empty '$HASH_0' - -test_expect_success 'stop node 1' ' - iptb stop -' - -test_done diff --git a/test/sharness/t0181-private-network.sh b/test/sharness/t0181-private-network.sh index 86c6151d3e4..46dc45cdf3c 100755 --- a/test/sharness/t0181-private-network.sh +++ b/test/sharness/t0181-private-network.sh @@ -35,6 +35,7 @@ LIBP2P_FORCE_PNET=1 test_launch_ipfs_daemon test_expect_success "set up iptb testbed" ' iptb testbed create -type localipfs -count 5 -force -init && + iptb run -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true && iptb run -- ipfs config --json Addresses.Swarm '"'"'["/ip4/127.0.0.1/tcp/0"]'"'"' ' diff --git a/test/sharness/t0182-circuit-relay.sh b/test/sharness/t0182-circuit-relay.sh index d6e439ae318..c79edfc8ea8 100755 --- a/test/sharness/t0182-circuit-relay.sh +++ b/test/sharness/t0182-circuit-relay.sh @@ -7,7 +7,8 @@ test_description="Test circuit relay" # start iptb + wait for peering NUM_NODES=3 test_expect_success 'init iptb' ' - iptb testbed create -type localipfs -count $NUM_NODES -init + iptb testbed create -type localipfs -count $NUM_NODES -init && + iptb run -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true ' # Network toplogy: A <-> Relay <-> B diff --git a/test/sharness/t0184-http-proxy-over-p2p.sh b/test/sharness/t0184-http-proxy-over-p2p.sh index 9c5308277c2..98e2f3ab20c 100755 --- a/test/sharness/t0184-http-proxy-over-p2p.sh +++ b/test/sharness/t0184-http-proxy-over-p2p.sh @@ -142,6 +142,7 @@ function curl_send_multipart_form_request() { test_expect_success 'configure nodes' ' iptb testbed create -type localipfs -count 2 -force -init && + iptb run -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true && ipfsi 0 config --json Experimental.Libp2pStreamMounting true && ipfsi 1 config --json Experimental.Libp2pStreamMounting true && ipfsi 0 config --json Experimental.P2pHttpProxy true && diff --git a/test/sharness/t0252-files-gc.sh b/test/sharness/t0252-files-gc.sh index 7267985d49a..f2eb25b4fcc 100755 --- a/test/sharness/t0252-files-gc.sh +++ b/test/sharness/t0252-files-gc.sh @@ -38,9 +38,9 @@ test_expect_success "gc okay after adding incomplete node -- prep" ' ' test_expect_success "gc okay after adding incomplete node" ' - ipfs object stat $ADIR_HASH && + ipfs dag get $ADIR_HASH && ipfs repo gc && - ipfs object stat $ADIR_HASH + ipfs dag get $ADIR_HASH ' test_expect_success "add directory with direct pin" ' diff --git a/test/sharness/t0276-cidv0v1.sh b/test/sharness/t0276-cidv0v1.sh index 2058a9d5497..c810f45449d 100755 --- a/test/sharness/t0276-cidv0v1.sh +++ b/test/sharness/t0276-cidv0v1.sh @@ -95,7 +95,8 @@ test_expect_success "check that we can access the file when converted to CIDv1" # test_expect_success "set up iptb testbed" ' - iptb testbed create -type localipfs -count 2 -init + iptb testbed create -type localipfs -count 2 -init && + iptb run -- ipfs config --json "Routing.LoopbackAddressesOnLanDHT" true ' test_expect_success "start nodes" ' diff --git a/test/sharness/t0701-delegated-routing-reframe.sh b/test/sharness/t0701-delegated-routing-reframe.sh deleted file mode 100755 index 5070b4fff16..00000000000 --- a/test/sharness/t0701-delegated-routing-reframe.sh +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env bash - -test_description="Test delegated routing via reframe endpoint" - -. lib/test-lib.sh - -if ! test_have_prereq SOCAT; then - skip_all="skipping '$test_description': socat is not available" - test_done -fi - -# simple reframe server mock -# local endpoint responds with deterministic application/vnd.ipfs.rpc+dag-json; version=1 -REFRAME_PORT=5098 -function start_reframe_mock_endpoint() { - REMOTE_SERVER_LOG="reframe-server.log" - rm -f $REMOTE_SERVER_LOG - - touch response - socat tcp-listen:$REFRAME_PORT,fork,bind=127.0.0.1,reuseaddr 'SYSTEM:cat response'!!CREATE:$REMOTE_SERVER_LOG & - REMOTE_SERVER_PID=$! - - socat /dev/null tcp:127.0.0.1:$REFRAME_PORT,retry=10 - return $? -} -function serve_reframe_response() { - local body=$1 - local status_code=${2:-"200 OK"} - local length=$((1 + ${#body})) - echo -e "HTTP/1.1 $status_code\nContent-Type: application/vnd.ipfs.rpc+dag-json; version=1\nContent-Length: $length\n\n$body" > response -} -function stop_reframe_mock_endpoint() { - exec 7<&- - kill $REMOTE_SERVER_PID > /dev/null 2>&1 - wait $REMOTE_SERVER_PID || true -} - -# daemon running in online mode to ensure Pin.origins/PinStatus.delegates work -test_init_ipfs - -# based on static, synthetic reframe messages: -# t0701-delegated-routing-reframe/FindProvidersRequest -# t0701-delegated-routing-reframe/FindProvidersResponse -FINDPROV_CID="bafybeigvgzoolc3drupxhlevdp2ugqcrbcsqfmcek2zxiw5wctk3xjpjwy" -EXPECTED_PROV="QmQzqxhK82kAmKvARFZSkUVS6fo9sySaiogAnx5EnZ6ZmC" - -test_expect_success "default Routing config has no Routers defined" ' - echo null > expected && - ipfs config show | jq .Routing.Routers > actual && - test_cmp expected actual -' - -# turn off all implicit routers -ipfs config Routing.Type none || exit 1 -test_launch_ipfs_daemon -test_expect_success "disabling default router (dht) works" ' - ipfs config Routing.Type > actual && - echo none > expected && - test_cmp expected actual -' -test_expect_success "no routers means findprovs returns no results" ' - ipfs routing findprovs "$FINDPROV_CID" > actual && - echo -n > expected && - test_cmp expected actual -' - -test_kill_ipfs_daemon - -ipfs config Routing.Type --json '"custom"' || exit 1 -ipfs config Routing.Methods --json '{ - "find-peers": { - "RouterName": "TestDelegatedRouter" - }, - "find-providers": { - "RouterName": "TestDelegatedRouter" - }, - "get-ipns": { - "RouterName": "TestDelegatedRouter" - }, - "provide": { - "RouterName": "TestDelegatedRouter" - } - }' || exit 1 - -test_expect_success "missing method params makes daemon fails" ' - echo "Error: constructing the node (see log for full detail): method name \"put-ipns\" is missing from Routing.Methods config param" > expected_error && - GOLOG_LOG_LEVEL=fatal ipfs daemon 2> actual_error || exit 0 && - test_cmp expected_error actual_error -' - -ipfs config Routing.Methods --json '{ - "find-peers": { - "RouterName": "TestDelegatedRouter" - }, - "find-providers": { - "RouterName": "TestDelegatedRouter" - }, - "get-ipns": { - "RouterName": "TestDelegatedRouter" - }, - "provide": { - "RouterName": "TestDelegatedRouter" - }, - "put-ipns": { - "RouterName": "TestDelegatedRouter" - }, - "NOT_SUPPORTED": { - "RouterName": "TestDelegatedRouter" - } - }' || exit 1 - -test_expect_success "having wrong methods makes daemon fails" ' - echo "Error: constructing the node (see log for full detail): method name \"NOT_SUPPORTED\" is not a supported method on Routing.Methods config param" > expected_error && - GOLOG_LOG_LEVEL=fatal ipfs daemon 2> actual_error || exit 0 && - test_cmp expected_error actual_error -' - -# set Routing config to only use delegated routing via mocked reframe endpoint - -ipfs config Routing.Type --json '"custom"' || exit 1 -ipfs config Routing.Routers.TestDelegatedRouter --json '{ - "Type": "reframe", - "Parameters": { - "Endpoint": "http://127.0.0.1:5098/reframe" - } -}' || exit 1 -ipfs config Routing.Methods --json '{ - "find-peers": { - "RouterName": "TestDelegatedRouter" - }, - "find-providers": { - "RouterName": "TestDelegatedRouter" - }, - "get-ipns": { - "RouterName": "TestDelegatedRouter" - }, - "provide": { - "RouterName": "TestDelegatedRouter" - }, - "put-ipns": { - "RouterName": "TestDelegatedRouter" - } - }' || exit 1 - -test_expect_success "adding reframe endpoint to Routing.Routers config works" ' - echo "http://127.0.0.1:5098/reframe" > expected && - ipfs config Routing.Routers.TestDelegatedRouter.Parameters.Endpoint > actual && - test_cmp expected actual -' - -test_launch_ipfs_daemon - -test_expect_success "start_reframe_mock_endpoint" ' - start_reframe_mock_endpoint -' - -test_expect_success "'ipfs routing findprovs' returns result from delegated reframe router" ' - serve_reframe_response "$(<../t0701-delegated-routing-reframe/FindProvidersResponse)" && - echo "$EXPECTED_PROV" > expected && - ipfs routing findprovs "$FINDPROV_CID" > actual && - test_cmp expected actual -' - -test_expect_success "stop_reframe_mock_endpoint" ' - stop_reframe_mock_endpoint -' - - -test_kill_ipfs_daemon -test_done -# vim: ts=2 sw=2 sts=2 et: diff --git a/version.go b/version.go index 3c6d89428d9..29bb0c30e22 100644 --- a/version.go +++ b/version.go @@ -11,7 +11,7 @@ import ( var CurrentCommit string // CurrentVersionNumber is the current application's version literal. -const CurrentVersionNumber = "0.27.0" +const CurrentVersionNumber = "0.28.0" const ApiVersion = "/kubo/" + CurrentVersionNumber + "/" //nolint