feat: 18 引擎驱动全家桶 + 驱动管理/离线包 + 设置中心 + 工作台交互打磨
驱动接入(全部本机真实例验收): - Elasticsearch 原生 SQL API、InfluxDB 原生 HTTP+Flux(官方 JDBC 付费许可,实测弃用) - ZooKeeper/MongoDB JVM agent(连接时自动下载官方驱动 jar,sha256 钉版本到 ~/.opsxdb/drivers/) - 达梦 JDBC agent 桥就绪(待厂商 jar+实例);TiDB 真实例验收 - 协议族代码审查放行 PolarDB/TDSQL/OceanBase/Kingbase/GaussDB/Oracle - 驱动能力模型:按驱动开关对象树分组/右键菜单/行编辑,NoSQL 树拍平(对象直挂库节点) 驱动管理: - 驱动管理弹框(状态/预装/离线包导入/JDK 检测)+ /api/drivers/* 三接口 - opsxdb-driver 驱动商店仓库(清单/fetch.sh/pack.sh 离线包/import.sh) - 连接时懒加载:DMG 零 Java 产物,首连自动下载(实测 ZK 九件套 1.35s),离线包自动回退 UI/交互: - 设置中心(⚙):常规/执行/结果/驱动/快捷键/关于,左导航+右面板(对标 opsxshell) - 实例级展开箭头(行首 SVG chevron,替代字体回退失真的 Unicode 三角) - 树内嵌套渲染修复:对象树挂在激活连接下;工具栏窄窗口不断行(按钮 nowrap+整颗换行) - 侧栏连接行精简(图标+连接名)、SQLite SSH 守卫、Oracle 死参数清理 质量: - Go 协议层/离线回退单测、E2E 门控测试(ES/ZK/Influx/Mongo/TiDB/JDBC 桥) - 驱动注册表单一事实来源 connection-types.json,README/BACKLOG/AGENTS 同步
This commit is contained in:
1 parent
26f459d1b8
commit
a9510235bb
156 files changed
+17200
-2520
No files matched your search
@@ -1,11 +1,13 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"database/sql"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
mysqldriver "github.com/go-sql-driver/mysql"
|
||||
@@ -41,7 +43,7 @@ func openMySQL(c ConnReq) (*sql.DB, error) {
|
||||
case "disable":
|
||||
// no TLS
|
||||
case "skip-verify":
|
||||
if c.SSLCA == "" && c.SSLCert == "" && c.SSLKey == "" {
|
||||
if !hasTLSMaterial(c) {
|
||||
cfg.TLSConfig = "skip-verify"
|
||||
} else {
|
||||
name, err := registerMySQLTLS(c)
|
||||
@@ -51,7 +53,7 @@ func openMySQL(c ConnReq) (*sql.DB, error) {
|
||||
cfg.TLSConfig = name
|
||||
}
|
||||
case "require", "verify-ca":
|
||||
if c.SSLCA == "" && c.SSLCert == "" && c.SSLKey == "" && mode == "require" {
|
||||
if !hasTLSMaterial(c) && mode == "require" {
|
||||
cfg.TLSConfig = "true"
|
||||
} else {
|
||||
name, err := registerMySQLTLS(c)
|
||||
@@ -66,6 +68,16 @@ func openMySQL(c ConnReq) (*sql.DB, error) {
|
||||
return sql.Open("mysql", cfg.FormatDSN())
|
||||
}
|
||||
|
||||
// hasTLSMaterial 是否提供了任何 CA/客户端证书材料(路径或 PEM 内容)。
|
||||
func hasTLSMaterial(c ConnReq) bool {
|
||||
return strings.TrimSpace(c.SSLCA) != "" ||
|
||||
strings.TrimSpace(c.SSLCert) != "" ||
|
||||
strings.TrimSpace(c.SSLKey) != "" ||
|
||||
strings.TrimSpace(c.SSLCAContent) != "" ||
|
||||
strings.TrimSpace(c.SSLCertContent) != "" ||
|
||||
strings.TrimSpace(c.SSLKeyContent) != ""
|
||||
}
|
||||
|
||||
func registerMySQLTLS(c ConnReq) (string, error) {
|
||||
tlsCfg, err := tlsConfigFrom(c)
|
||||
if err != nil {
|
||||
@@ -74,7 +86,8 @@ func registerMySQLTLS(c ConnReq) (string, error) {
|
||||
if tlsCfg == nil {
|
||||
return "", fmt.Errorf("SSL 已启用但未能构建 TLS 配置")
|
||||
}
|
||||
sum := sha256.Sum256([]byte(EffectiveSSLMode(c) + "|" + c.SSLCA + "|" + c.SSLCert + "|" + c.SSLKey + "|" + c.Host))
|
||||
sum := sha256.Sum256([]byte(EffectiveSSLMode(c) + "|" + c.SSLCA + "|" + c.SSLCert + "|" + c.SSLKey +
|
||||
"|" + c.SSLCAContent + "|" + c.SSLCertContent + "|" + c.SSLKeyContent + "|" + c.TLSServerName + "|" + c.Host))
|
||||
name := "opsxdb-" + hex.EncodeToString(sum[:8])
|
||||
mysqldriver.DeregisterTLSConfig(name)
|
||||
if err := mysqldriver.RegisterTLSConfig(name, tlsCfg); err != nil {
|
||||
@@ -83,8 +96,8 @@ func registerMySQLTLS(c ConnReq) (string, error) {
|
||||
return name, nil
|
||||
}
|
||||
|
||||
func listDatabasesMySQL(db *sql.DB) ([]string, error) {
|
||||
rows, err := db.Query("SHOW DATABASES")
|
||||
func listDatabasesMySQL(ctx context.Context, db *sql.DB) ([]string, error) {
|
||||
rows, err := db.QueryContext(ctx, "SHOW DATABASES")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -100,12 +113,12 @@ func listDatabasesMySQL(db *sql.DB) ([]string, error) {
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func listTablesMySQL(db *sql.DB, database string) ([]string, error) {
|
||||
func listTablesMySQL(ctx context.Context, db *sql.DB, database string) ([]string, error) {
|
||||
q := "SHOW TABLES"
|
||||
if database != "" {
|
||||
q = "SHOW TABLES FROM " + quoteMySQLIdent(database)
|
||||
}
|
||||
rows, err := db.Query(q)
|
||||
rows, err := db.QueryContext(ctx, q)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -121,12 +134,12 @@ func listTablesMySQL(db *sql.DB, database string) ([]string, error) {
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func listColumnsMySQL(db *sql.DB, database, table string) ([]ColumnInfo, error) {
|
||||
func listColumnsMySQL(ctx context.Context, db *sql.DB, database, table string) ([]ColumnInfo, error) {
|
||||
ident := quoteMySQLIdent(table)
|
||||
if database != "" {
|
||||
ident = quoteMySQLIdent(database) + "." + ident
|
||||
}
|
||||
rows, err := db.Query("SHOW FULL COLUMNS FROM " + ident)
|
||||
rows, err := db.QueryContext(ctx, "SHOW FULL COLUMNS FROM "+ident)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user