fastip

package
v0.0.0-...-b048235 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

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
	// are pinged.  Any ping results received after it are cached but not
	// used at the moment.  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 the *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 a 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL