Skip to content

wheelcomplex/dns_resolver

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple dns resolver implemented in go

Based on based on miekg/dns.

Features

  • Uses provided dns servers array in random order
  • Retries dns requests in case of i/o timeout

Building

Building is done with the go tool. If you have setup your GOPATH correctly, the following should work:

go get github.com/bogdanovich/dns_resolver
go build github.com/bogdanovich/dns_resolver

Examples

package main

import (
	"log"
	"github.com/bogdanovich/dns_resolver"
)

func main() {
	resolver := dns_resolver.New([]string{"8.8.8.8", "8.8.4.4"})
	// OR
	// resolver := dns_resolver.NewFromResolvConf("resolv.conf")

	// In case of i/o timeout
	resolver.RetryTimes = 5

	ip, err := resolver.LookupHost("google.com")
	if err != nil {
		log.Fatal(err.Error())
	}
	log.Println(ip)
	// Output [216.58.192.46]
}

About

Simple dns resolver in go based on miekg/dns.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%