fix(webui): make listener exposure explicit

Use a local-only default while preserving saved operator choices and keeping broader network access available from the settings panel.

Treat enabled encrypted transport as a startup requirement and present a dismissible notice when remote browser access is not protected.
This commit is contained in:
DrSmoothl committed 2026-08-01 16:50:08 +08:00
1 parent e4179ffb47
commit ea841d929e
12 files changed
+193 -36

No files matched your search

+7 -3
View File
@@ -1,6 +1,6 @@
import net from 'net';
function isPortAvailable(port: number, host = '0.0.0.0'): Promise<boolean> {
function isPortAvailable(port: number, host = '127.0.0.1'): Promise<boolean> {
return new Promise((resolve) => {
const server = net.createServer();
let settled = false;
@@ -27,11 +27,15 @@ function isPortAvailable(port: number, host = '0.0.0.0'): Promise<boolean> {
* Find an available TCP port starting from `start`, advancing by 1 up to `maxTries` attempts.
* Skips reserved/invalid port numbers.
*/
export async function findAvailablePort(start: number, maxTries = 50): Promise<number> {
export async function findAvailablePort(
start: number,
options: { maxTries?: number; host?: string } = {},
): Promise<number> {
const { maxTries = 50, host = '127.0.0.1' } = options;
let port = Math.max(1, Math.min(65535, Math.trunc(start)));
for (let i = 0; i < maxTries; i++) {
if (port > 65535) break;
if (await isPortAvailable(port)) return port;
if (await isPortAvailable(port, host)) return port;
port += 1;
}
throw new Error(`No available TCP port found near ${start}`);