utils

package
v0.0.0-...-5f17d81 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CertFilePermissions = 0644
	KeyFilePermissions  = 0600
	MinTLSVersion       = tls.VersionTLS12
	MaxTLSVersion       = tls.VersionTLS13
)

Variables

View Source
var (
	Logger *logger.Logger

	LogLevelMap = map[string]int{
		"debug":    100,
		"info":     200,
		"notice":   300,
		"warning":  400,
		"error":    500,
		"critical": 502,
		"alert":    509,
	}
)

Functions

func ArePortsReachable

func ArePortsReachable(ip string, ports ...string) error

func CheckIfPathExist

func CheckIfPathExist(path string) bool

func CheckIfServiceIsInstalled

func CheckIfServiceIsInstalled(serv string) (bool, error)

func CreateLinuxService

func CreateLinuxService(serviceName string, execStart string) error

func CreatePathIfNotExist

func CreatePathIfNotExist(path string) error

func DoReq

func DoReq[response any](url string, data []byte, method string, headers map[string]string, skipTlsVerification bool) (response, int, error)

func DownloadFile

func DownloadFile(url string, headers map[string]string, fileName string, path string, skipTlsVerification bool) error

func Execute

func Execute(c string, dir string, arg ...string) error

func ExecuteWithResult

func ExecuteWithResult(c string, dir string, arg ...string) (string, bool)

func FindLatestLog

func FindLatestLog(path string, pattern *regexp.Regexp) (string, error)

func GenerateFromTemplate

func GenerateFromTemplate(data interface{}, templateFile string, configFile string) error

func GenerateKey

func GenerateKey(baseKey string) ([]byte, error)

func GenerateKeyByUUID

func GenerateKeyByUUID(baseKey string, uuid string) ([]byte, error)

func GetHostAliases

func GetHostAliases(hostname string) ([]string, error)

func GetIPAddress

func GetIPAddress() (string, error)

func GetMyPath

func GetMyPath() string

func IncrementReconnectDelay

func IncrementReconnectDelay(delay time.Duration, maxReconnectDelay time.Duration) time.Duration

func InitLogger

func InitLogger(filename string)

func IsDirEmpty

func IsDirEmpty(path string) (bool, error)

func LoadGRPCTLSCredentials

func LoadGRPCTLSCredentials(crtName string) (credentials.TransportCredentials, error)

func LoadHTTPTLSCredentials

func LoadHTTPTLSCredentials(crtName string) (*tls.Config, error)

func LoadIntegrationTLSConfig

func LoadIntegrationTLSConfig(certPath, keyPath string) (*tls.Config, error)

func LoadUserCertificatesWithStruct

func LoadUserCertificatesWithStruct(src, dest CertificateFiles) error

func PrintBanner

func PrintBanner()

func ReadFileLines

func ReadFileLines(path string) ([]string, error)

func ReadJson

func ReadJson(fileName string, data interface{}) error

func ReadYAML

func ReadYAML(path string, result interface{}) error

func StopService

func StopService(name string) error

func TailLogFile

func TailLogFile(filePath string, logLinesChan chan string, stopChan chan bool)

func UninstallService

func UninstallService(name string) error

func Unzip

func Unzip(zipFile, destPath string) error

func ValidateIntegrationCertificates

func ValidateIntegrationCertificates(certPath, keyPath string) error

func WatchFolder

func WatchFolder(logType string, logsPath string, logLinesChan chan string)

func WriteJSON

func WriteJSON(path string, data interface{}) error

func WriteStringToFile

func WriteStringToFile(fileName string, body string) error

func WriteYAML

func WriteYAML(url string, data interface{}) error

Types

type CertificateFiles

type CertificateFiles struct {
	CertPath string
	KeyPath  string
	CAPath   string
}

type LogLevels

type LogLevels struct {
	Level string `yaml:"level"`
}

type OSInfo

type OSInfo struct {
	Hostname       string
	OsType         string
	Platform       string
	CurrentUser    string
	Mac            string
	OsMajorVersion string
	OsMinorVersion string
	Aliases        string
	Addresses      string
}

func GetOsInfo

func GetOsInfo() (OSInfo, error)

type TLSStatus

type TLSStatus struct {
	Available  bool   `json:"available"`
	CertExists bool   `json:"cert_exists"`
	KeyExists  bool   `json:"key_exists"`
	CAExists   bool   `json:"ca_exists"`
	Valid      bool   `json:"valid"`
	Error      string `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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