omo-web 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,7 +15,7 @@ omo-web
15
15
 
16
16
  Open the printed URL (normally `http://127.0.0.1:4317`). The local browser connects to OmO on the host. `omo-web --help` lists startup commands.
17
17
 
18
- In an interactive terminal, `omo-web` opens a keyboard-driven launcher. Use ↑/↓ and Enter to choose working directories or open **Access settings**. There you can change or disable the password, toggle HTTPS, generate a self-signed certificate (requires OpenSSL 1.1.1+ on `PATH`), bind to an IPv4 interface, or set the HTTPS origin of a reverse proxy. Changes apply on the next start. Non-loopback listeners require HTTPS; passwordless remote access needs confirmation. The browser username is `omo`. Use at least 20 characters for remote access; shorter passwords are accepted with a warning.
18
+ In an interactive terminal, `omo-web` opens a keyboard-driven launcher. Use ↑/↓ and Enter to choose working directories or open **Access settings**. There you can change or disable the password, toggle HTTPS, generate a self-signed certificate (requires OpenSSL 1.1.1+ on `PATH`), bind to an IPv4 interface, or set the HTTPS origin of a reverse proxy. Changes apply on the next start. Remote HTTP shows a warning. Passwordless remote access needs confirmation. The browser sign-in page asks only for the password.
19
19
 
20
20
  For a local proxy or tunnel that handles HTTPS, keep the default upstream `http://127.0.0.1:4317`, preserve the original `Host`, and set the exact public origin (for example `https://web.example.com`) in **Proxy origin** or `OMO_WEB_PROXY_ORIGIN`.
21
21
 
