Commit 73b2058f authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

DNSResolver: use isd.IsDomain

this commit dedicated to @whyrusleeping
parent 7bb2bd6d
......@@ -2,25 +2,29 @@ package namesys
import (
"net"
"strings"
b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
u "github.com/jbenet/go-ipfs/util"
isd "github.com/jbenet/go-is-domain"
)
// DNSResolver implements a Resolver on DNS domains
type DNSResolver struct {
// TODO: maybe some sort of caching?
// cache would need a timeout
}
// Matches implements Resolver
func (r *DNSResolver) Matches(name string) bool {
return strings.Contains(name, ".") && !strings.HasPrefix(name, ".")
return isd.IsDomain(name)
}
// Resolve implements Resolver
// TXT records for a given domain name should contain a b58
// encoded multihash.
func (r *DNSResolver) Resolve(name string) (string, error) {
log.Info("DNSResolver resolving %v", name)
txt, err := net.LookupTXT(name)
if err != nil {
return "", err
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment