Support IPv6 service endpoints in trace plugin (#8410)

Use net.JoinHostPort rather than string concatenation to support
both ipv4, ipv6, and hostname service endpoints for the trace
plugin. Previously, ipv6 bind addresses in the coredns configuration
would fail to be parsed, as the ipv6 address was not surrounded in
brackets.

Signed-off-by: Michael Wolf <mwolf@cloudflare.com>

Closes #8409

Co-authored-by: Michael Wolf <mwolf@cloudflare.com>
This commit is contained in:
Michael Wolf
2026-08-05 21:10:34 -07:00
committed by GitHub
parent 419869ebac
commit c7e5424e7c
2 changed files with 56 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package trace
import (
"fmt"
"net"
"strconv"
"strings"
"time"
@@ -38,7 +39,7 @@ func traceParse(c *caddy.Controller) (*trace, error) {
cfg := dnsserver.GetConfig(c)
if len(cfg.ListenHosts) > 0 && cfg.ListenHosts[0] != "" {
tr.serviceEndpoint = cfg.ListenHosts[0] + ":" + cfg.Port
tr.serviceEndpoint = net.JoinHostPort(cfg.ListenHosts[0], cfg.Port)
}
for c.Next() { // trace