mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-30 07:41:24 +08:00
🐛 fix(oceanbase): 修复 Oracle 租户跳板机连接预探测失败
- 修复 OceanBase Oracle 预探测未走 SSH 隧道导致内网 IP 被本机直连误判不可达的问题 - 预探测阶段复用完整连接配置,支持通过 SSH 跳板机访问目标地址 - 区分本机 TCP 不可达与 SSH 跳板机访问失败,优化错误提示 - 保留 OBClient 与 TNS 双路径路由逻辑,避免协议判断回退 - 补充 OceanBase Oracle SSH 预探测与网络失败回归测试
This commit is contained in:
@@ -116,6 +116,22 @@ func RegisterSSHNetwork(sshConfig connection.SSHConfig) (string, error) {
|
||||
return netName, nil
|
||||
}
|
||||
|
||||
// DialContextThroughSSH creates a context-aware connection through an SSH tunnel.
|
||||
func DialContextThroughSSH(ctx context.Context, config connection.SSHConfig, network, address string) (net.Conn, error) {
|
||||
client, err := GetOrCreateSSHClient(config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("建立 SSH 连接失败:%w", err)
|
||||
}
|
||||
|
||||
conn, err := dialContext(ctx, client, network, address)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("通过 SSH 隧道连接到 %s 失败:%w", address, err)
|
||||
}
|
||||
|
||||
logger.Infof("已通过 SSH 隧道连接到:%s", address)
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
// sshClientCache stores SSH clients to avoid creating multiple connections
|
||||
var (
|
||||
sshClientCache = make(map[sshClientCacheKey]*ssh.Client)
|
||||
|
||||
Reference in New Issue
Block a user