fix: Prevent broken dnsmasq entries for services without internal domain

Services registered via the service API have a domain but no internal
domain (that's a Wild Cloud instance concept). The dnsmasq generator
was producing broken entries like `local=//` and `address=//`.

Fix: skip internal domain entries when InternalDomain is empty, in
both config.go and config_modular.go. Also fix DNS entries to point
to Central's IP (where HAProxy listens) rather than the backend
address — all traffic flows through Central.

Added 3 tests covering: service-only, mixed services+instances.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-09 14:11:24 +00:00
parent c7a0227e03
commit e4e1a15f92
4 changed files with 95 additions and 13 deletions

View File

@@ -11,6 +11,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/haproxy"
"github.com/wild-cloud/wild-central/internal/network"
"github.com/wild-cloud/wild-central/internal/services"
"github.com/wild-cloud/wild-central/internal/sse"
)
@@ -81,8 +82,14 @@ func (api *API) reconcileNetworking() {
}
}
// Generate dnsmasq DNS entries from registered services
// Build instance configs for backward compatibility with dnsmasq generator
// Generate dnsmasq DNS entries from registered services.
// All service domains resolve to Central's IP (where HAProxy listens).
// HAProxy then routes to the actual backend based on SNI or Host header.
centralIP, _ := network.GetWildCentralIP()
if centralIP == "" {
centralIP = "127.0.0.1"
}
var instanceConfigs []config.InstanceConfig
for _, svc := range svcs {
if svc.Reach == services.ReachOff || svc.Domain == "" {
@@ -90,7 +97,7 @@ func (api *API) reconcileNetworking() {
}
ic := config.InstanceConfig{}
ic.Cloud.Domain = svc.Domain
ic.Cluster.LoadBalancerIp = extractHost(svc.Backend.Address)
ic.Cluster.LoadBalancerIp = centralIP // DNS points to Central, not the backend
instanceConfigs = append(instanceConfigs, ic)
}