Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: random mysql ssh connection scheme (#16233)

Danny Xuc92df4620445
diff --git a/backend/plugin/db/mysql/mysql.go b/backend/plugin/db/mysql/mysql.go
index 03284b163b..9fb20fa127 100644
--- a/backend/plugin/db/mysql/mysql.go
+++ b/backend/plugin/db/mysql/mysql.go
@@ -117,11 +117,11 @@ func (d *Driver) getMySQLConnection(connCfg db.ConnectionConfig) (string, error)
return "", err
}
d.sshClient = sshClient
+ protocol = "mysql-tcp-" + uuid.NewString()[:8]
// Now we register the dialer with the ssh connection as a parameter.
- mysql.RegisterDialContext("mysql+tcp", func(_ context.Context, addr string) (net.Conn, error) {
+ mysql.RegisterDialContext(protocol, func(_ context.Context, addr string) (net.Conn, error) {
return sshClient.Dial("tcp", addr)
})
- protocol = "mysql+tcp"
}
tlscfg, err := util.GetTLSConfig(connCfg.DataSource)
diff --git a/backend/plugin/db/starrocks/starrocks.go b/backend/plugin/db/starrocks/starrocks.go
index 15fde4ff38..296e1e1d9b 100644
--- a/backend/plugin/db/starrocks/starrocks.go
+++ b/backend/plugin/db/starrocks/starrocks.go
@@ -75,10 +75,11 @@ func (d *Driver) Open(_ context.Context, dbType storepb.Engine, connCfg db.Conne
}
d.sshClient = sshClient
// Now we register the dialer with the ssh connection as a parameter.
- mysql.RegisterDialContext("mysql+tcp", func(_ context.Context, addr string) (net.Conn, error) {
+ protocol = "mysql-tcp-" + uuid.NewString()[:8]
+ // Now we register the dialer with the ssh connection as a parameter.
+ mysql.RegisterDialContext(protocol, func(_ context.Context, addr string) (net.Conn, error) {
return sshClient.Dial("tcp", addr)
})
- protocol = "mysql+tcp"
}
tlscfg, err := util.GetTLSConfig(connCfg.DataSource)
diff --git a/backend/plugin/db/tidb/tidb.go b/backend/plugin/db/tidb/tidb.go
index b61bac88ad..c3e332355b 100644
--- a/backend/plugin/db/tidb/tidb.go
+++ b/backend/plugin/db/tidb/tidb.go
@@ -76,10 +76,11 @@ func (d *Driver) Open(_ context.Context, dbType storepb.Engine, connCfg db.Conne
}
d.sshClient = sshClient
// Now we register the dialer with the ssh connection as a parameter.
- mysql.RegisterDialContext("mysql+tcp", func(_ context.Context, addr string) (net.Conn, error) {
+ protocol = "mysql-tcp-" + uuid.NewString()[:8]
+ // Now we register the dialer with the ssh connection as a parameter.
+ mysql.RegisterDialContext(protocol, func(_ context.Context, addr string) (net.Conn, error) {
return sshClient.Dial("tcp", addr)
})
- protocol = "mysql+tcp"
}
tlscfg, err := util.GetTLSConfig(connCfg.DataSource)