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

[CNS] refactor: remove redundant check for TLSSettings.TLSPort #2780

Merged
merged 1 commit into from
Jun 14, 2024
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
30 changes: 14 additions & 16 deletions cns/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down
Loading