Documentation
¶
Overview ¶
Package networking provides utilities for network operations, such as finding available ports and checking network connectivity.
Index ¶
- Constants
- func AddressReferencesPrivateIp(address string) error
- func FindAvailable() int
- func FindOrUsePort(port int) (int, error)
- func IsAvailable(port int) bool
- func IsIPv6Available() bool
- func IsLocalhost(host string) bool
- func IsURL(input string) bool
- func ValidateEndpointURL(endpoint string) error
- type HttpClientBuilder
- type ValidatingTransport
Constants ¶
const ( // MinPort is the minimum port number to use MinPort = 10000 // MaxPort is the maximum port number to use MaxPort = 65535 // MaxAttempts is the maximum number of attempts to find an available port MaxAttempts = 10 )
const (
// ErrPrivateIpAddress is the error returned when the provided URL redirects to a private IP address
ErrPrivateIpAddress = "the provided registry URL redirects to a private IP address, which is not allowed; " +
"to override this, reset the registry URL using the --allow-private-ip (-p) flag"
)
const HttpScheme = "http"
HttpScheme is the HTTP scheme
const HttpTimeout = 30 * time.Second
HttpTimeout is the timeout for outgoing HTTP requests
const HttpsScheme = "https"
HttpsScheme is the HTTPS scheme
Variables ¶
This section is empty.
Functions ¶
func AddressReferencesPrivateIp ¶ added in v0.1.1
AddressReferencesPrivateIp returns an error if the address references a private IP address
func FindOrUsePort ¶
FindOrUsePort checks if the provided port is available or finds an available port if none is provided. If port is 0, it will find an available port. If port is not 0, it will check if the port is available. Returns the selected port and an error if any.
func IsIPv6Available ¶
func IsIPv6Available() bool
IsIPv6Available checks if IPv6 is available on the system by looking for IPv6 addresses on network interfaces
func IsLocalhost ¶ added in v0.2.4
IsLocalhost checks if a host is localhost (for development)
func ValidateEndpointURL ¶ added in v0.2.4
ValidateEndpointURL validates that an endpoint URL is secure
Types ¶
type HttpClientBuilder ¶ added in v0.1.8
type HttpClientBuilder struct {
// contains filtered or unexported fields
}
HttpClientBuilder provides a fluent interface for building HTTP clients
func NewHttpClientBuilder ¶ added in v0.1.8
func NewHttpClientBuilder() *HttpClientBuilder
NewHttpClientBuilder returns a new HttpClientBuilder
func (*HttpClientBuilder) Build ¶ added in v0.1.8
func (b *HttpClientBuilder) Build() (*http.Client, error)
Build creates the configured HTTP client
func (*HttpClientBuilder) WithCABundle ¶ added in v0.1.8
func (b *HttpClientBuilder) WithCABundle(path string) *HttpClientBuilder
WithCABundle sets the CA certificate bundle path
func (*HttpClientBuilder) WithPrivateIPs ¶ added in v0.1.8
func (b *HttpClientBuilder) WithPrivateIPs(allow bool) *HttpClientBuilder
WithPrivateIPs allows connections to private IP addresses
func (*HttpClientBuilder) WithTokenFromFile ¶ added in v0.1.8
func (b *HttpClientBuilder) WithTokenFromFile(path string) *HttpClientBuilder
WithTokenFromFile sets the auth token file path
type ValidatingTransport ¶ added in v0.0.37
type ValidatingTransport struct {
Transport http.RoundTripper
}
ValidatingTransport is for validating URLs prior to request