netutils

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package netutils provides types and functions to perform common network operations.

Index

Constants

View Source
const (

	// NetTypeTCPAuto indicates that either of IPv4 or IPv6 will be used to
	// establish a connection depending on the specified IP Address.
	NetTypeTCPAuto string = "tcp"

	// NetTypeTCP4 indicates an IPv4-only network.
	NetTypeTCP4 string = "tcp4"

	// NetTypeTCP6 indicates an IPv6-only network.
	NetTypeTCP6 string = "tcp6"
)

Known, named networks used for TCP/IP connections. These names match the network names used by the `net` standard library package.

Variables

View Source
var (
	// ErrMissingValue indicates that an expected value was missing.
	ErrMissingValue = errors.New("missing expected value")

	// ErrDNSLookupFailed indicates a failure to resolve a hostname to an IP
	// Address.
	ErrDNSLookupFailed = errors.New("failed to resolve hostname")

	// ErrIPAddressParsingFailed indicates a failure to parse a given value as
	// an IP Address.
	ErrIPAddressParsingFailed = errors.New("failed to parse IP Address")

	// ErrNoIPAddressesForChosenNetworkType indicates a failure to obtain any
	// IP Addresses of the specified network type (e.g., IPv4 vs IPv6) for a
	// given hostname.
	ErrNoIPAddressesForChosenNetworkType = errors.New("no resolved IP Addresses for chosen network type")

	// ErrNetworkConnectionFailed indicates a failure to establish a network
	// connection to the specified host.
	ErrNetworkConnectionFailed = errors.New("failed to establish network connection")
)

Functions

This section is empty.

Types

type HTTPTransportDialContextFunc

type HTTPTransportDialContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)

HTTPTransportDialContextFunc represents a function that is compatible with the http.Transport DialContext field.

func DialerWithContext

func DialerWithContext(networkType string, logger zerolog.Logger) HTTPTransportDialContextFunc

DialerWithContext returns a function for use with the http.Transport DialContext field. Use of this function allows the caller to override the default "auto" network type selection behavior used by the net.Dial function when opening a network connection to the specified address/port.

Jump to

Keyboard shortcuts

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