@@ -84,7 +84,6 @@ export async function loadLauncherSettings(base) {
84
84
 
85
85
  return {
86
86
  directory, warning, prepare, save, effectiveEnv,
87
- get hasListenerOverride() { return overrides.OMO_WEB_HOST !== undefined || overrides.httpsEnabled !== undefined; },
88
87
  async changePassword(password) {
89
88
  await prepare();
90
89
  const path = join(directory, "password.txt");
package/bin/omo-web.js CHANGED
@@ -28,8 +28,8 @@ ${cliTr("在「访问设置」中选择网卡、设置密码和生成 SSL 自签
28
28
  "Use Access settings in the launcher to choose an interface, set a password, or generate an SSL certificate.")}
29
29
  ${cliTr("内网穿透或反代可设置 OMO_WEB_PROXY_ORIGIN;代理需保留浏览器的 Host。",
30
30
  "Set OMO_WEB_PROXY_ORIGIN for a tunnel or reverse proxy. Preserve the browser's Host.")}
31
- ${cliTr("非本机监听必须使用 HTTPS。建议设置访问密码。",
32
- "Non-loopback listening requires HTTPS. Set an access password for protection.")}
31
+ ${cliTr("HTTPS 可关闭;远程使用明文 HTTP 时会提示。",
32
+ "HTTPS is optional. Remote plaintext HTTP shows a warning.")}
33
33
  ${cliTr("仅在受限私网或 VPN 使用无密码模式;脚本需显式设置 OMO_WEB_ALLOW_UNAUTHENTICATED=1。",
34
34
  "Use password-free access only on a restricted private network or VPN. Scripts must set OMO_WEB_ALLOW_UNAUTHENTICATED=1.")}
35
35
  https://github.com/NekoCCN/OmO-Web/blob/main/docs/usage.md`);
package/bin/tui.js CHANGED
@@ -168,6 +168,11 @@ export async function startTui({ entry, version }) {
168
168
  let paint;
169
169
  const finished = new Promise(resolve => { settle = resolve; });
170
170
 
171
+ const browserUrl = () => {
172
+ if (!url) return;
173
+ return parseProxyOrigin(proxyOrigin())?.origin ??
174
+ (env.OMO_WEB_ORIGIN === new URL(url).origin ? env.OMO_WEB_ORIGIN : url);
175
+ };
171
176
  const directoriesLabel = cliTr("工作目录", "Working directories");
172
177
  const quitAction = [cliTr("退出", "Quit"), () => quit(0)];
173
178
  const stopAction = [cliTr("停止服务", "Stop web"), stopWeb];
@@ -238,21 +243,23 @@ export async function startTui({ entry, version }) {
238
243
  const [state, tone] = status[phase];
239
244
  const label = state();
240
245
  const build = fold(`v${version}`, 20)[0];
241
- const title = cliTr(" Web 监听 ", " WEB LISTENER ");
242
- const brand = "-- OmO Web ";
243
- const gap = width - textWidth(title) - textWidth(label) - textWidth(build) - 1;
244
- const boxed = width >= 44 && gap >= 2;
245
- const header = boxed ? [
246
- ink("36;1", `+${brand}${"-".repeat(width - brand.length)}+`),
247
- `|${title}${ink(tone, label)}${" ".repeat(gap)}${build} |`,
248
- ink("36", `+${"-".repeat(width)}+`),
249
- ] : fold(`OmO Web / ${label}`, width).map(line => ink(tone, line));
246
+ const brand = "OmO Web";
247
+ const gap = width - textWidth(`${brand} ${label}${build}`);
248
+ const header = gap >= 3 ? [
249
+ `${ink("36;1", brand)} ${ink(tone, label)}${" ".repeat(gap)}${ink("2", build)}`,
250
+ ink("2", "─".repeat(Math.floor(width / cells("─")))),
251
+ ] : fold(`${brand} / ${label}`, width).map(line => ink(tone, line));
250
252
  const short = text => fold(text, width)[0];
253
+ const addressRows = (title, href) => [ink("1", short(title)), ...fold(href, Math.max(2, width - 2)).map(row => ` ${row}`)];
251
254
  const editorTitle = draft && ink("1", short(draft.title));
252
255
  const menu = activeMenu(dimensions);
253
256
  const focus = Math.min(selected, menu.length - 1);
254
- const actions = menu.map(([action], index) => index === focus
255
- ? ink("7;1", short(`> ${action} `)) : short(` ${action}`));
257
+ const proxyAction = phase === "settings" && proxyOrigin();
258
+ const proxyOverflows = proxyAction && textWidth(` ${menu[5][0]}`) > width;
259
+ const actions = menu.map(([action], index) => {
260
+ const title = proxyOverflows && index === 5 ? cliTr("代理入口:开", "Proxy origin: On") : action;
261
+ return index === focus ? ink("36;1", short(`> ${title}`)) : short(` ${title}`);
262
+ });
256
263
  const message = notice ? fold(notice, width).slice(0, 2).map(line => ink("33;1", line)) : [];
257
264
  const warning = unprotected() && (optedIn() || server) && phase !== "confirming"
258
265
  ? fold(REMOTE_WARNING, width).map(line => ink("33;1", line)) : [];
@@ -261,6 +268,7 @@ export async function startTui({ entry, version }) {
261
268
  ? riskLines(width).map(line => ink("33;1", line)) : [];
262
269
  let editor;
263
270
  let lines;
271
+ let readyAddresses = [];
264
272
  if (draft) {
265
273
  editor = editorLine(draft.masked ? { ...draft, text: "*".repeat(draft.text.length) } : draft, Math.max(2, width - 2));
266
274
  lines = [...header, "", editorTitle, `> ${editor}`, "",
@@ -274,15 +282,18 @@ export async function startTui({ entry, version }) {
274
282
  } else if (phase === "settings" || phase === "networks") {
275
283
  const hint = phase === "networks" ? cliTr("选择监听网卡,不会修改防火墙规则。", "Select a listen interface; firewall rules are unchanged.")
276
284
  : cliTr("Enter 修改 · 保存后下次启动生效 · Esc 返回", "Enter to edit · Applies on the next start · Esc back");
277
- const origin = phase === "settings" && hasHttps() ? fold(cliTr(`HTTPS 地址:${env.OMO_WEB_ORIGIN}`,
278
- `HTTPS URL: ${env.OMO_WEB_ORIGIN}`), width) : [];
279
- lines = [...header, "", ...actions, "", ...message, ...origin, ...fold(hint, width)];
285
+ const origin = phase === "settings" && hasHttps() ? addressRows(cliTr("HTTPS 地址", "HTTPS URL"), env.OMO_WEB_ORIGIN) : [];
286
+ const proxy = proxyOverflows ? addressRows(cliTr("代理入口地址", "Proxy URL"), proxyAction) : [];
287
+ lines = [...header, "", ...actions, "", ...message, ...proxy, ...origin, ...fold(hint, width)];
280
288
  } else {
281
289
  const paths = activePaths();
282
- const urlRows = url ? fold(url, Math.max(2, width - 2)) : [];
283
290
  const pathCount = height >= 23 ? 4 : 2;
284
- const details = url ? [ink("1", short(cliTr("浏览器地址", "Browser URL"))), ...urlRows.slice(0, 2).map(line => ` ${line}`),
285
- ...(urlRows.length > 2 ? [" ..."] : []), ""] : [];
291
+ const browser = browserUrl();
292
+ const browserRows = browser ? addressRows(cliTr("浏览器地址", "Browser URL"), browser) : [];
293
+ const upstreamRows = browser && new URL(browser).href !== url
294
+ ? addressRows(cliTr("本地上游", "Local upstream"), url) : [];
295
+ readyAddresses = [browserRows, upstreamRows];
296
+ const details = browser ? [...browserRows, ...upstreamRows, ""] : [];
286
297
  const directories = paths.length ? paths.slice(0, pathCount).map(path => ` ${pathLabel(path, width - 2)}`)
287
298
  : [short(cliTr(" (未配置)", " (none configured)"))];
288
299
  if (paths.length > pathCount) directories.push(short(cliTr(` 另有 ${paths.length - pathCount} 个`, ` +${paths.length - pathCount} more`)));
@@ -305,7 +316,16 @@ export async function startTui({ entry, version }) {
305
316
  lines = [...risk, ...actions];
306
317
  } else {
307
318
  const compactStatus = ink(tone, short(`OmO Web / ${label}`));
308
- if (phase === "settings" || phase === "networks") {
319
+ const addressSpace = height - warning.length - 2;
320
+ if (phase === "ready" && readyAddresses[0].length - 1 <= addressSpace) {
321
+ const [browserRows, upstreamRows] = readyAddresses;
322
+ const addresses = browserRows.length + upstreamRows.length <= addressSpace ? readyAddresses.flat()
323
+ : browserRows.length <= addressSpace ? browserRows : browserRows.slice(1);
324
+ const controls = [compactStatus, ...warning, ...addresses];
325
+ const available = height - controls.length;
326
+ controls.push(...(available >= actions.length ? actions : [actions[focus]]));
327
+ lines = controls;
328
+ } else if (phase === "settings" || phase === "networks") {
309
329
  const slots = Math.max(1, height - 1 - message.length);
310
330
  const first = Math.max(0, Math.min(focus - Math.floor(slots / 2), actions.length - slots));
311
331
  lines = height > 1 ? [compactStatus, ...actions.slice(first, first + slots), ...message] : [actions[focus]];
@@ -494,9 +514,6 @@ export async function startTui({ entry, version }) {
494
514
  function requestStart() {
495
515
  if (settings.warning) {
496
516
  notice = settings.warning;
497
- } else if (settings.hasListenerOverride && isRemoteAddress(address()) && !hasHttps()) {
498
- notice = cliTr("非本机监听必须启用 HTTPS。请在访问设置中启用或生成证书。",
499
- "Remote listening requires HTTPS. Enable it or generate a certificate in Access settings.");
500
517
  } else if (unprotected() && !optedIn()) {
501
518
  phase = "confirming";
502
519
  selected = 0;
@@ -597,11 +614,13 @@ export async function startTui({ entry, version }) {
597
614
 
598
615
  function openBrowser() {
599
616
  const current = server;
617
+ const href = browserUrl();
618
+ if (!href) return;
600
619
  const commands = {
601
- darwin: ["open", url],
602
- win32: ["rundll32.exe", "url.dll,FileProtocolHandler", url],
620
+ darwin: ["open", href],
621
+ win32: ["rundll32.exe", "url.dll,FileProtocolHandler", href],
603
622
  };
604
- const [command, ...args] = commands[process.platform] ?? ["xdg-open", url];
623
+ const [command, ...args] = commands[process.platform] ?? ["xdg-open", href];
605
624
  const browser = spawn(command, args, { stdio: "ignore", windowsHide: true, detached: !windows });
606
625
  const failed = () => {
607
626
  if (server !== current || phase !== "ready" || exitCode !== undefined) return;