|
6 | 6 | "fmt"
|
7 | 7 | "net"
|
8 | 8 | "runtime"
|
| 9 | + "strconv" |
9 | 10 | "strings"
|
10 | 11 | "time"
|
11 | 12 |
|
@@ -318,7 +319,7 @@ func (h *Handler) handleDefault(w dns.ResponseWriter, req *dns.Msg) {
|
318 | 319 | logrus.Tracef("handleDefault for %v", req)
|
319 | 320 | for _, client := range h.clients {
|
320 | 321 | for _, srv := range h.clientConfig.Servers {
|
321 |
| - addr := fmt.Sprintf("%s:%s", srv, h.clientConfig.Port) |
| 322 | + addr := net.JoinHostPort(srv, h.clientConfig.Port) |
322 | 323 | reply, _, err := client.Exchange(req, addr)
|
323 | 324 | if err != nil {
|
324 | 325 | logrus.WithError(err).Debugf("handleDefault failed to perform a synchronous query with upstream [%v]", addr)
|
@@ -378,9 +379,9 @@ func listenAndServe(network Network, opts ServerOptions) (*dns.Server, error) {
|
378 | 379 | // always enable reply truncate for UDP
|
379 | 380 | if network == UDP {
|
380 | 381 | opts.HandlerOptions.TruncateReply = true
|
381 |
| - addr = fmt.Sprintf("%s:%d", opts.Address, opts.UDPPort) |
| 382 | + addr = net.JoinHostPort(opts.Address, strconv.Itoa(opts.UDPPort)) |
382 | 383 | } else {
|
383 |
| - addr = fmt.Sprintf("%s:%d", opts.Address, opts.TCPPort) |
| 384 | + addr = net.JoinHostPort(opts.Address, strconv.Itoa(opts.TCPPort)) |
384 | 385 | }
|
385 | 386 | h, err := NewHandler(opts.HandlerOptions)
|
386 | 387 | if err != nil {
|
|
0 commit comments