feat(sol): UDP + HTTP listener

This commit is contained in:
Björn Benouarets
2025-11-11 17:19:49 +01:00
commit 8ed56f7ba0
12 changed files with 565 additions and 0 deletions

50
utils/env.go Normal file
View File

@@ -0,0 +1,50 @@
package utils
import (
"os"
"strconv"
"git.secnex.io/secnex/masterlog"
)
func GetEnv(key string, defaultValue string) string {
value := os.Getenv(key)
if value == "" {
return defaultValue
}
return value
}
func GetStringFromEnv(key string, defaultValue string) string {
return GetEnv(key, defaultValue)
}
func GetIntFromEnv(key string, defaultValue int) int {
value := os.Getenv(key)
if value == "" {
return defaultValue
}
intValue, err := strconv.Atoi(value)
if err != nil {
return defaultValue
}
return intValue
}
func GetBoolFromEnv(key string, defaultValue bool) bool {
value := os.Getenv(key)
if value == "" {
return defaultValue
}
if value == "true" || value == "TRUE" || value == "True" || value == "1" {
return true
} else {
masterlog.Error("Invalid environment variable value", map[string]interface{}{
"variable": key,
"value": value,
"type": "boolean",
})
return false
}
}