Giter Site home page Giter Site logo

dnscache's People

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

dnscache's Issues

FetchString undefined.

Hello, I find that there is a mistake in your Readme
image.

dnscache.FetchString undefined. Maybe dnscache.FetchOneString ?

Suggested to random ip in FetchOne.

Hello. I think your FetchOne function always return the first ip in cache is not perfect.Because we can use dns to do some load-balance.

image

So, i think you can random your ip in return. Or create another function to return a random Ip.

Improvement: allow to use custom LookupIP function

Sometimes we need to use other LookupIP() func then default net.LookupIP() func. This is typical, when we need to use custom DNS resolver - e.g. hashicorps consul, etc.
It should be very helpfull to be able to setup cutom function here

func (r *Resolver) Lookup(address string) ([]net.IP, error) {
  ips, err := net.LookupIP(address)

Correct way to set timeouts for net.Dialer?

client := &http.Client{
	Transport: &http.Transport{
		Dial: (&net.Dialer{
			Timeout:   20 * time.Second,
			KeepAlive: 20 * time.Second,
		}).Dial,
		TLSHandshakeTimeout:   10 * time.Second,
	},
	Timeout: 30 * time.Second,
}

How can I set these timeouts using the DNS cache example?

client := &http.Client{
	Transport: &http.Transport {
	  MaxIdleConnsPerHost: 64,
	  Dial: func(network string, address string) (net.Conn, error) {
	    separator := strings.LastIndex(address, ":")
	    ip, _ := dnscache.FetchString(address[:separator])
	    return net.Dial("tcp", ip + address[separator:])
	  },
	  TLSHandshakeTimeout:   10 * time.Second,
	}
	Timeout: 30 * time.Second,
}

Do I need to create my own Dailer so I can set properties net.Dailer has?

type Dialer struct {
	net.Dialer
}

func (d *Dailer) Dial(network string, address string) (net.Conn, error) {
	separator := strings.LastIndex(address, ":")
	ip, _ := dnscache.FetchString(address[:separator])
	return net.Dial("tcp", ip + address[separator:])
}

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.