Skip to content

Commit

Permalink
Fix --http-host flag to support IPv6 (#1620)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Jun 14, 2023
1 parent cc69f03 commit 9374b56
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type server struct {
factory logging.Factory
// Listens for HTTP traffic on this address
listenHost string
listenPort uint16
listenPort string

shutdownTimeout time.Duration

Expand Down Expand Up @@ -154,7 +154,7 @@ func New(
log: log,
factory: factory,
listenHost: host,
listenPort: port,
listenPort: fmt.Sprintf("%d", port),
shutdownTimeout: shutdownTimeout,
tracingEnabled: tracingEnabled,
tracer: tracer,
Expand All @@ -171,7 +171,7 @@ func New(
}

func (s *server) Dispatch() error {
listenAddress := fmt.Sprintf("%s:%d", s.listenHost, s.listenPort)
listenAddress := net.JoinHostPort(s.listenHost, s.listenPort)
listener, err := net.Listen("tcp", listenAddress)
if err != nil {
return err
Expand All @@ -193,7 +193,7 @@ func (s *server) Dispatch() error {
}

func (s *server) DispatchTLS(certBytes, keyBytes []byte) error {
listenAddress := fmt.Sprintf("%s:%d", s.listenHost, s.listenPort)
listenAddress := net.JoinHostPort(s.listenHost, s.listenPort)
cert, err := tls.X509KeyPair(certBytes, keyBytes)
if err != nil {
return err
Expand Down

0 comments on commit 9374b56

Please sign in to comment.