Code Monkey home page Code Monkey logo

go-dnslink's Introduction

⚠️ Deprecated in favor of dnslink-std/go

  • 👉 this project is no longer maintained, greenfield projects should use dnslink-std/go
  • we will convert this repo to a thin arapper around dnslink-std/go at some point – see #15

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/ipfs/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=/ipns/bar.com/f/o/o
> dig TXT bar.com
bar.com.  120   IN  TXT  dnslink=/ipns/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) // "/ipns/long.test.baz.it"
dnslink.Resolve("long.test.baz.it")     // "/b/a/z"

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

dnslink.ResolveN("foo.com", 1)          // "/ipns/bar.com/f/o/o/"
dnslink.ResolveN("foo.com", 2)          // "/ipns/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 github.com/ipfs/go-dnslink

Usage

As a library

import (
  log
  fmt

  dnslink "github.com/ipfs/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

go-dnslink's People

Contributors

abitrolly avatar andrew avatar ebastos avatar hsanjuan avatar iand avatar ipfs-mgmt-read-write[bot] avatar jbenet avatar lidel avatar richardlitt avatar stebalien avatar web-flow avatar web3-bot avatar whyrusleeping avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-dnslink's Issues

Returning TTL of record

In future IPNS caching might be written and TTL of records will be required. It would be great to be prepared for it.

/ipns/ instead of /dns/

I think the examples in the README should be /ipns/ instead of /dns/.
Does /dns/ work? When I tried to test it I don't think it worked.

Allow specifying a recursion limit

Something like

> dnslink --limit 1 a.com
/dns/b.a.com
> dnslink --limit 2 a.com
/dns/c.b.a.com
> dnslink --limit 3 a.com
/dns/d.c.b.a.com

Is this repo actually used?

I can't find any packages that reference this repository (and none are shown on godoc.org). Functionality seems to be reimplemented in github.com/ipfs/go-ipfs/namesys. As such I think it's potentially misleading to have an implementation that can drift from the official IPFS behaviour. The ipfs tool has the dns subcommand, among others that perform the behaviour in this package. Perhaps it should be deleted?

Ignore non-IPFS content paths in DNSLink records

DNSLink currently returns the first non /dns-prefixed dnslink which means that per domain it is possible to use dnslink for only one "protocol". In order for dnslink to become useful for different decentralized protocols (hyper/dat, earthlink, etc.) it would need an option to specify a particular protocol to be looked for. Would you be open to a PR adding an option to this repo, defaulting to IPFS?

(Related issue on js-dnslink: here)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.