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

feat: adds support to include tls ver in ts #568 #569

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions internal/client/observe/observe.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ package observe

import (
"encoding/json"
"internal/apiclient"
"net/url"
"path"
"strconv"
"strings"

"internal/apiclient"
)

type Action uint8
Expand Down
25 changes: 20 additions & 5 deletions internal/client/targetservers/targetservers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ type commonName struct {
}

// Create
func Create(name string, description string, host string, port int, enable bool, protocol string, keyStore string, keyAlias string, trustStore string, tlsenabled string, tlsenforce string, clientAuthEnabled string, ignoreValidationErrors string) (respBody []byte, err error) {
func Create(name string, description string, host string, port int, enable bool, protocol string,
keyStore string, keyAlias string, trustStore string, tlsenabled string, tlsenforce string,
clientAuthEnabled string, tlsVersions []string, ignoreValidationErrors string,
) (respBody []byte, err error) {
e := new(bool)
*e = enable

Expand All @@ -69,11 +72,15 @@ func Create(name string, description string, host string, port int, enable bool,
IsEnabled: e,
}

return createOrUpdate("create", targetsvr, name, description, host, port, protocol, keyStore, keyAlias, trustStore, tlsenabled, tlsenforce, clientAuthEnabled, ignoreValidationErrors)
return createOrUpdate("create", targetsvr, name, description, host, port, protocol,
keyStore, keyAlias, trustStore, tlsenabled, tlsenforce, clientAuthEnabled, tlsVersions, ignoreValidationErrors)
}

// Update
func Update(name string, description string, host string, port int, enable bool, protocol string, keyStore string, keyAlias string, trustStore string, tlsenabled string, tlsenforce string, clientAuthEnabled string, ignoreValidationErrors string) (respBody []byte, err error) {
func Update(name string, description string, host string, port int, enable bool, protocol string,
keyStore string, keyAlias string, trustStore string, tlsenabled string, tlsenforce string,
clientAuthEnabled string, tlsVersions []string, ignoreValidationErrors string,
) (respBody []byte, err error) {
apiclient.ClientPrintHttpResponse.Set(false)
targetRespBody, err := Get(name)
if err != nil {
Expand All @@ -88,10 +95,15 @@ func Update(name string, description string, host string, port int, enable bool,

targetsvr.IsEnabled = &enable

return createOrUpdate("update", targetsvr, name, description, host, port, protocol, keyStore, keyAlias, trustStore, tlsenabled, tlsenforce, clientAuthEnabled, ignoreValidationErrors)
return createOrUpdate("update", targetsvr, name, description, host, port, protocol, keyStore,
keyAlias, trustStore, tlsenabled, tlsenforce, clientAuthEnabled, tlsVersions, ignoreValidationErrors)
}

func createOrUpdate(action string, targetsvr targetserver, name string, description string, host string, port int, protocol string, keyStore string, keyAlias string, trustStore string, tlsenabled string, tlsenforce string, clientAuthEnabled string, ignoreValidationErrors string) (respBody []byte, err error) {
func createOrUpdate(action string, targetsvr targetserver, name string, description string,
host string, port int, protocol string, keyStore string, keyAlias string, trustStore string,
tlsenabled string, tlsenforce string, clientAuthEnabled string, tlsVersions []string,
ignoreValidationErrors string,
) (respBody []byte, err error) {
if description != "" {
targetsvr.Description = description
}
Expand Down Expand Up @@ -126,6 +138,9 @@ func createOrUpdate(action string, targetsvr targetserver, name string, descript
if ignoreValidationErrors != "" {
targetsvr.SslInfo.IgnoreValidationErrors = getBool(ignoreValidationErrors)
}
if len(tlsVersions) != 0 {
targetsvr.SslInfo.Protocols = tlsVersions
}
}

reqBody, err := json.Marshal(targetsvr)
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/targetservers/crtts.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var CreateCmd = &cobra.Command{
protocol,
keyStore, keyAlias, trustStore,
tlsenabled, tlsenforce, clientAuthEnabled,
tlsVersions,
ignoreValidationErrors)
return err
},
Expand All @@ -72,6 +73,7 @@ var CreateCmd = &cobra.Command{
var (
tlsenabled, tlsenforce, clientAuthEnabled, description, host, keyStore, keyAlias string
trustStore, protocol, ignoreValidationErrors string
tlsVersions []string
enable bool
port int
)
Expand Down Expand Up @@ -107,6 +109,9 @@ func init() {
CreateCmd.Flags().StringVarP(&protocol, "protocol", "",
"HTTP", "Protocol for a TargetServer; default is HTTP")

CreateCmd.Flags().StringArrayVarP(&tlsVersions, "tls-versions", "",
nil, "TLS versions for the target server")

_ = CreateCmd.MarkFlagRequired("name")
_ = CreateCmd.MarkFlagRequired("host")
}
4 changes: 4 additions & 0 deletions internal/cmd/targetservers/updatets.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var UpdateCmd = &cobra.Command{
protocol,
keyStore, keyAlias, trustStore,
tlsenabled, tlsenforce, clientAuthEnabled,
tlsVersions,
ignoreValidationErrors)
return err
},
Expand Down Expand Up @@ -100,5 +101,8 @@ func init() {
UpdateCmd.Flags().StringVarP(&protocol, "protocol", "",
"", "Protocol for a TargetServer")

UpdateCmd.Flags().StringArrayVarP(&tlsVersions, "tls-versions", "",
nil, "TLS versions for the target server")

_ = UpdateCmd.MarkFlagRequired("name")
}
Loading