publicip

package
v1.136.3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Detector

type Detector interface {
	// DetectPublicIPs returns the system's public IPs (IPv4 and/or IPv6 as available) or an error if none or both can be
	// detected.
	DetectPublicIPs(ctx context.Context, log logr.Logger) ([]net.IP, error)
}

Detector can detect the system's public IPs.

type IpifyDetector

type IpifyDetector struct {
	// Client is the http client to use, defaults to http.DefaultClient.
	Client *http.Client
}

IpifyDetector implements Detector using https://ipify.org/.

func (IpifyDetector) DetectPublicIPs

func (i IpifyDetector) DetectPublicIPs(ctx context.Context, parentLog logr.Logger) ([]net.IP, error)

DetectPublicIPs tries both api4.ipify.org and api6.ipify.org. If both return an error, the result is an empty slice and a combined error. Otherwise, it returns either or both detected IP addresses.

Jump to

Keyboard shortcuts

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