implemented bind address environment variable.

This commit is contained in:
2025-12-30 17:08:20 +01:00
parent 99dd77e375
commit ad6f86146d
5 changed files with 44 additions and 11 deletions

View File

@@ -25,6 +25,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net"
"os"
"path/filepath"
"regexp"
@@ -1396,6 +1397,22 @@ func GetPortFromEnv() (int, bool) {
return 0, false
}
// GetBindAddressFromEnv returns the BIND_ADDRESS environment variable value if set, and whether it's set
// If not set, returns "0.0.0.0" as the default bind address
// Validates that the address is a valid IP address format
func GetBindAddressFromEnv() (string, bool) {
bindAddrEnv := os.Getenv("BIND_ADDRESS")
if bindAddrEnv == "" {
return "0.0.0.0", false
}
// Validate that it's a valid IP address format using net.ParseIP
if ip := net.ParseIP(bindAddrEnv); ip != nil {
return bindAddrEnv, true
}
// Invalid format, return default
return "0.0.0.0", false
}
func GetSettings() AppSettings {
settingsLock.RLock()
defer settingsLock.RUnlock()