utils

package
v0.0.0-...-c8940be Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultVRFIndex int = 0

If the master index of a link is 0, we consider its VRF as default VRF

View Source
const FilePathPresumedToBeStdin = "-"
View Source
const FilePathThatIsStdin = "/dev/stdin"
View Source
const VRFNameDefault = "default"
View Source
const VRFNameEmpty = ""

Variables

This section is empty.

Functions

func BirdBGPConfigDirFromCtx

func BirdBGPConfigDirFromCtx(ctx context.Context) (string, error)

func BirdControlSocketFromCtx

func BirdControlSocketFromCtx(ctx context.Context) (string, error)

func BoolPtr

func BoolPtr(b bool) *bool

func CheckVRFDiff

func CheckVRFDiff(handle *netlink.Handle, link netlink.Link, vrfName *string) (*string, error)

Returns: (vrfNameToSet, error)

func CompareBoolPointers

func CompareBoolPointers(lhs, rhs *bool) bool

func CompareInt64Pointers

func CompareInt64Pointers(lhs, rhs *int64) bool

func CompareIntPointers

func CompareIntPointers(lhs, rhs *int) bool

func CompareStringPointers

func CompareStringPointers(lhs, rhs *string) bool

func CompareStringSlices

func CompareStringSlices(lhs, rhs []string) bool

func DiffSets

func DiffSets(lhs, rhs map[string]interface{}) (map[string]interface{}, map[string]interface{})

returns: (added, removed) added is those in lhs but not rhs, removed is those in rhs but not lhs

func DockerCliFromCtx

func DockerCliFromCtx(ctx context.Context) (*client.Client, error)

func FetchHTTPConfig

func FetchHTTPConfig(url string, tlsConfig *tls.Config, username, password string) (io.Reader, error)

FetchHTTPConfig fetches configuration from an HTTP(S) endpoint

func FetchHTTPConfigReadCloser

func FetchHTTPConfigReadCloser(url string, tlsConfig *tls.Config, username, password string) (io.ReadCloser, error)

FetchHTTPConfig fetches configuration from an HTTP(S) endpoint

func GetContainerNSPid

func GetContainerNSPid(ctx context.Context, cli *client.Client, containerName string) (*int, error)

func GetCustomResolver

func GetCustomResolver(resolverEndpoint string) (*net.Resolver, error)

func GetNetNSHandle

func GetNetNSHandle(ctx context.Context, cli *client.Client, containerName string) (netns.NsHandle, error)

func GetRandomFreeUDPPort

func GetRandomFreeUDPPort() (int, error)

func GetStatefulDir

func GetStatefulDir(ctx context.Context) string

func GetTLSConfig

func GetTLSConfig(caCertPath, clientCertPath, clientKeyPath string) (*tls.Config, error)

GetTLSConfig creates a TLS configuration from the provided certificate files

func IntPtr

func IntPtr(i int) *int

func IsAllZeroKey

func IsAllZeroKey(key wgtypes.Key) bool

func IsIPNetListNotEqu

func IsIPNetListNotEqu(lhs, rhs []net.IPNet) bool

func NewURLReader

func NewURLReader(url string, options *URLReaderTransportOptions) (io.ReadCloser, error)

func NodeNameFromCtx

func NodeNameFromCtx(ctx context.Context) (string, error)

func NormalizeContainerName

func NormalizeContainerName(containerName string) string

func ParseKVPairs

func ParseKVPairs(sep string, raw string) map[string]string

func ResolvePath

func ResolvePath(path string) string

func ResolverEndpointFromCtx

func ResolverEndpointFromCtx(ctx context.Context) (string, error)

func SetBirdBGPConfigDirInCtx

func SetBirdBGPConfigDirInCtx(ctx context.Context, configDir string) context.Context

func SetBirdControlSocketInCtx

func SetBirdControlSocketInCtx(ctx context.Context, controlSocket string) context.Context

func SetClientAuthInCtx

func SetClientAuthInCtx(ctx context.Context, clientAuth *ClientAuth) context.Context

func SetDockerCliInCtx

func SetDockerCliInCtx(ctx context.Context, cli *client.Client) context.Context

