Skip to content

Commit b7f9e8e

Browse files
jyxjjjcodex
andauthored
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>
1 parent d7c332c commit b7f9e8e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/sftp/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package sftp
33
import (
44
"fmt"
55
"path"
6+
"time"
67

78
"github.com/OpenListTeam/OpenList/v4/pkg/singleflight"
89
"github.com/pkg/sftp"
@@ -39,6 +40,7 @@ func (d *SFTP) _initClient() error {
3940
User: d.Username,
4041
Auth: []ssh.AuthMethod{auth},
4142
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
43+
Timeout: 10 * time.Second,
4244
}
4345
conn, err := ssh.Dial("tcp", d.Address, config)
4446
if err != nil {

0 commit comments

Comments
 (0)