Coder Social home page Coder Social logo

dns_resolver's Introduction

Simple dns resolver implemented in go

Build Status Go Walker

Based on based on miekg/dns.

Features

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

Installing

Using go get

$ go get github.com/bogdanovich/dns_resolver

After this command dns_resolver is ready to use. Its source will be in:

$GOPATH/src/github.com/bogdanovich/dns_resolver

Example

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]
}

dns_resolver's People

Contributors

bogdanovich avatar bramp 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dns_resolver's Issues

why no executable file: dns_resolver generated?

hi.
in $GOPATH,I RAN "go get -u -v github.com/bogdanovich/dns_resolver" AS FOLLOWS:

yudeMacBook-Air:gopath brite$ go get -u -v github.com/bogdanovich/dns_resolver
github.com/bogdanovich/dns_resolver (download)

cd .; git clone https://github.com/bogdanovich/dns_resolver /Users/yuming/go1.10.2/go/gopath/src/github.com/bogdanovich/dns_resolver

Cloning into '/Users/yuming/go1.10.2/go/gopath/src/github.com/bogdanovich/dns_resolver'...
fatal: unable to access 'https://github.com/bogdanovich/dns_resolver/': Failed to connect to github.com port 443: Operation timed out
package github.com/bogdanovich/dns_resolver: exit status 128
yudeMacBook-Air:gopath brite$
yudeMacBook-Air:gopath brite$ go get -u -v github.com/bogdanovich/dns_resolver
github.com/bogdanovich/dns_resolver (download)
github.com/miekg/dns (download)
Fetching https://golang.org/x/crypto/ed25519?go-get=1
Parsing meta tags from https://golang.org/x/crypto/ed25519?go-get=1 (status code 200)
get "golang.org/x/crypto/ed25519": found meta tag get.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at https://golang.org/x/crypto/ed25519?go-get=1
get "golang.org/x/crypto/ed25519": verifying non-authoritative meta tag
Fetching https://golang.org/x/crypto?go-get=1
Parsing meta tags from https://golang.org/x/crypto?go-get=1 (status code 200)
golang.org/x/crypto (download)
Fetching https://golang.org/x/crypto/ed25519/internal/edwards25519?go-get=1
Parsing meta tags from https://golang.org/x/crypto/ed25519/internal/edwards25519?go-get=1 (status code 200)
get "golang.org/x/crypto/ed25519/internal/edwards25519": found meta tag get.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at https://golang.org/x/crypto/ed25519/internal/edwards25519?go-get=1
get "golang.org/x/crypto/ed25519/internal/edwards25519": verifying non-authoritative meta tag
Fetching https://golang.org/x/net/ipv4?go-get=1
Parsing meta tags from https://golang.org/x/net/ipv4?go-get=1 (status code 200)
get "golang.org/x/net/ipv4": found meta tag get.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/ipv4?go-get=1
get "golang.org/x/net/ipv4": verifying non-authoritative meta tag
Fetching https://golang.org/x/net?go-get=1
Parsing meta tags from https://golang.org/x/net?go-get=1 (status code 200)
golang.org/x/net (download)
Fetching https://golang.org/x/net/bpf?go-get=1
Parsing meta tags from https://golang.org/x/net/bpf?go-get=1 (status code 200)
get "golang.org/x/net/bpf": found meta tag get.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/bpf?go-get=1
get "golang.org/x/net/bpf": verifying non-authoritative meta tag
Fetching https://golang.org/x/net/internal/iana?go-get=1
Parsing meta tags from https://golang.org/x/net/internal/iana?go-get=1 (status code 200)
get "golang.org/x/net/internal/iana": found meta tag get.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/internal/iana?go-get=1
get "golang.org/x/net/internal/iana": verifying non-authoritative meta tag
Fetching https://golang.org/x/net/internal/socket?go-get=1
Parsing meta tags from https://golang.org/x/net/internal/socket?go-get=1 (status code 200)
get "golang.org/x/net/internal/socket": found meta tag get.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/internal/socket?go-get=1
get "golang.org/x/net/internal/socket": verifying non-authoritative meta tag
Fetching https://golang.org/x/sys/unix?go-get=1
Parsing meta tags from https://golang.org/x/sys/unix?go-get=1 (status code 200)
get "golang.org/x/sys/unix": found meta tag get.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at https://golang.org/x/sys/unix?go-get=1
get "golang.org/x/sys/unix": verifying non-authoritative meta tag
Fetching https://golang.org/x/sys?go-get=1
Parsing meta tags from https://golang.org/x/sys?go-get=1 (status code 200)
golang.org/x/sys (download)
Fetching https://golang.org/x/net/ipv6?go-get=1
Parsing meta tags from https://golang.org/x/net/ipv6?go-get=1 (status code 200)
get "golang.org/x/net/ipv6": found meta tag get.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net/ipv6?go-get=1
get "golang.org/x/net/ipv6": verifying non-authoritative meta tag
github.com/bogdanovich/dns_resolver
yudeMacBook-Air:gopath brite$ which dns_resolver
yudeMacBook-Air:gopath brite$

thank

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.