// gives you an object that is friendly with what Node.js core modules expect for addresses addr.nodeAddress() // { // family: 4, // port: 1234, // address: "127.0.0.1" // }
constprotocol: ProtocolCodec = { code:2059, name:'custom-protocol', size:V // V means variable length, can also be 0, a positive integer (e.g. a fixed // length or omitted }
registry.addProtocol(protocol)
// does not throw UnknownProtocolError multiaddr(maWithCustomTuple)
// protocols can also be removed registry.removeProtocol(protocol.code)
A standard way to represent addresses that
Example
Resolving DNSADDR addresses
DNSADDR is a spec that allows storing a TXT DNS record that contains a Multiaddr.
To resolve DNSADDR addresses, call the
.resolve()
function the multiaddr, optionally passing aDNS
resolver.DNSADDR addresses can resolve to multiple multiaddrs, since there is no limit to the number of TXT records that can be stored.
Example: Resolving DNSADDR Multiaddrs
Example: Using a custom DNS resolver to resolve DNSADDR Multiaddrs
See the docs for @multiformats/dns for a full breakdown of how to specify multiple resolvers or resolvers that can be used for specific TLDs.
Example: Adding custom protocols
To add application-specific or experimental protocols, add a protocol codec to the protocol registry: