Skip to content

Commit

Permalink
dns fanout: wrap IPv6 address (#1374)
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
  • Loading branch information
glazychev-art authored Dec 15, 2022
1 parent bb4ba1a commit fa94b07
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/tools/dnsutils/fanout/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"fmt"
"net/url"
"strings"
"time"

"github.com/miekg/dns"
Expand Down Expand Up @@ -55,6 +56,11 @@ func (h *fanoutHandler) ServeDNS(ctx context.Context, rw dns.ResponseWriter, msg
Timeout: timeout,
}

// If u.Host is IPv6 then wrap it in brackets
if strings.Count(u.Host, ":") >= 2 && !strings.HasPrefix(u.Host, "[") && !strings.Contains(u.Host, "]") {
u.Host = fmt.Sprintf("[%s]", u.Host)
}

address := u.Host
if u.Port() == "" {
address += fmt.Sprintf(":%d", h.dnsPort)
Expand Down

0 comments on commit fa94b07

Please sign in to comment.