1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

libnetwork/diagnostic: EnableDiagnostic(): use net.JoinHostPort

Use net.JoinHostPort to account for IPv6 addresses.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit a33d1f9a7c)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-09-04 15:36:00 +02:00
parent b5a0d7a188
commit ff4ec67b90
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -4,7 +4,9 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net"
"net/http" "net/http"
"strconv"
"sync" "sync"
"sync/atomic" "sync/atomic"
@ -91,7 +93,10 @@ func (s *Server) EnableDiagnostic(ip string, port int) {
} }
logrus.Infof("Starting the diagnostic server listening on %d for commands", port) logrus.Infof("Starting the diagnostic server listening on %d for commands", port)
srv := &http.Server{Addr: fmt.Sprintf("%s:%d", ip, port), Handler: s} srv := &http.Server{
Addr: net.JoinHostPort(ip, strconv.Itoa(port)),
Handler: s,
}
s.srv = srv s.srv = srv
s.enable = 1 s.enable = 1
go func(n *Server) { go func(n *Server) {