release: alle hardcodierten IPs entfernt, Konfiguration via Env-Variablen und Auto-Discovery

This commit is contained in:
cynfo3000
2026-03-07 14:31:24 +01:00
parent c76868e806
commit 5fc46a8148
8 changed files with 57 additions and 22 deletions
+26 -1
View File
@@ -145,7 +145,7 @@ func ensureTLS(certPath, keyPath string) error {
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment,
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
BasicConstraintsValid: true,
IPAddresses: []net.IP{net.ParseIP("127.0.0.1"), net.ParseIP("192.168.85.13")},
IPAddresses: localIPs(),
DNSNames: []string{"localhost", "rmm-backend"},
}
@@ -176,3 +176,28 @@ func ensureTLS(certPath, keyPath string) error {
log.Printf("TLS-Zertifikat generiert: %s, %s", certPath, keyPath)
return nil
}
// localIPs sammelt alle lokalen IP-Adressen des Hosts für das TLS-Zertifikat
func localIPs() []net.IP {
ips := []net.IP{net.ParseIP("127.0.0.1")}
ifaces, err := net.Interfaces()
if err != nil {
return ips
}
for _, iface := range ifaces {
addrs, _ := iface.Addrs()
for _, addr := range addrs {
var ip net.IP
switch v := addr.(type) {
case *net.IPNet:
ip = v.IP
case *net.IPAddr:
ip = v.IP
}
if ip != nil && !ip.IsLoopback() && ip.To4() != nil {
ips = append(ips, ip)
}
}
}
return ips
}