func SetNodeNameInCtx

func SetNodeNameInCtx(ctx context.Context, nodeName string) context.Context

func SetResolverEndpointInCtx

func SetResolverEndpointInCtx(ctx context.Context, resolverEndpoint string) context.Context

func SetServiceNameInCtx

func SetServiceNameInCtx(ctx context.Context, serviceName string) context.Context

func SetStartedAtInCtx

func SetStartedAtInCtx(ctx context.Context, startedAt uint64) context.Context

func SetStatefulDirInCtx

func SetStatefulDirInCtx(ctx context.Context, statefulDir string) context.Context

func SetUnixSocketPathInCtx

func SetUnixSocketPathInCtx(ctx context.Context, unixSocketPath string) context.Context

func SetV6AvailableInCtx

func SetV6AvailableInCtx(ctx context.Context, v6Available bool) context.Context

func SetVersionMetadataInCtx

func SetVersionMetadataInCtx(ctx context.Context, versionMetadata map[string]string) context.Context

func StartedAtFromCtx

func StartedAtFromCtx(ctx context.Context) (uint64, error)

func StatefulDirFromCtx

func StatefulDirFromCtx(ctx context.Context) (string, error)

func StringPtr

func StringPtr(s string) *string

func TrySetVRF

func TrySetVRF(handle *netlink.Handle, link netlink.Link, vrfName *string) error

func Uint16Ptr

func Uint16Ptr(i uint16) *uint16

func UnixSocketPathFromCtx

func UnixSocketPathFromCtx(ctx context.Context) (string, error)

func V6AvailableFromCtx

func V6AvailableFromCtx(ctx context.Context) (bool, error)

func VersionMetadataFromCtx

func VersionMetadataFromCtx(ctx context.Context) (map[string]string, error)

func WithFullMask

func WithFullMask(ip *string) *string

This works the same as WithFullMaskIPNet, except that it's string in and string out.

func WithFullMaskIPNet

func WithFullMaskIPNet(ipObj net.IP) *net.IPNet

For IPv4, append /32 VLSM to make it a CIDR with full 32 bits mask, For IPv6, append /128 VLSM to make it a CIDR with full 128 bits mask.

Types

type BasicInfo

type BasicInfo struct {
	NodeName       string
	Hostname       string
	StartedAt      uint64
	Uptime         uint64
	UnixSocketPath string
}

func CollectBasicInfo

func CollectBasicInfo(ctx context.Context) (*BasicInfo, error)

type ClientAuth

type ClientAuth struct {
	TLSClientCertFile     string
	TLSClientKeyFile      string
	TLSTrustedCACertFile  string
	HTTPBasicAuthUsername string
	HTTPBasicAuthPassword string
}

func ClientAuthFromCtx

func ClientAuthFromCtx(ctx context.Context) (*ClientAuth, error)

type ContainerKey

type ContainerKey string
const (
	ContainerKeyHost ContainerKey = "-"
)

type CtxKey

type CtxKey string
const CtxKeyBirdBGPConfigDir CtxKey = "bird_bgp_config_dir"
const CtxKeyBirdControlSocket CtxKey = "bird_control_socket"
const CtxKeyClientAuth CtxKey = "client_auth"
const CtxKeyNodeName CtxKey = "node_name"
const CtxKeyResolverEndpoint CtxKey = "resolver_endpoint"
const CtxKeyStartedAt CtxKey = "started_at"
const CtxKeyUnixSocketPath CtxKey = "unix_socket_path"
const CtxKeyV6Available CtxKey = "v6_available"
const CtxKeyVersionMetadata CtxKey = "version_metadata"

type URLReader

type URLReader struct {
	// contains filtered or unexported fields
}

A object of struct type URLReader is an implementation of io.ReadCloser, it is the responsibility of the caller to close the reader

func (*URLReader) Close

func (reader *URLReader) Close() error

func (*URLReader) Read

func (reader *URLReader) Read(p []byte) (n int, err error)

type URLReaderTransportOptions

type URLReaderTransportOptions struct {
	TLSConfig *tls.Config
	Username  string
	Password  string
}

Jump to

Keyboard shortcuts

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