Skip to content

Commit

Permalink
Fix Nil pointers in WebSystemdSocket
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan J. Gallant <ethan.gallant@acquia.com>

Co-authored-by: William Van Hevelingen <William.VanHevelingen@acquia.com>

Co-authored-by: Stephanie Palis <35511514+stephpalis@users.noreply.github.com>
  • Loading branch information
ethan-gallant and stephpalis committed Mar 8, 2023
1 parent c5c3d5b commit 4f173ac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web/tls_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ func ServeMultiple(listeners []net.Listener, server *http.Server, flags *FlagCon
// WebSystemdSocket in the FlagConfig is true. The FlagConfig is also passed on
// to ServeMultiple.
func ListenAndServe(server *http.Server, flags *FlagConfig, logger log.Logger) error {
if *flags.WebSystemdSocket {
if flags.WebSystemdSocket == nil && (flags.WebListenAddresses == nil || len(*flags.WebListenAddresses) == 0) {
return errors.New("no web listen address or systemd socket flag specified")
}

if flags.WebSystemdSocket != nil && *flags.WebSystemdSocket {
level.Info(logger).Log("msg", "Listening on systemd activated listeners instead of port listeners.")
listeners, err := activation.Listeners()
if err != nil {
Expand All @@ -214,6 +218,7 @@ func ListenAndServe(server *http.Server, flags *FlagConfig, logger log.Logger) e
}
return ServeMultiple(listeners, server, flags, logger)
}

listeners := make([]net.Listener, 0, len(*flags.WebListenAddresses))
for _, address := range *flags.WebListenAddresses {
listener, err := net.Listen("tcp", address)
Expand Down

0 comments on commit 4f173ac

Please sign in to comment.