From 7b21819b020e5962fcbe1cd2d0850d1300fa60f6 Mon Sep 17 00:00:00 2001 From: Jackie Luc <15662837+jackieluc@users.noreply.github.com> Date: Tue, 11 Jun 2024 09:44:39 -0700 Subject: [PATCH] refactor: remove redundant check for TLSSettings.TLSPort --- cns/service.go | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/cns/service.go b/cns/service.go index 147c41051d..b46dde7041 100644 --- a/cns/service.go +++ b/cns/service.go @@ -103,23 +103,21 @@ func (service *Service) AddListener(config *common.ServiceConfig) error { // only use TLS connection for DNC/CNS listener: if config.TLSSettings.TLSPort != "" { - if config.TLSSettings.TLSPort != "" { - // listener.URL.Host will always be hostname:port, passed in to CNS via CNS command - // else it will default to localhost - // extract hostname and override tls port. - hostParts := strings.Split(nodeListener.URL.Host, ":") - tlsAddress := net.JoinHostPort(hostParts[0], config.TLSSettings.TLSPort) - - // Start the listener and HTTP and HTTPS server. - tlsConfig, err := getTLSConfig(config.TLSSettings, config.ErrChan) //nolint - if err != nil { - log.Printf("Failed to compose Tls Configuration with error: %+v", err) - return errors.Wrap(err, "could not get tls config") - } + // listener.URL.Host will always be hostname:port, passed in to CNS via CNS command + // else it will default to localhost + // extract hostname and override tls port. + hostParts := strings.Split(nodeListener.URL.Host, ":") + tlsAddress := net.JoinHostPort(hostParts[0], config.TLSSettings.TLSPort) + + // Start the listener and HTTP and HTTPS server. + tlsConfig, err := getTLSConfig(config.TLSSettings, config.ErrChan) //nolint + if err != nil { + log.Printf("Failed to compose Tls Configuration with error: %+v", err) + return errors.Wrap(err, "could not get tls config") + } - if err := nodeListener.StartTLS(config.ErrChan, tlsConfig, tlsAddress); err != nil { - return errors.Wrap(err, "could not start tls") - } + if err := nodeListener.StartTLS(config.ErrChan, tlsConfig, tlsAddress); err != nil { + return errors.Wrap(err, "could not start tls") } }