Skip to content

Conversation

@hsanjuan
Copy link
Contributor

@hsanjuan hsanjuan commented Sep 5, 2025


This allows Kubo to respond to the GetClosestPeers() http routing v1 endpoint as spec'ed here: ipfs/specs#476

It is based on work from ipfs/boxo#1021

We let IpfsNode implmement the contentRouter.Client interface with the new method. We use our DHTs to get the closest peers. We try to respect the count/closerThan options here. We then trigger FindPeers lookups to fill-in information about the peers (addresses) and return the result.

Tests are missing and will come up once discussions around the spec and the boxo pr have settled.

TODO

@hsanjuan hsanjuan self-assigned this Sep 5, 2025
@hsanjuan hsanjuan force-pushed the feat/get-closest-peers branch from 1d5bc1f to ded09f5 Compare September 5, 2025 13:34
@hsanjuan hsanjuan force-pushed the feat/get-closest-peers branch from ded09f5 to 5d605bc Compare September 26, 2025 12:23
@hsanjuan hsanjuan marked this pull request as ready for review September 26, 2025 13:17
@hsanjuan hsanjuan requested review from a team and lidel as code owners September 26, 2025 13:17
@guillaumemichel guillaumemichel self-requested a review September 26, 2025 13:39
This allows Kubo to respond to the GetClosestPeers() http routing v1 endpoint
as spec'ed here: ipfs/specs#476

It is based on work from ipfs/boxo#1021

We let IpfsNode implmement the contentRouter.Client interface with the new
method.  We use our DHTs to get the closest peers. We try to respect the
count/closerThan options here.  We then trigger FindPeers lookups to fill-in
information about the peers (addresses) and return the result.

Tests are missing and will come up once discussions around the spec and the
boxo pr have settled.
@hsanjuan hsanjuan force-pushed the feat/get-closest-peers branch from 11f924a to e55712a Compare October 16, 2025 09:25
lidel added 2 commits October 17, 2025 22:22
- only query WAN DHT for dual DHT setups (not LAN)
- LAN DHT contains private network peers that should not be exposed via public HTTP Routing API
- preallocate records slice for better performance
- update to boxo v0.35.1-0.20251017171347-325640119338

fixes conflict resolution and aligns with someguy reference implementation
- change Gateway.ExposeRoutingAPI default to true
- enables light clients in browsers to use Kubo Gateway as delegated routing backend
- add v0.39 changelog entry highlighting IPIP-476 support
@lidel lidel changed the title corehttp/routing: wire GetClosestPeers() feat: support GetClosesPeers (IPIP-476) and ExposeRoutingAPI by default Oct 17, 2025
lidel added 3 commits October 17, 2025 23:06
Test GetClosestPeers with all Routing.Type values:
- DHT-based types that support it: auto, autoclient, dht, dhtclient
- Non-DHT types that don't support it: none, delegated, custom

Verify proper error handling when DHT is not available.
kept boxo v0.35.1-0.20251017171347-325640119338 as requested
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm – pushed some changes:

  • clean up the way things are wired up
  • tests for positive and negative scenarios
  • flip config flag to expose /routing/v1 by default on gateway port

I'd like to include this in 0.39, but would be good to have second set of eyes from either @hsanjuan or @guillaumemichel

@lidel lidel requested a review from guillaumemichel October 18, 2025 00:18
Comment on lines +31 to +34
#### Routing V1 HTTP API now exposed by default

The [Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/) is now exposed by default at `http://127.0.0.1:8080/routing/v1`. This allows light clients in browsers to use Kubo Gateway as a delegated routing backend instead of running a full DHT client. Support for [IPIP-476: Delegated Routing DHT Closest Peers API](https://github.com/ipfs/specs/pull/476) is included. Can be disabled via [`Gateway.ExposeRoutingAPI`](https://github.com/ipfs/kubo/blob/master/docs/config.md#gatewayexposeroutingapi).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably thought of this better, but, assuming someone has exposed the gateway listen address already (:8080), doesn't this inadvertently exposes the routing API to the world?

And, if so, how does this interact with certain gateway options... for example NoFetch means the gateway will not trigger lookups nor fetch any content, but now this API would allow for such lookups to be performed, so it seems a door that was closed is being opened. There are also other gateway options that might make similar considerations.

@hsanjuan
Copy link
Contributor Author

Thank you @lidel for completing, just left a couple of comments.

Copy link
Contributor

@guillaumemichel guillaumemichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just 1 comment/question

@hsanjuan
Copy link
Contributor Author

Comments addressed. Updated to master and latest boxo commit.

@hsanjuan hsanjuan enabled auto-merge (squash) November 19, 2025 10:44
@hsanjuan hsanjuan merged commit 73ab037 into master Nov 19, 2025
16 checks passed
@hsanjuan hsanjuan deleted the feat/get-closest-peers branch November 19, 2025 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants