jbenet / random-ideas

random ideas
juan.benet.ai
324 stars 12 forks source link

JRFC 28 - note on DNS and the Web #28

Open jbenet opened 9 years ago

jbenet commented 9 years ago

(Originally posted at https://gist.github.com/jbenet/ca4f31dfbaec7c8ce9a8)

note on DNS and the Web

DISCLAIMER: I have not done any review of other systems that already do this. I'm sure there are many, as this is a trivial extension. Further disclaimer: I also dislike DNS, and this note should not be taken to mean otherwise.

DNS is used mostly to map names to IP Addresses and other protocol-specific resources. IPFS will use a TXT record to map to objects or names:

// ipfs (objects)
TXT  example.com  "ipfs=<hash-of-object>[/path]"

// ipns (names)
TXT  example.com  "ipns=<hash-of-publickey>[/path]"

But perhaps much better to use a general, protocol agnostic link:

// format
TXT  example.com  "link=/path/to/resource"

// ipfs (objects)
TXT  example.com  "link=/ipfs/<hash-of-object>[/path]"

// ipns (names)
TXT  example.com  "link=/ipns/<hash-of-publickey>[/path]"

// http
TXT  example.com  "link=/http/<hostname>[/path]"

// bittorrent
TXT  example.com  "link=/bittorrent/<infohash>[/piece]"

// bitcoin
TXT  example.com  "link=/bitcoin/address/<bitcoin-address>"

The key can be link or dnsweb or whatever isn't taken.

This way path file systems can use dns in its paths without locking users into one protocol. I.e. http uses dns, but it's in an http-only context:

consider http://foo.com/bar/baz.txt

> DNS resolve A foo.com 
< A foo.com 10.20.30.40

> HTTP get http://10.20.30.40:80/bar/baz.txt
< ...

But with these links, we could use dns to reference other protocols easily, and make the web cross protocol boundaries seamlessly.

consider /ipns/foo.com/bar/baz.txt

> IPNS "foo.com" is a DNS name, thus resolve with DNS
> DNS resolve TXT (link) foo.com

< TXT foo.com "link=/ipfs/<hash-of-foo>"
> IPFS get /ipfs/<hash-of-foo>/bar/baz.txt

or

< TXT foo.com "link=/bittorrent/<foo-infohash>"
> BitTorrent get <foo-infohash>/bar/baz.txt

or 

< TXT foo.com "link=/http/<bar.com>/baz.txt"
> HTTP get http://<bar.com>/baz.txt

fs root

This fits in well with another idea I have, which I'll detail more in the future. The gist of that is to make all root file systems the same, specifying the protocol in the first path component. (Shoving all your local filesystem into /local for now.)

/dns/foo.com/bar/baz.txt
/http/10.20.30.40/bar/baz.txt
/ipfs/abcabcabcbabcacab/bar/baz.txt
/ipns/foo.com/bar/baz.txt
/bittorrent/abbaabababbaabab/bar/baz.txt
/local/foo/bar/baz.txt

And thus all our filesystems would work nicely together. Links would make sense across protocols.

andrewtj commented 8 years ago

I also dislike DNS, and this note should not be taken to mean otherwise.

Have you expanded on that anywhere?

jbenet commented 8 years ago

@andrewtj not yet. i dislike many aspects, but the more egregious one is the registrar system. it's a racket with terrible UX. (also getting endianness backwards). also lack of sigs ...

jbenet commented 8 years ago

Update: this is now known (and implemented) as "dnslink=". should make a small tool to resolve them.