mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-13 14:39:28 +00:00
PT-73 Added SSL support
This commit is contained in:
@@ -71,6 +71,8 @@ type options struct {
|
||||
OrderBy []string
|
||||
Password string
|
||||
SkipCollections []string
|
||||
SSLCAFile string
|
||||
SSLPEMKeyFile string
|
||||
User string
|
||||
Version bool
|
||||
}
|
||||
@@ -527,6 +529,8 @@ func getOptions() (*options, error) {
|
||||
gop.StringVarLong(&opts.LogLevel, "log-level", 'l', "Log level: error", "panic, fatal, error, warn, info, debug. Default: error")
|
||||
gop.StringVarLong(&opts.Password, "password", 'p', "", "Password to use for optional MongoDB authentication").SetOptional()
|
||||
gop.StringVarLong(&opts.User, "username", 'u', "Username to use for optional MongoDB authentication")
|
||||
gop.StringVarLong(&opts.SSLCAFile, "sslCAFile", 0, "SSL CA cert file used for authentication")
|
||||
gop.StringVarLong(&opts.SSLPEMKeyFile, "sslPEMKeyFile", 0, "SSL client PEM file used for authentication")
|
||||
|
||||
gop.SetParameters("host[:port]/database")
|
||||
|
||||
@@ -566,25 +570,34 @@ func getOptions() (*options, error) {
|
||||
return opts, nil
|
||||
}
|
||||
|
||||
func getDialInfo(opts *options) *mgo.DialInfo {
|
||||
func getDialInfo(opts *options) *pmgo.DialInfo {
|
||||
di, _ := mgo.ParseURL(opts.Host)
|
||||
di.FailFast = true
|
||||
|
||||
if getopt.IsSet("username") {
|
||||
if di.Username != "" {
|
||||
di.Username = opts.User
|
||||
}
|
||||
if getopt.IsSet("password") {
|
||||
if di.Password != "" {
|
||||
di.Password = opts.Password
|
||||
}
|
||||
if getopt.IsSet("authenticationDatabase") {
|
||||
if opts.AuthDB != "" {
|
||||
di.Source = opts.AuthDB
|
||||
}
|
||||
|
||||
if getopt.IsSet("database") {
|
||||
if opts.Database != "" {
|
||||
di.Database = opts.Database
|
||||
}
|
||||
|
||||
return di
|
||||
pmgoDialInfo := pmgo.NewDialInfo(di)
|
||||
|
||||
if opts.SSLCAFile != "" {
|
||||
pmgoDialInfo.SSLCAFile = opts.SSLCAFile
|
||||
}
|
||||
|
||||
if opts.SSLPEMKeyFile != "" {
|
||||
pmgoDialInfo.SSLPEMKeyFile = opts.SSLPEMKeyFile
|
||||
}
|
||||
|
||||
return pmgoDialInfo
|
||||
}
|
||||
|
||||
func getQueryField(query map[string]interface{}) (map[string]interface{}, error) {
|
||||
@@ -891,7 +904,7 @@ func sortQueries(queries []stat, orderby []string) []stat {
|
||||
|
||||
}
|
||||
|
||||
func isProfilerEnabled(dialer pmgo.Dialer, di *mgo.DialInfo) (bool, error) {
|
||||
func isProfilerEnabled(dialer pmgo.Dialer, di *pmgo.DialInfo) (bool, error) {
|
||||
var ps proto.ProfilerStatus
|
||||
replicaMembers, err := util.GetReplicasetMembers(dialer, di)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user