services -> domains
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/wild-cloud/wild-central/internal/certbot"
|
||||
"github.com/wild-cloud/wild-central/internal/config"
|
||||
"github.com/wild-cloud/wild-central/internal/services"
|
||||
"github.com/wild-cloud/wild-central/internal/domains"
|
||||
)
|
||||
|
||||
// CertStatus returns TLS certificate status for all relevant domains:
|
||||
@@ -24,31 +24,30 @@ func (api *API) CertStatus(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
cfToken := api.getCloudflareToken()
|
||||
|
||||
// Gather cert statuses for all registered services that need TLS termination
|
||||
// Gather cert statuses for all registered domains that need TLS termination
|
||||
certs := []map[string]any{}
|
||||
seen := map[string]bool{}
|
||||
|
||||
svcs, _ := api.services.List()
|
||||
for _, svc := range svcs {
|
||||
if svc.TLS != services.TLSTerminate || svc.Domain == "" {
|
||||
doms, _ := api.domains.List()
|
||||
for _, dom := range doms {
|
||||
if dom.TLS != domains.TLSTerminate || dom.DomainName == "" {
|
||||
continue
|
||||
}
|
||||
if seen[svc.Domain] {
|
||||
if seen[dom.DomainName] {
|
||||
continue
|
||||
}
|
||||
seen[svc.Domain] = true
|
||||
seen[dom.DomainName] = true
|
||||
|
||||
status := api.certbot.GetStatus(svc.Domain)
|
||||
status := api.certbot.GetStatus(dom.DomainName)
|
||||
|
||||
entry := map[string]any{
|
||||
"domain": svc.Domain,
|
||||
"service": svc.Domain,
|
||||
"source": svc.Source,
|
||||
"cert": status,
|
||||
"domain": dom.DomainName,
|
||||
"source": dom.Source,
|
||||
"cert": status,
|
||||
}
|
||||
|
||||
// Check if covered by a wildcard cert
|
||||
parts := strings.SplitN(svc.Domain, ".", 2)
|
||||
parts := strings.SplitN(dom.DomainName, ".", 2)
|
||||
if len(parts) == 2 && !status.Exists {
|
||||
wildcardBase := parts[1]
|
||||
wildcardStatus := api.certbot.GetStatus(wildcardBase)
|
||||
|
||||
Reference in New Issue
Block a user