Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
73b2058f
Commit
73b2058f
authored
Oct 03, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DNSResolver: use isd.IsDomain
this commit dedicated to @whyrusleeping
parent
7bb2bd6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
namesys/dns.go
namesys/dns.go
+6
-2
No files found.
namesys/dns.go
View file @
73b2058f
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment