diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cbba94365..ce15b28c15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,12 +16,27 @@ The following emojis are used to highlight certain changes: ### Added -* The `routing/http` client and server now support Delegated IPNS as per [IPIP-379](https://specs.ipfs.tech/ipips/ipip-0379/). +* ✨ The `routing/http` package has received the following additions: + * Supports Delegated IPNS as per [IPIP-379](https://specs.ipfs.tech/ipips/ipip-0379/). + * Supports Delegated Peer Routing as per [IPIP-417](https://github.com/ipfs/specs/pull/417). ### Changed +* 🛠 The `routing/http` package has suffered the following modifications: + * Client `FindProviders` has been renamed to `GetProviders`. Similarly, the + required function names in the server `ContentRouter` have also been updated + for higher consistency with the remaining code and the specifications. + * Many types regarding response types were updated to conform to the updated + Peer Schema discussed in [IPIP-417](https://github.com/ipfs/specs/pull/417). + ### Removed +* 🛠 The `routing/http` package has suffered the following removals: + * Server and client no longer support the `Provide*` methods for content routing. + These methods did not conform to any specification, as it is still being worked + out in [IPIP-378](https://github.com/ipfs/specs/pull/378). + * Server no longer exports `FindProvidersPath` and `ProvidePath`. + ### Fixed ### Security diff --git a/routing/http/README.md b/routing/http/README.md index 65650ed509..0f0281f8f0 100644 --- a/routing/http/README.md +++ b/routing/http/README.md @@ -1,24 +1,9 @@ -go-delegated-routing +Routing V1 Server and Client ======================= -> Delegated routing Client and Server over Reframe RPC - -This package provides delegated routing implementation in Go: -- Client (for IPFS nodes like [Kubo](https://github.com/ipfs/kubo/blob/master/docs/config.md#routingrouters-parameters)), -- Server (for public indexers such as https://cid.contact) +> Delegated Routing V1 Server and Client over HTTP API. ## Documentation -- Go docs: https://pkg.go.dev/github.com/ipfs/boxo/routing/http/ - -## Lead Maintainer - -🦗🎶 - -## Contributing - -Contributions are welcome! This repository is part of the IPFS project and therefore governed by our [contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md). - -## License - -[SPDX-License-Identifier: Apache-2.0 OR MIT](LICENSE.md) \ No newline at end of file +- Go Documentation: https://pkg.go.dev/github.com/ipfs/boxo/routing/http +- Routing V1 Specification: https://specs.ipfs.tech/routing/http-routing-v1/ diff --git a/routing/http/contentrouter/contentrouter.go b/routing/http/contentrouter/contentrouter.go index 2a06f1012f..137e95c363 100644 --- a/routing/http/contentrouter/contentrouter.go +++ b/routing/http/contentrouter/contentrouter.go @@ -15,7 +15,7 @@ import ( "github.com/multiformats/go-multihash" ) -var logger = logging.Logger("service/contentrouting") +var logger = logging.Logger("routing/http/contentrouter") type Client interface { GetProviders(ctx context.Context, key cid.Cid) (iter.ResultIter[types.Record], error) diff --git a/routing/http/contentrouter/contentrouter_test.go b/routing/http/contentrouter/contentrouter_test.go index 2cb1d79077..ebd614710b 100644 --- a/routing/http/contentrouter/contentrouter_test.go +++ b/routing/http/contentrouter/contentrouter_test.go @@ -57,9 +57,9 @@ func TestGetProvidersAsync(t *testing.T) { ID: &p2, Protocols: []string{"transport-bitswap"}, }, - // &types.UnknownRecord{ - // Protocol: "UNKNOWN", - // }, + &types.UnknownRecord{ + Schema: "UNKNOWN", + }, } aisIter := iter.ToResultIter[types.Record](iter.FromSlice(ais)) diff --git a/routing/http/server/server.go b/routing/http/server/server.go index 93878bd0d4..7737fecf1a 100644 --- a/routing/http/server/server.go +++ b/routing/http/server/server.go @@ -34,12 +34,12 @@ const ( DefaultStreamingRecordsLimit = 0 ) -var logger = logging.Logger("service/server/delegatedrouting") +var logger = logging.Logger("routing/http/server") const ( - GetProvidersPath = "/routing/v1/providers/{cid}" - GetPeersPath = "/routing/v1/peers/{peer-id}" - GetIPNSRecordPath = "/routing/v1/ipns/{cid}" + getProvidersPath = "/routing/v1/providers/{cid}" + getPeersPath = "/routing/v1/peers/{peer-id}" + getIPNSRecordPath = "/routing/v1/ipns/{cid}" ) type GetProvidersAsyncResponse struct { @@ -50,7 +50,7 @@ type GetProvidersAsyncResponse struct { type ContentRouter interface { // GetProviders searches for peers who are able to provide the given [cid.Cid]. // Limit indicates the maximum amount of results to return; 0 means unbounded. - GetProviders(ctx context.Context, key cid.Cid, limit int) (iter.ResultIter[types.Record], error) + GetProviders(ctx context.Context, cid cid.Cid, limit int) (iter.ResultIter[types.Record], error) // GetPeers searches for peers who have the provided [peer.ID]. // Limit indicates the maximum amount of results to return; 0 means unbounded. @@ -74,7 +74,8 @@ func WithStreamingResultsDisabled() Option { } // WithRecordsLimit sets a limit that will be passed to [ContentRouter.GetProviders] -// for non-streaming requests (application/json). Default is [DefaultRecordsLimit]. +// and [ContentRouter.GetPeers] for non-streaming requests (application/json). +// Default is [DefaultRecordsLimit]. func WithRecordsLimit(limit int) Option { return func(s *server) { s.recordsLimit = limit @@ -82,7 +83,8 @@ func WithRecordsLimit(limit int) Option { } // WithStreamingRecordsLimit sets a limit that will be passed to [ContentRouter.GetProviders] -// for streaming requests (application/x-ndjson). Default is [DefaultStreamingRecordsLimit]. +// and [ContentRouter.GetPeers] for streaming requests (application/x-ndjson). +// Default is [DefaultStreamingRecordsLimit]. func WithStreamingRecordsLimit(limit int) Option { return func(s *server) { s.streamingRecordsLimit = limit @@ -101,11 +103,10 @@ func Handler(svc ContentRouter, opts ...Option) http.Handler { } r := mux.NewRouter() - r.HandleFunc(GetProvidersPath, server.getProviders).Methods(http.MethodGet) - r.HandleFunc(GetPeersPath, server.getPeers).Methods(http.MethodGet) - r.HandleFunc(GetIPNSRecordPath, server.getIPNSRecord).Methods(http.MethodGet) - r.HandleFunc(GetIPNSRecordPath, server.putIPNSRecord).Methods(http.MethodPut) - + r.HandleFunc(getProvidersPath, server.getProviders).Methods(http.MethodGet) + r.HandleFunc(getPeersPath, server.getPeers).Methods(http.MethodGet) + r.HandleFunc(getIPNSRecordPath, server.getIPNSRecord).Methods(http.MethodGet) + r.HandleFunc(getIPNSRecordPath, server.putIPNSRecord).Methods(http.MethodPut) return r }