Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --http-host flag to support IPv6 #1620

Merged
merged 2 commits into from
Jun 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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