Skip to content

Commit

Permalink
Export TLS Handler fields
Browse files Browse the repository at this point in the history
Signed-off-by: Shaad7 <[email protected]>
  • Loading branch information
AbdullahAlShaad authored May 10, 2023
2 parents 2f2a7ce + 195f8ab commit a453f30
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 36 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/yannh/redis-dump-go
go 1.18

require (
github.com/mediocregopher/radix/v3 v3.8.0
github.com/mediocregopher/radix/v3 v3.8.1
github.com/pkg/errors v0.9.1
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/mediocregopher/radix/v3 v3.8.0 h1:HI8EgkaM7WzsrFpYAkOXIgUKbjNonb2Ne7K6Le61Pmg=
github.com/mediocregopher/radix/v3 v3.8.0/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8=
github.com/mediocregopher/radix/v3 v3.8.1 h1:rOkHflVuulFKlwsLY01/M2cM2tWCjDoETcMqKbAWu1M=
github.com/mediocregopher/radix/v3 v3.8.1/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
28 changes: 14 additions & 14 deletions pkg/redisdump/tlsutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ import (
)

type TlsHandler struct {
skipVerify bool
caCertPath string
certPath string
keyPath string
SkipVerify bool
CACertPath string
CertPath string
KeyPath string
}

func NewTlsHandler(caCertPath, certPath, keyPath string, insecure bool) (*TlsHandler, error) {
if caCertPath == "" && certPath == "" && keyPath == "" {
if insecure {
return &TlsHandler{
skipVerify: true,
SkipVerify: true,
}, nil
} else {
return nil, errors.New("no cert is set. if skip cert validation to set -insecure option")
}
}

return &TlsHandler{
skipVerify: false,
caCertPath: caCertPath,
certPath: certPath,
keyPath: keyPath,
SkipVerify: false,
CACertPath: caCertPath,
CertPath: certPath,
KeyPath: keyPath,
}, nil
}

Expand All @@ -39,16 +39,16 @@ func tlsConfig(tlsHandler *TlsHandler) (*tls.Config, error) {
return nil, nil
}

if tlsHandler.skipVerify {
if tlsHandler.SkipVerify {
return &tls.Config{
InsecureSkipVerify: true,
}, nil
}

certPool := x509.NewCertPool()
// ca cert is optional
if tlsHandler.caCertPath != "" {
pem, err := ioutil.ReadFile(tlsHandler.caCertPath)
if tlsHandler.CACertPath != "" {
pem, err := ioutil.ReadFile(tlsHandler.CACertPath)
if err != nil {
return nil, fmt.Errorf("connectionpool: unable to open CA certs: %v", err)
}
Expand All @@ -63,8 +63,8 @@ func tlsConfig(tlsHandler *TlsHandler) (*tls.Config, error) {
RootCAs: certPool,
}

if tlsHandler.certPath != "" && tlsHandler.keyPath != "" {
cert, err := tls.LoadX509KeyPair(tlsHandler.certPath, tlsHandler.keyPath)
if tlsHandler.CertPath != "" && tlsHandler.KeyPath != "" {
cert, err := tls.LoadX509KeyPair(tlsHandler.CertPath, tlsHandler.KeyPath)
if err != nil {
return nil, err
}
Expand Down
10 changes: 10 additions & 0 deletions vendor/github.com/mediocregopher/radix/v3/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/mediocregopher/radix/v3/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 19 additions & 6 deletions vendor/github.com/mediocregopher/radix/v3/cluster.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 43 additions & 12 deletions vendor/github.com/mediocregopher/radix/v3/cluster_topo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# github.com/mediocregopher/radix/v3 v3.8.0
# github.com/mediocregopher/radix/v3 v3.8.1
## explicit; go 1.13
github.com/mediocregopher/radix/v3
github.com/mediocregopher/radix/v3/internal/bytesutil
Expand Down

0 comments on commit a453f30

Please sign in to comment.