mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-25 09:00:27 +00:00
sftpfs: add a dial timeout
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
97122ef06c
commit
d3fee39388
1 changed files with 4 additions and 0 deletions
|
@ -751,11 +751,13 @@ func (fs *SFTPFs) createConnection() error {
|
||||||
fsLog(fs, logger.LevelWarn, "login without host key validation, please provide at least a fingerprint!")
|
fsLog(fs, logger.LevelWarn, "login without host key validation, please provide at least a fingerprint!")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
Timeout: 10 * time.Second,
|
||||||
ClientVersion: fmt.Sprintf("SSH-2.0-SFTPGo_%v", version.Get().Version),
|
ClientVersion: fmt.Sprintf("SSH-2.0-SFTPGo_%v", version.Get().Version),
|
||||||
}
|
}
|
||||||
if fs.config.PrivateKey.GetPayload() != "" {
|
if fs.config.PrivateKey.GetPayload() != "" {
|
||||||
signer, err := ssh.ParsePrivateKey([]byte(fs.config.PrivateKey.GetPayload()))
|
signer, err := ssh.ParsePrivateKey([]byte(fs.config.PrivateKey.GetPayload()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fsLog(fs, logger.LevelError, "unable to parse the provided private key: %v", err)
|
||||||
fs.err <- err
|
fs.err <- err
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -766,11 +768,13 @@ func (fs *SFTPFs) createConnection() error {
|
||||||
}
|
}
|
||||||
fs.sshClient, err = ssh.Dial("tcp", fs.config.Endpoint, clientConfig)
|
fs.sshClient, err = ssh.Dial("tcp", fs.config.Endpoint, clientConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fsLog(fs, logger.LevelError, "unable to connect: %v", err)
|
||||||
fs.err <- err
|
fs.err <- err
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fs.sftpClient, err = sftp.NewClient(fs.sshClient)
|
fs.sftpClient, err = sftp.NewClient(fs.sshClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fsLog(fs, logger.LevelError, "unable to create SFTP client: %v", err)
|
||||||
fs.sshClient.Close()
|
fs.sshClient.Close()
|
||||||
fs.err <- err
|
fs.err <- err
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue