Documentation ¶
Overview ¶
Package fastip implements the algorithm that allows to query multiple resolvers, ping all IP addresses that were returned, and return the fastest one among them.
Index ¶
Constants ¶
View Source
const DefaultPingWaitTimeout = 1 * time.Second
DefaultPingWaitTimeout is the default period of time for waiting ping operations to finish.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FastestAddr ¶
type FastestAddr struct { // PingWaitTimeout is the timeout for waiting all the resolved addresses to // be pinged. Any ping results received after that moment are cached, but // won't be used. It should be configured right after the FastestAddr // initialization since it isn't protected for concurrent usage. PingWaitTimeout time.Duration // contains filtered or unexported fields }
FastestAddr provides methods to determine the fastest network addresses.
func NewFastestAddr ¶
func NewFastestAddr() (f *FastestAddr)
NewFastestAddr initializes a new instance of *FastestAddr.
func (*FastestAddr) ExchangeFastest ¶
func (f *FastestAddr) ExchangeFastest( req *dns.Msg, ups []upstream.Upstream, ) (resp *dns.Msg, u upstream.Upstream, err error)
ExchangeFastest queries each specified upstream and returns the response with the fastest IP address. The fastest IP address is considered to be the first one successfully dialed and other addresses are removed from the answer.
Click to show internal directories.
Click to hide internal directories.