This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 188
feat(encrypt): Support both encrypted and unencrypted passwords for the upstream and downstream database #633
Merged
csuzhangxc
merged 14 commits into
pingcap:master
from
Kur-Public:feature/kurisu-support-unencrypted-pw-in-toml-200423
May 20, 2020
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bc8bac5
feat: add support encrypted and unencrypted in config file
Kuri-su d84aece
Merge branch 'master' into feature/kurisu-support-unencrypted-pw-in-t…
Kuri-su 53ebb15
fix():
Kuri-su 438169f
Merge branch 'master' into feature/kurisu-support-unencrypted-pw-in-t…
Kuri-su eb8f7e1
fix(test): test case
Kuri-su bf05b56
Merge branch 'master' into feature/kurisu-support-unencrypted-pw-in-t…
Kuri-su 8912fac
Merge branch 'master' into feature/kurisu-support-unencrypted-pw-in-t…
Kuri-su b011dee
Merge branch 'master' into feature/kurisu-support-unencrypted-pw-in-t…
Kuri-su 9f7ad8d
fix: test case
Kuri-su 7b70831
Merge branch 'master' into feature/kurisu-support-unencrypted-pw-in-t…
Kuri-su 07eabac
fix(master/server_test): testCase comment
Kuri-su 34778da
fix(tests): add testcases
Kuri-su bde723b
fix(descrypt): clean code && add testCase
Kuri-su 870c528
Merge branch 'master' into feature/kurisu-support-unencrypted-pw-in-t…
Kuri-su File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ const ( | |
|
||
// EncryptCmdName is special command | ||
EncryptCmdName = "encrypt" | ||
// DecryptCmdName is special command | ||
DecryptCmdName = "decrypt" | ||
) | ||
|
||
// NewConfig creates a new base config for dmctl. | ||
|
@@ -47,6 +49,7 @@ func NewConfig() *Config { | |
fs.StringVar(&cfg.MasterAddr, "master-addr", "", "master API server addr") | ||
fs.StringVar(&cfg.RPCTimeoutStr, "rpc-timeout", defaultRPCTimeout, fmt.Sprintf("rpc timeout, default is %s", defaultRPCTimeout)) | ||
fs.StringVar(&cfg.encrypt, EncryptCmdName, "", "encrypt plaintext to ciphertext") | ||
fs.StringVar(&cfg.decrypt, DecryptCmdName, "", "decrypt ciphertext to plaintext") | ||
|
||
return cfg | ||
} | ||
|
@@ -64,6 +67,7 @@ type Config struct { | |
|
||
printVersion bool | ||
encrypt string // string need to be encrypted | ||
decrypt string // string need to be decrypted | ||
} | ||
|
||
func (c *Config) String() string { | ||
|
@@ -95,6 +99,15 @@ func (c *Config) Parse(arguments []string) (finish bool, err error) { | |
return true, nil | ||
} | ||
|
||
if len(c.decrypt) > 0 { | ||
plaintext, err1 := utils.Decrypt(c.decrypt) | ||
if err1 != nil { | ||
return true, err1 | ||
} | ||
fmt.Println(plaintext) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line should be deleted There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we are shouldn't delete these lines, because the |
||
return true, nil | ||
} | ||
|
||
// Load config file if specified. | ||
if c.ConfigFile != "" { | ||
err = c.configFromFile(c.ConfigFile) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about adding test case config with encrypt password?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i have added a testCase about encrypt password