fix(credential): 修复凭据测试结果不一致的问题

问题原因:
1. 未知错误类型不重试,导致服务端限流时跳过正确密码
2. SSH 错误分类不够准确,某些临时错误未被识别

修复内容:
1. 未知错误改为可重试(可能是临时问题)
2. 增加 SSH 特有的网络错误识别(handshake failed, disconnect 等)
This commit is contained in:
ZacharyZcR
2026-01-20 13:29:00 +08:00
parent 2839a14c6f
commit b86f39d2cc
2 changed files with 14 additions and 7 deletions
+3 -6
View File
@@ -255,10 +255,10 @@ func testCredentialWithRetry(
// 根据错误类型决定是否重试
switch result.ErrorType {
case ErrorTypeAuth:
// 认证错误,不重试
// 认证错误(密码错误),不重试
return nil
case ErrorTypeNetwork:
// 网络错误,可以重试
case ErrorTypeNetwork, ErrorTypeUnknown:
// 网络错误或未知错误,可以重试(可能是服务端限流等临时问题)
if attempt < testConfig.MaxRetries-1 {
select {
case <-ctx.Done():
@@ -267,9 +267,6 @@ func testCredentialWithRetry(
// 继续重试
}
}
default:
// 未知错误,不重试
return nil
}
}
return nil