feat: refactor protocol configuration handling in main and plugin

- Add protocol configuration to the `run` function in `main.go`
- Remove redundant protocol configuration from the `run` function in `main.go`
- Add proxy protocol configuration to the `run` function in `main.go`
- Add protocol configuration to the `removeAllDestFile` function in `plugin.go`
- Add proxy protocol configuration to the `removeAllDestFile` function in `plugin.go`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2024-07-19 07:50:09 +08:00
parent 7468610684
commit 2decbc4a77
No known key found for this signature in database
2 changed files with 4 additions and 1 deletions

View File

@ -278,6 +278,7 @@ func run(c *cli.Context) error {
Config: Config{
Host: c.StringSlice("host"),
Port: c.Int("port"),
Protocol: easyssh.Protocol(c.String("protocol")),
Username: c.String("username"),
Password: c.String("password"),
Passphrase: c.String("ssh-passphrase"),
@ -298,7 +299,6 @@ func run(c *cli.Context) error {
Ciphers: c.StringSlice("ciphers"),
UseInsecureCipher: c.Bool("useInsecureCipher"),
TarDereference: c.Bool("tar.dereference"),
Protocol: easyssh.Protocol(c.String("protocol")),
Proxy: easyssh.DefaultConfig{
Key: c.String("proxy.ssh-key"),
Passphrase: c.String("proxy.ssh-passphrase"),
@ -308,6 +308,7 @@ func run(c *cli.Context) error {
Password: c.String("proxy.password"),
Server: c.String("proxy.host"),
Port: c.String("proxy.port"),
Protocol: easyssh.Protocol(c.String("proxy.protocol")),
Timeout: c.Duration("proxy.timeout"),
Ciphers: c.StringSlice("proxy.ciphers"),
UseInsecureCipher: c.Bool("proxy.useInsecureCipher"),

View File

@ -123,6 +123,7 @@ func (p *Plugin) removeAllDestFile() error {
User: p.Config.Username,
Password: p.Config.Password,
Port: port,
Protocol: p.Config.Protocol,
Key: p.Config.Key,
KeyPath: p.Config.KeyPath,
Passphrase: p.Config.Passphrase,
@ -135,6 +136,7 @@ func (p *Plugin) removeAllDestFile() error {
User: p.Config.Proxy.User,
Password: p.Config.Proxy.Password,
Port: p.Config.Proxy.Port,
Protocol: p.Config.Proxy.Protocol,
Key: p.Config.Proxy.Key,
KeyPath: p.Config.Proxy.KeyPath,
Passphrase: p.Config.Proxy.Passphrase,