Documentation ¶
Index ¶
- func AllUnique[T comparable](sl []T) bool
- func DecodeOptions(in io.ReadCloser, formatHint string, out any) error
- func Exec(ctx context.Context, command string, args ...string) error
- func ExecOutput(ctx context.Context, command string, args ...string) ([]byte, error)
- func GenerateULA() (netip.Prefix, error)
- func GetEnvDefault(key, def string) string
- func GetEnvDurationDefault(key string, def time.Duration) time.Duration
- func GetEnvIntDefault(key string, def int) int
- func MACtoEUI64(mac net.HardwareAddr) net.HardwareAddr
- func ParsePortRange(s string) (start int, end int, err error)
- func Ping(ctx context.Context, addr netip.Addr) error
- func Pointer[T any](t T) *T
- func PrettyByteSize(b int64) string
- func Random64(prefix netip.Prefix) (netip.Prefix, error)
- func RandomLocalMAC() (net.HardwareAddr, error)
- func ResolveTCPAddr(ctx context.Context, lookup string, maxRetries int) (net.Addr, error)
- func SetupLogging(logLevel string) *slog.Logger
- func TimeToNTP(t time.Time) uint64
- func VerifyChainOnly(rawCerts [][]byte, _ [][]*x509.Certificate) error
- type STUNLoggerFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllUnique ¶ added in v0.1.2
func AllUnique[T comparable](sl []T) bool
func DecodeOptions ¶
func DecodeOptions(in io.ReadCloser, formatHint string, out any) error
DecodeOptions will attempt to decode the given reader into the given object. The formatHint is used to select the format of the document. If the formatHint is empty, the format is guessed from the document. The document is first treated as a go-template with some custom functions. This allows us to use environment variables and file contents in the config.
func ExecOutput ¶
func GenerateULA ¶
GenerateULA generates a unique local address with a /48 prefix according to RFC 4193. The network is returned as a netip.Prefix.
func GetEnvDefault ¶
GetEnvDefault returns the value of an environment variable or a default value.
func GetEnvDurationDefault ¶
GetEnvDurationDefault returns the value of an environment variable or a default value.
func GetEnvIntDefault ¶
GetEnvIntDefault returns the value of an environment variable or a default value.
func MACtoEUI64 ¶
func MACtoEUI64(mac net.HardwareAddr) net.HardwareAddr
MACtoEUI64 converts a MAC address to an EUI-64 identifier.
func ParsePortRange ¶
ParsePortRange parses a port range string.
func Ping ¶
Ping sends ICMP echo requests to the given address. The context must have a timeout set and is used for the duration of the ping. The function returns an error if no replies were received.
func PrettyByteSize ¶ added in v0.1.2
func RandomLocalMAC ¶
func RandomLocalMAC() (net.HardwareAddr, error)
GetRandomLocalMAC returns a random MAC address from the host.
func ResolveTCPAddr ¶ added in v0.0.27
ResolveTCPAddr resolves a TCP address with retries and context.
func SetupLogging ¶ added in v0.1.6
func VerifyChainOnly ¶
func VerifyChainOnly(rawCerts [][]byte, _ [][]*x509.Certificate) error
VerifyChainOnly is a function that can be used in a TLS configuration to only verify that the certificate chain is valid.
Types ¶
type STUNLoggerFactory ¶ added in v0.1.3
func NewSTUNLoggerFactory ¶ added in v0.1.3
func NewSTUNLoggerFactory(logger *slog.Logger) *STUNLoggerFactory
func (*STUNLoggerFactory) NewLogger ¶ added in v0.1.3
func (f *STUNLoggerFactory) NewLogger(scope string) logging.LeveledLogger