Documentation ¶
Index ¶
- func AppendPrefixMask(ipStr string, maskSize int) (string, error)
- func CLose(err *error, fn fnWithErrorResult)
- func CheckPeriodically(ctx context.Context, duration time.Duration, fn func() (bool, error)) (bool, error)
- func ContainsValidCustomIPv4Ranges(ipRanges []string) bool
- func ContainsValidCustomIPv6Ranges(ipRanges []string) bool
- func FilterOutAllowed(elems []string, allowed map[string]struct{}) (notAllowed []string)
- func Getenv(name, defaultValue string) string
- func GetenvDuration(name, defaultValue string) (time.Duration, error)
- func GetenvInt(name, defaultValue string) (int, error)
- func GoWithWaitGroup(wg *sync.WaitGroup, fn func())
- func IPNetSliceToStringSlice(items []net.IPNet) (result []string)
- func IgnoreError(fn fnWithErrorResult)
- func IsDefaultIPRoute(ip string) bool
- func IsDefaultIPv4Route(ip string) bool
- func IsDefaultIPv6Route(ip string) bool
- func IsIPv4Address(addr string) bool
- func IsIPv4Prefix(prefix string) bool
- func IsIPv6Address(addr string) bool
- func IsIPv6Prefix(prefix string) bool
- func IsValidPrefix(prefix string) bool
- func JsonStringer(x interface{}) fmt.Stringer
- func JsonUnmarshal(from map[string]interface{}, to interface{}) error
- func MustJsonMarshalToString(x interface{}) string
- func ParseTime(timeStr string) (time.Time, error)
- func PtrString(v string) *string
- func RetryOperation(ctx context.Context, wait time.Duration, retries int, operation func() error) error
- func RetryOperationExpBackoff(ctx context.Context, maxWait time.Duration, operation func() error) error
- func RetryOperationForErrors(ctx context.Context, wait time.Duration, retries int, retriableErrors []error, ...) error
- func RunPeriodically(ctx context.Context, duration time.Duration, fn func())
- func SplitKeyValue(s string) (result []string)
- func StringToInt64(s string) int64
- func TimeBeginPeriod(period uint32) error
- func TimeEndPeriod(period uint32) error
- func ValidateIPv4Cidr(cidrStr string) error
- func ValidateIPv6Cidr(cidrStr string) error
- func WithTrace(ctx context.Context, l *zap.SugaredLogger) *zap.SugaredLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendPrefixMask ¶
AppendPrefixMask appends a prefix mask to a v4 or v6 address and returns the result as a string.
func CheckPeriodically ¶
func CheckPeriodically(ctx context.Context, duration time.Duration, fn func() (bool, error)) (bool, error)
CheckPeriodically checks a function (fn) at a specified interval (duration). It will return when one of these conditions occurs: fn returns true, fn returns an error, the duration is met, or the context is Done().
func ContainsValidCustomIPv4Ranges ¶
ContainsValidCustomIPv4Ranges matches the following custom IPv4 patterns usable by netfilter userspace utils: Cidr notation 100.100.0.0/16 Individual address 10.100.0.2 Dash-separated range 100.100.0.0-100.100.10.255
func ContainsValidCustomIPv6Ranges ¶
ContainsValidCustomIPv6Ranges matches the following custom IPv6 patterns usable by netfilter userspace utils: Cidr notation 200::/64 Individual address 200::2 Dash-separated range 200::1-200::8 Dash-separated range 2001:0db8:0000:0000:0000:0000:0000:0000-2001:0db8:ffff:ffff:ffff:ffff:ffff:ffff
func FilterOutAllowed ¶
func GoWithWaitGroup ¶
GoWithWaitGroup runs fn in a goroutine with an optional *sync.WaitGroup to track when fn finishes executing.
func IPNetSliceToStringSlice ¶
func IgnoreError ¶
func IgnoreError(fn fnWithErrorResult)
IgnoreError call the passed fn and ignore the errors it returns. Example `defer util.IgnoreError(file.Close)`
func IsDefaultIPRoute ¶
IsDefaultIPRoute wrapper for IsDefaultIPv4Route and IsDefaultIPv6Route
func IsDefaultIPv4Route ¶
IsDefaultIPv4Route checks if the given prefix is the default route for IPv4.
func IsDefaultIPv6Route ¶
IsDefaultIPv6Route checks if the given prefix is the default route for IPv6.
func IsIPv4Address ¶
IsIPv4Address checks if the given IP address is an IPv4 address.
func IsIPv4Prefix ¶
IsIPv4Prefix checks if the given IP address is an IPv4 prefix.
func IsIPv6Address ¶
IsIPv6Address checks if the given IP address is an IPv6 address.
func IsIPv6Prefix ¶
IsIPv6Prefix checks if the given IP address is an IPv6 prefix.
func IsValidPrefix ¶
IsValidPrefix checks if the given cidr is valid
func JsonStringer ¶
func JsonUnmarshal ¶
func MustJsonMarshalToString ¶
func MustJsonMarshalToString(x interface{}) string
func ParseTime ¶
ParseTime attempts to parse a time string in three possible formats to handle UTC and local time differences between Darwin and Linux and the proxy mode. On each system we get different time formats for the last wireguard handshake time.
func RetryOperation ¶
func RetryOperation(ctx context.Context, wait time.Duration, retries int, operation func() error) error
RetryOperation retries the operation with a backoff policy.
func RetryOperationExpBackoff ¶
func RetryOperationExpBackoff(ctx context.Context, maxWait time.Duration, operation func() error) error
RetryOperationExpBackoff retries the operation with an exponential backoff policy.
func RetryOperationForErrors ¶
func RetryOperationForErrors(ctx context.Context, wait time.Duration, retries int, retriableErrors []error, operation func() error) error
RetryOperationForErrors retries the operation with a backoff policy for the specified errors, otherwise will just perform the operation once and return the error if it fails.
func SplitKeyValue ¶
func StringToInt64 ¶
func TimeBeginPeriod ¶
func TimeEndPeriod ¶
func ValidateIPv4Cidr ¶
ValidateIPv4Cidr checks for a valid IPv4 cidr
func ValidateIPv6Cidr ¶
ValidateIPv6Cidr checks for a valid IPv6 cidr
func WithTrace ¶
func WithTrace(ctx context.Context, l *zap.SugaredLogger) *zap.SugaredLogger
Types ¶
This section is empty.