mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2026-10-10 04:53:09 +08:00
fix(sftp): add connection timeout (#2626)
- 为 SFTP SSH 连接设置启动超时 - 避免远端不可达时长时间阻塞存储初始化 Signed-off-by: jyxjjj <16695261+jyxjjj@users.noreply.github.com> Co-authored-by: Codex <267193182+codex@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package sftp
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/OpenListTeam/OpenList/v4/pkg/singleflight"
|
||||
"github.com/pkg/sftp"
|
||||
@@ -39,6 +40,7 @@ func (d *SFTP) _initClient() error {
|
||||
User: d.Username,
|
||||
Auth: []ssh.AuthMethod{auth},
|
||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||
Timeout: 10 * time.Second,
|
||||
}
|
||||
conn, err := ssh.Dial("tcp", d.Address, config)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user