utils

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareIface added in v1.1.0

func CompareIface(iface1, iface2 models.Iface) bool

CompareIface compares two individual Iface structs and returns true if they are equal

func CompareIfaces added in v1.1.0

func CompareIfaces(ifaces1, ifaces2 []models.Iface) bool

CompareIfaces compares two slices of Iface and returns true if they are equal Two slices are considered equal if they have the same length and all corresponding elements have the same Name, AddressString, and IP address

func GetExtClientEndpoint added in v1.0.0

func GetExtClientEndpoint(hostIpv4Endpoint, hostIpv6Endpoint net.IP, hostListenPort int) string

GetExtClientEndpoint returns the external client endpoint in the format "host:port" or "[host]:port" for IPv6

func NoEmptyStringToCsv added in v0.90.0

func NoEmptyStringToCsv(strs ...string) string

NoEmptyStringToCsv takes a bunch of strings, filters out empty ones and returns a csv version of the string

func SortIfacesByName added in v1.1.0

func SortIfacesByName(ifaces []models.Iface)

SortIfacesByName sorts a slice of Iface by name in ascending order

func TraceCaller added in v0.90.0

func TraceCaller()

Types

type GeoInfo added in v1.5.0

type GeoInfo struct {
	IP          string
	CountryCode string
	Location    string
}

func GetGeoInfo added in v1.5.0

func GetGeoInfo(ip ...net.IP) (*GeoInfo, error)

GetGeoInfo returns the ip, location and country code of the host it's called on.

type RetryStrategy

type RetryStrategy struct {
	Wait             func(time.Duration)
	WaitTime         time.Duration
	WaitTimeIncrease time.Duration
	MaxTries         int
	Try              func() error
	OnMaxTries       func()
	OnSuccess        func()
}

RetryStrategy specifies a strategy to retry an operation after waiting a while, with hooks for successful and unsuccessful (>=max) tries.

func (RetryStrategy) DoStrategy

func (rs RetryStrategy) DoStrategy()

DoStrategy does the retry strategy specified in the struct, waiting before retrying an operator, up to a max number of tries, and if executes a success "finalizer" operation if a retry is successful

Jump to

Keyboard shortcuts

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