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。

feat: add ssh_expose_lan configuration and localization support

t8y26e0fdf1c92f0
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index d1e14012ee..af3360fc53 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -1400,7 +1400,7 @@ checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8"
[[package]]
name = "dbx"
-version = "0.3.2"
+version = "0.3.3"
dependencies = [
"anyhow",
"chrono",
diff --git a/src-tauri/src/commands/connection.rs b/src-tauri/src/commands/connection.rs
index c396e9199a..92d554532c 100644
--- a/src-tauri/src/commands/connection.rs
+++ b/src-tauri/src/commands/connection.rs
@@ -166,6 +166,7 @@ impl AppState {
&config.ssh_key_path,
&config.host,
config.port,
+ config.ssh_expose_lan,
)
.await?;
diff --git a/src-tauri/src/db/ssh_tunnel.rs b/src-tauri/src/db/ssh_tunnel.rs
index d29ff137fe..bd6e9fa8bb 100644
--- a/src-tauri/src/db/ssh_tunnel.rs
+++ b/src-tauri/src/db/ssh_tunnel.rs
@@ -160,6 +160,7 @@ impl TunnelManager {
ssh_key_path: &str,
remote_host: &str,
remote_port: u16,
+ expose_to_lan: bool,
) -> Result<u16, String> {
let local_port = portpicker::pick_unused_port().ok_or("No available port")?;
@@ -167,7 +168,8 @@ impl TunnelManager {
connect_and_authenticate(ssh_host, ssh_port, ssh_user, ssh_password, ssh_key_path)
.await?;
- let listener = TcpListener::bind(("127.0.0.1", local_port))
+ let bind_addr = if expose_to_lan { "0.0.0.0" } else { "127.0.0.1" };
+ let listener = TcpListener::bind((bind_addr, local_port))
.await
.map_err(|e| format!("Failed to bind local port: {e}"))?;
diff --git a/src-tauri/src/models/connection.rs b/src-tauri/src/models/connection.rs
index 281f67d95f..381e817ba8 100644
--- a/src-tauri/src/models/connection.rs
+++ b/src-tauri/src/models/connection.rs
@@ -32,6 +32,8 @@ pub struct ConnectionConfig {
#[serde(default)]
pub ssh_key_path: String,
#[serde(default)]
+ pub ssh_expose_lan: bool,
+ #[serde(default)]
pub ssl: bool,
#[serde(default)]
pub connection_string: Option<String>,
diff --git a/src/components/connection/ConnectionDialog.vue b/src/components/connection/ConnectionDialog.vue
index e59caecc27..c785beff06 100644
--- a/src/components/connection/ConnectionDialog.vue
+++ b/src/components/connection/ConnectionDialog.vue
@@ -54,6 +54,7 @@ const defaultForm = (): Omit<ConnectionConfig, "id"> => ({
ssh_user: "",
ssh_password: "",
ssh_key_path: "",
+ ssh_expose_lan: false,
ssl: false,
connection_string: undefined,
});
@@ -155,6 +156,7 @@ watch(() => props.editConfig, (config) => {
ssh_user: config.ssh_user || "",
ssh_password: config.ssh_password || "",
ssh_key_path: config.ssh_key_path || "",
+ ssh_expose_lan: config.ssh_expose_lan || false,
ssl: config.ssl || false,
connection_string: config.connection_string,
};
@@ -514,6 +516,13 @@ watch([() => editingId.value, () => open.value], () => {
<Label class="text-right text-xs">{{ t('connection.sshKeyPath') }}</Label>
<Input v-model="form.ssh_key_path" class="col-span-3" placeholder="~/.ssh/id_rsa" />
</div>
+ <div class="grid grid-cols-4 items-center gap-4">
+ <span />
+ <label class="col-span-3 flex items-center gap-2 cursor-pointer">
+ <input type="checkbox" v-model="form.ssh_expose_lan" class="mr-0" />
+ <span class="text-xs text-muted-foreground">{{ t('connection.sshExposeLan') }}</span>
+ </label>
+ </div>
</template>
</template>
</div>
diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts
index 089548ee0c..bdef4d44e9 100644
--- a/src/i18n/locales/en.ts
+++ b/src/i18n/locales/en.ts
@@ -58,6 +58,7 @@ export default {
sshPassword: "SSH Password",
sshPasswordPlaceholder: "Leave empty to use key",
sshKeyPath: "Key Path",
+ sshExposeLan: "Expose tunnel to LAN",
compatible: "Compatible",
mainstream: "Popular",
color: "Color",
diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts
index daa55c2c3b..48a0fb0609 100644
--- a/src/i18n/locales/zh-CN.ts
+++ b/src/i18n/locales/zh-CN.ts
@@ -60,6 +60,7 @@ export default {
sshPassword: "SSH 密码",
sshPasswordPlaceholder: "留空则使用密钥",
sshKeyPath: "密钥路径",
+ sshExposeLan: "允许局域网访问隧道",
compatible: "兼容",
mainstream: "主流",
color: "颜色",
diff --git a/src/types/database.ts b/src/types/database.ts
index ad022b0d27..529a76a098 100644
--- a/src/types/database.ts
+++ b/src/types/database.ts
@@ -19,6 +19,7 @@ export interface ConnectionConfig {
ssh_user?: string;
ssh_password?: string;
ssh_key_path?: string;
+ ssh_expose_lan?: boolean;
ssl?: boolean;
connection_string?: string;
}