Properties

Last built 5 months ago using go version go1.7.1 linux/amd64 and 40 seconds of time

Downloads
Filename
File Size
 
go-dnslink_master_darwin-386.zip
5.9KiB
go-dnslink_master_darwin-amd64.zip
5.8KiB
go-dnslink_master_linux-386.zip
5.9KiB
go-dnslink_master_linux-amd64.zip
5.8KiB
go-dnslink_master_linux-arm.zip
5.9KiB
go-dnslink_master_windows-386.zip
5.9KiB
go-dnslink_master_windows-amd64.zip
5.8KiB
Project-Readme for this version

go-dnslink

dnslink resolution in go-ipfs

Table of Contents

Background

Package dnslink implements a DNS link resolver. dnslink is a basic standard for placing traversable links in DNS itself. See dnslink.info

A dnslink is a path link in a DNS TXT record, like this:

dnslink=/ipfs/QmR7tiySn6vFHcEjBeZNtYGAFh735PJHfEMdVEycj9jAPy

For example:

> dig TXT ipfs.io
ipfs.io.  120   IN  TXT  dnslink=/ipfs/QmR7tiySn6vFHcEjBeZNtYGAFh735PJHfEMdVEycj9jAPy

This package eases resolving and working with thse DNS links. For example:

import (
  dnslink "github.com/jbenet/go-dnslink"
)

link, err := dnslink.Resolve("ipfs.io")
// link = "/ipfs/QmR7tiySn6vFHcEjBeZNtYGAFh735PJHfEMdVEycj9jAPy"

It even supports recursive resolution. Suppose you have three domains with dnslink records like these:

> dig TXT foo.com
foo.com.  120   IN  TXT  dnslink=/dns/bar.com/f/o/o
> dig TXT bar.com
bar.com.  120   IN  TXT  dnslink=/dns/long.test.baz.it/b/a/r
> dig TXT long.test.baz.it
long.test.baz.it.  120   IN  TXT  dnslink=/b/a/z

Expect these resolutions:

dnslink.ResolveN("long.test.baz.it", 0) // "/dns/long.test.baz.it"
dnslink.Resolve("long.test.baz.it")     // "/b/a/z"

dnslink.ResolveN("bar.com", 1)          // "/dns/long.test.baz.it/b/a/r"
dnslink.Resolve("bar.com")              // "/b/a/z/b/a/r"

dnslink.ResolveN("foo.com", 1)          // "/dns/bar.com/f/o/o/"
dnslink.ResolveN("foo.com", 2)          // "/dns/long.test.baz.it/b/a/r/f/o/o/"
dnslink.Resolve("foo.com")              // "/b/a/z/b/a/r/f/o/o"

Install

go get ipfs/go-dnslink

Usage

As a library

import (
  log
  fmt

  dnslink "github.com/jbenet/go-dnslink"
)

func main() {
  link, err := dnslink.Resolve("ipfs.io")
  if err != nil {
    log.Fatal(err)
  }

  fmt.Println(link) // string path
}

As a commandline tool

Check out the commandline tool, which works like this:

> dnslink ipfs.io
/ipfs/QmR7tiySn6vFHcEjBeZNtYGAFh735PJHfEMdVEycj9jAPy

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

Want to hack on IPFS?

License

MIT © Juan Benet-Batiz