ipfs / js-ipfs

IPFS implementation in JavaScript
https://js.ipfs.tech
Other
7.43k stars 1.25k forks source link

/dnsaddr support in bootstrap and swarm connect #2289

Closed lidel closed 1 year ago

lidel commented 5 years ago

Type: Feature

Severity: Medium

Motivation

/dnsaddr is like DNSLink, but for multiaddrs. It is a way of having static peer multiaddrs that do not hardcode PeerID and can point at multiple multiaddrs:

It is already supported by go-ipfs (https://github.com/ipfs/go-ipfs/issues/5522) and feels like "magic" mentioned in https://github.com/ipfs/js-ipfs/issues/1459 In js-ipfs, it could be used in default multiaddrs for things like dns-based bootstrap nodes or preload / delegate nodes, enabling us to scale transparently by adding more multiaddrs without the need for shipping patch release or changing client configs.

Problem

Steps to reproduce:

bootstrap.libp2p.io has dnsaddr records with port and peerid:

$ dig +short _dnsaddr.bootstrap.libp2p.io txt
"dnsaddr=/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd"
"dnsaddr=/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd"

Try connecting to peer via dnsaddr:

$ jsipfs swarm connect /dnsaddr/bootstrap.libp2p.io
peer multiaddr instance or string must include peerId

Expected:

$ ipfs swarm connect /dnsaddr/bootstrap.libp2p.io
connect QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd success

In case dnsaddr disappears from bootstrap.libp2p.io, alternative hostname for testing: ipfs.aergia.eu

GavinDmello commented 5 years ago

@alanshaw @lidel Can I work on this ?

lidel commented 5 years ago

@GavinDmello would be awesome, give it a try!

Check if we could add generic support for "resolving" multiaddrs in js-multiaddr/dnsaddr is an example of that. Check discussion at https://github.com/multiformats/js-multiaddr/issues/94

GavinDmello commented 5 years ago

@lidel Thank you for the direction.

I was planning on adding handling directly in this repository and reusing the the dns objects in the core components.

I'll try asking on https://github.com/multiformats/js-multiaddr/issues/94 if anyone has started working on adding support.

Edit: I see @hacdias is going to be working on adding support for it. I'll use his work once he is done.

SgtPooki commented 1 year ago

js-ipfs is being deprecated in favor of Helia. You can learn more about this deprecation and read the migration guide.

Please feel to reopen with any comments by 2023-06-02. We will do a final pass on reopened issues afterwards (see https://github.com/ipfs/js-ipfs/issues/4336).

This issue is most likely resolved in Helia, please try it out!