fix(plugin): prevent panic when ListenHosts is empty (#7565)

This commit is contained in:
Ville Vesilehto
2025-09-19 13:59:37 +03:00
committed by GitHub
parent 051d8d6f05
commit 5532ba8484
3 changed files with 29 additions and 2 deletions

View File

@@ -37,7 +37,7 @@ func traceParse(c *caddy.Controller) (*trace, error) {
)
cfg := dnsserver.GetConfig(c)
if cfg.ListenHosts[0] != "" {
if len(cfg.ListenHosts) > 0 && cfg.ListenHosts[0] != "" {
tr.serviceEndpoint = cfg.ListenHosts[0] + ":" + cfg.Port
}