utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// errGotConnection has already been established
	ErrInflightCancel       = errkit.New("context cancelled before establishing connection")
	ErrNoIPs                = errkit.New("no ips provided in dialWrap")
	ExpireConnAfter         = time.Duration(5) * time.Second
	ErrPortClosedOrFiltered = errkit.New("port closed or filtered").SetKind(errkit.ErrKindNetworkPermanent)
)

Error constants

Functions

This section is empty.

Types

type DialWrap

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

DialWrap wraps the net dialer taking in and only dials to given ips. This implementation retains the orignal Happy Eyeballs algorithm and dual stack support.

func NewDialWrap

func NewDialWrap(dialer *net.Dialer, ips []string, network, address, port string) (*DialWrap, error)

NewDialWrap creates a new dial wrap instance and returns it.

func (*DialWrap) Address

func (d *DialWrap) Address() (string, string)

Address returns ip and port of the target if multiple ips are present, it returns the first one

func (*DialWrap) DialContext

func (d *DialWrap) DialContext(ctx context.Context, _ string, _ string) (net.Conn, error)

DialContext is the main entry point for dialing

func (*DialWrap) FirstConnectionTook added in v0.2.13

func (d *DialWrap) FirstConnectionTook() time.Duration

func (*DialWrap) MultipathTCP

func (d *DialWrap) MultipathTCP() bool

MultipathTCP is a getter for the MultipathTCP field

func (*DialWrap) SetFirstConnectionDuration added in v0.2.13

func (d *DialWrap) SetFirstConnectionDuration(dur time.Duration)

func (*DialWrap) SetMultipathTCP

func (d *DialWrap) SetMultipathTCP(use bool)

SetMultipathTCP is a setter for the MultipathTCP field

Jump to

Keyboard shortcuts

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