新功能:允许查看服务器地址

This commit is contained in:
CN-JS-HuiBai
2026-04-10 21:27:33 +08:00
parent cf1842f4e5
commit c9784ec48e
5 changed files with 57 additions and 9 deletions

View File

@@ -145,7 +145,8 @@ function getPublicSiteSettings(settings = {}) {
: 1,
icp_filing: settings.icp_filing || null,
ps_filing: settings.ps_filing || null,
network_data_sources: settings.network_data_sources || null
network_data_sources: settings.network_data_sources || null,
show_server_ip: settings.show_server_ip ? 1 : 0
};
}
@@ -547,6 +548,7 @@ app.post('/api/setup/init', ensureSetupAccess, async (req, res) => {
icp_filing VARCHAR(255),
ps_filing VARCHAR(255),
network_data_sources TEXT,
show_server_ip TINYINT(1) DEFAULT 0,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
`);
@@ -561,6 +563,7 @@ app.post('/api/setup/init', ensureSetupAccess, async (req, res) => {
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS show_page_name TINYINT(1) DEFAULT 1 AFTER page_name");
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS require_login_for_server_details TINYINT(1) DEFAULT 1 AFTER p95_type");
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS network_data_sources TEXT AFTER ps_filing");
await connection.query("ALTER TABLE site_settings ADD COLUMN IF NOT EXISTS show_server_ip TINYINT(1) DEFAULT 0 AFTER network_data_sources");
await connection.query(`
CREATE TABLE IF NOT EXISTS latency_routes (
id INT AUTO_INCREMENT PRIMARY KEY,
@@ -894,7 +897,7 @@ app.post('/api/settings', requireAuth, async (req, res) => {
const {
page_name, show_page_name, title, logo_url, logo_url_dark, favicon_url,
default_theme, show_95_bandwidth, p95_type, require_login_for_server_details,
icp_filing, ps_filing, network_data_sources
icp_filing, ps_filing, network_data_sources, show_server_ip
} = req.body;
// 3. Prepare parameters, prioritizing body but falling back to current
@@ -917,7 +920,8 @@ app.post('/api/settings', requireAuth, async (req, res) => {
latency_target: current.latency_target || null,
icp_filing: icp_filing !== undefined ? icp_filing : (current.icp_filing || null),
ps_filing: ps_filing !== undefined ? ps_filing : (current.ps_filing || null),
network_data_sources: network_data_sources !== undefined ? network_data_sources : (current.network_data_sources || null)
network_data_sources: network_data_sources !== undefined ? network_data_sources : (current.network_data_sources || null),
show_server_ip: show_server_ip !== undefined ? (show_server_ip ? 1 : 0) : (current.show_server_ip || 0)
};
await db.query(`
@@ -925,8 +929,8 @@ app.post('/api/settings', requireAuth, async (req, res) => {
id, page_name, show_page_name, title, logo_url, logo_url_dark, favicon_url,
default_theme, show_95_bandwidth, p95_type, require_login_for_server_details,
blackbox_source_id, latency_source, latency_dest, latency_target,
icp_filing, ps_filing, network_data_sources
) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
icp_filing, ps_filing, network_data_sources, show_server_ip
) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
page_name = VALUES(page_name),
show_page_name = VALUES(show_page_name),
@@ -944,12 +948,13 @@ app.post('/api/settings', requireAuth, async (req, res) => {
latency_target = VALUES(latency_target),
icp_filing = VALUES(icp_filing),
ps_filing = VALUES(ps_filing),
network_data_sources = VALUES(network_data_sources)`,
network_data_sources = VALUES(network_data_sources),
show_server_ip = VALUES(show_server_ip)`,
[
settings.page_name, settings.show_page_name, settings.title, settings.logo_url, settings.logo_url_dark, settings.favicon_url,
settings.default_theme, settings.show_95_bandwidth, settings.p95_type, settings.require_login_for_server_details,
settings.blackbox_source_id, settings.latency_source, settings.latency_dest, settings.latency_target,
settings.icp_filing, settings.ps_filing, settings.network_data_sources
settings.icp_filing, settings.ps_filing, settings.network_data_sources, settings.show_server_ip
]
);