Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(mysql): skip tcp probe for direct ip connections

t8y2a2d4d521138e
diff --git a/crates/dbx-core/src/connection.rs b/crates/dbx-core/src/connection.rs
index b7e45d613e..72639a3bec 100644
--- a/crates/dbx-core/src/connection.rs
+++ b/crates/dbx-core/src/connection.rs
@@ -1569,14 +1569,14 @@ fn uses_tcp_probe(config: &ConnectionConfig, host: &str, port: u16) -> bool {
if database_capabilities::skips_tcp_probe(&config.db_type) {
return false;
}
- if is_original_hostname_endpoint(config, host, port) {
+ if is_original_endpoint(config, host, port) {
return false;
}
true
}
-fn is_original_hostname_endpoint(config: &ConnectionConfig, host: &str, port: u16) -> bool {
- host == config.host && port == config.port && host.parse::<std::net::IpAddr>().is_err()
+fn is_original_endpoint(config: &ConnectionConfig, host: &str, port: u16) -> bool {
+ host == config.host && port == config.port
}
async fn detect_ob_oracle_mode(config: &ConnectionConfig, pool: &db::mysql::MySqlPool) -> MysqlMode {
@@ -2326,17 +2326,18 @@ mod tests {
}
#[test]
- fn mysql_hostname_connections_skip_tcp_probe() {
+ fn mysql_direct_connections_skip_tcp_probe() {
let mut config = mysql_config(Some("app"));
config.host = "mysql.example.com".to_string();
assert!(!uses_tcp_probe(&config, "mysql.example.com", 3306));
- assert!(uses_tcp_probe(&config, "192.0.2.10", 3306));
+ config.host = "192.0.2.10".to_string();
+ assert!(!uses_tcp_probe(&config, "192.0.2.10", 3306));
assert!(uses_tcp_probe(&config, "127.0.0.1", 53306));
}
#[test]
- fn native_hostname_connections_skip_tcp_probe() {
+ fn native_direct_connections_skip_tcp_probe() {
for db_type in [
DatabaseType::Postgres,
DatabaseType::Redshift,
@@ -2351,7 +2352,8 @@ mod tests {
config.host = "db.example.com".to_string();
assert!(!uses_tcp_probe(&config, "db.example.com", config.port), "{db_type:?} hostname");
- assert!(uses_tcp_probe(&config, "192.0.2.10", config.port), "{db_type:?} ip");
+ config.host = "192.0.2.10".to_string();
+ assert!(!uses_tcp_probe(&config, "192.0.2.10", config.port), "{db_type:?} ip");
assert!(uses_tcp_probe(&config, "127.0.0.1", 54000), "{db_type:?} forwarded");
}
}