Skip to content

Utility Go-API

import "givc/modules/pkgs/utility"

SPDX-FileCopyrightText: 2024-2026 TII (SSRC) and the Ghaf contributors SPDX-License-Identifier: Apache-2.0

SPDX-FileCopyrightText: 2024-2026 TII (SSRC) and the Ghaf contributors SPDX-License-Identifier: Apache-2.0

var (
CIPHER_SUITES = []uint16{
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
}
)

func CertIPVerifyStreamInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

func CertIPVerifyUnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)

func CheckStringInArray(element string, array []string) bool

func FindCGroupPath(serviceName string) (string, error)

func GetCGroupPathForProcess(pid uint32) (string, error)

func GetFqdn(addrs []net.IP) (string, error)

func GetHostname() (string, error)

func GetInterfaceIpv4(ifname string) (string, error)

func GetInterfaceIpv4Dns(hostname string) (string, error)

func GetIps(hostname string) ([]net.IP, error)

func GetOutboundIP() net.IP

func IsRoot() bool

func IsUser(username string) bool

func ParseVsockAddress(addr string) (uint32, uint32, error)

func TlsClientConfig(cacertFilePath string, certFilePath string, keyFilePath string, serverName string) (*tls.Config, error)

func TlsClientConfigFromTlsConfig(tlsConfig *tls.Config, serverName string) (*tls.Config, error)

func TlsServerConfig(cacertFilePath string, certFilePath string, keyFilePath string, mutual bool) (*tls.Config, error)

func extractIPFromAddr(addr net.Addr) (net.IP, error)

extractIPFromAddr extracts the IP address from a net.Addr

func ipInCertSAN(cert *x509.Certificate, ip net.IP) bool

ipInCertSAN checks if the given IP is in the certificate’s SubjectAltName IP addresses

func verifyPeerIP(ctx context.Context, addr net.Addr) error

verifyPeerIP contains the shared logic for both unary and stream interceptors.

Generated by gomarkdoc