How to interpret multiaddr?

How are multiaddr supposed to be interpreted?

When I see /ip4/, I interpret this as an ipv4 address that can be connected to using tcp via port 80.

But what about something like this /dnsaddr/

Also does the specification specify the order? for example is /ip4/ as valid as /tcp/80/ip4/ ?

I really could not find any information that expounds on the specification. Unfortunately. the specification section on Github here is very scanty.

You read them left to right and each protocol stack on the previous ones.

That correct.

Not that I know of, because that would require a full description of all protocols, it’s up to implementations.

But think about what such protocol would be, it would be IP running over TCP.
Which doesn’t make any sense, TCP use IP in the first place, you can’t just use TCP on it’s own.
And IP can’t be tunneled in a TCP stream like that, you need various PTP protocols which handle wrapping the IP packets.

First /p2p, this is the public key field, it will contain a hash or the raw public key if it’s small enough (RSA would be a hash, ECC is embeded)

/dnsaddr is a special one.
So dnsaddr stores the actual address in TXT records, so you query

$ dig -t TXT 324 IN	TXT	"dnsaddr=/dnsaddr/" 324 IN	TXT	"dnsaddr=/dnsaddr/" 324 IN	TXT	"dnsaddr=/dnsaddr/" 324 IN	TXT	"dnsaddr=/dnsaddr/" 324 IN	TXT	"dnsaddr=/dnsaddr/" 324 IN	TXT	"dnsaddr=/dnsaddr/

As you can see we have many different addresses however they all include the /p2p field, the rule is we have to pick the one matching the outer address (QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt we seen earlier).
Which is:


Then since we have an other dnsaddr address we just repeat this process:

$ dig -t TXT 600	IN TXT	"dnsaddr=/ip4/" 600	IN TXT	"dnsaddr=/ip4/" 600	IN TXT	"dnsaddr=/ip6/2604:1380:3000:1f00::1/tcp/4001/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt" 600	IN TXT	"dnsaddr=/ip6/2604:1380:3000:1f00::1/udp/4001/quic/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt" 600	IN TXT	"dnsaddr=/dns4/" 600	IN TXT	"dnsaddr=/dns6/"

This time we have many different addresses matching, but hopefully this should be clear enough by now, you just expand with all of them that match the public key.

Oh also the dns4 and dns6 do A and AAAA resolutions instead of TXT, and expand the results with corresponding ip4 and ip6 blocks.

1 Like