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(web): make the listener bind address configurable via DBX_BIND_ADDR

Jinpy9540f51dce52
diff --git a/crates/dbx-web/src/main.rs b/crates/dbx-web/src/main.rs
index ac93da5ed1..b0edc80a5a 100644
--- a/crates/dbx-web/src/main.rs
+++ b/crates/dbx-web/src/main.rs
@@ -8,7 +8,7 @@ mod state;
mod web_mcp;
use std::collections::{HashMap, HashSet};
-use std::net::SocketAddr;
+use std::net::{IpAddr, SocketAddr};
use std::sync::Arc;
use argon2::password_hash::rand_core::OsRng;
@@ -1398,7 +1398,19 @@ async fn serve() {
// Bind address
let port: u16 = std::env::var("DBX_PORT").ok().and_then(|p| p.parse().ok()).unwrap_or(4224);
- let addr = SocketAddr::from(([0, 0, 0, 0], port));
+ // Defaults to all interfaces for container deployments; operators who
+ // expose the service through a local reverse proxy can pin the listener
+ // (DBX_BIND_ADDR=127.0.0.1) without a firewall change. The value is an
+ // IP only — the port always comes from DBX_PORT so the HTTP listener and
+ // the Redis PubSub server (which reads DBX_PORT independently) stay in
+ // sync.
+ let ip = match std::env::var("DBX_BIND_ADDR").ok().as_deref().map(str::trim).filter(|value| !value.is_empty()) {
+ Some(value) => {
+ value.parse::<IpAddr>().unwrap_or_else(|error| panic!("invalid DBX_BIND_ADDR \"{value}\": {error}"))
+ }
+ None => IpAddr::from([0, 0, 0, 0]),
+ };
+ let addr = SocketAddr::new(ip, port);
tracing::info!("DBX Web server starting on http://{}", addr);
if public_base_path != "/" {