From e60fcbd4d975f84c7a1aa24ba2bfa3685cb5a45b Mon Sep 17 00:00:00 2001 From: mrwuliu Date: Fri, 13 Mar 2026 12:51:12 +0800 Subject: [PATCH] feat: add configurable port and switch to IPv4 by default - Add PTY_WEB_PORT env var for fixed port (0 = random) - Change default hostname from ::1 (IPv6) to 127.0.0.1 (IPv4) - Update README with new environment variable --- README.md | 3 ++- src/web/server/server.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f91e0a4..06b7ff9 100644 --- a/README.md +++ b/README.md @@ -224,7 +224,8 @@ This eliminates the need for polling—perfect for long-running processes like b | Variable | Default | Description | | ---------------------- | ---------- | -------------------------------------------------- | | `PTY_MAX_BUFFER_LINES` | `50000` | Maximum lines to keep in output buffer per session | -| `PTY_WEB_HOSTNAME` | `::1` | Hostname for the web server to bind to | +| `PTY_WEB_HOSTNAME` | `127.0.0.1`| Hostname for the web server to bind to (IPv4) | +| `PTY_WEB_PORT` | `0` (random) | Port for the web server (0 = random port) | ### Permissions diff --git a/src/web/server/server.ts b/src/web/server/server.ts index 4391751..a50beca 100644 --- a/src/web/server/server.ts +++ b/src/web/server/server.ts @@ -41,8 +41,8 @@ export class PTYServer implements Disposable { private startWebServer(): Server { return Bun.serve({ - port: 0, - hostname: process.env.PTY_WEB_HOSTNAME ?? '::1', + port: process.env.PTY_WEB_PORT ? parseInt(process.env.PTY_WEB_PORT, 10) : 0, + hostname: process.env.PTY_WEB_HOSTNAME ?? '127.0.0.1', routes: { ...this.staticRoutes,