fastip

package
v0.73.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 6

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.

View Source
const LogPrefix = "fastip"

LogPrefix is a prefix for logging.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.72.0

type Config struct {
	// Logger is used as the base logger for the service.  If nil,
	// [slog.Default] with [LogPrefix] is used.
	Logger *slog.Logger

	// 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.  If zero, [DefaultPingWaitTimeout] is used.
	PingWaitTimeout time.Duration
}

Config contains all the fields necessary for proxy configuration.

type FastestAddr

type FastestAddr struct {
	// contains filtered or unexported fields
}

FastestAddr provides methods to determine the fastest network addresses.

func New added in v0.72.0

func New(c *Config) (f *FastestAddr)

New initializes a new instance of *FastestAddr.

func NewFastestAddr deprecated

func NewFastestAddr() (f *FastestAddr)

NewFastestAddr initializes a new instance of *FastestAddr.

Deprecated: Use New instead.

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.

Jump to

Keyboard shortcuts

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