otoji 0.1.48 → 0.1.50

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.
Files changed (2) hide show
  1. package/otoji-node.mjs +9 -1
  2. package/package.json +1 -1
package/otoji-node.mjs CHANGED
@@ -48,7 +48,15 @@ if (typeof WebSocket === "undefined") {
48
48
  }
49
49
 
50
50
  const deviceId = "cli-" + Math.random().toString(36).slice(2, 10);
51
- const url = `${signal}/${encodeURIComponent(room)}?name=cli&deviceId=${deviceId}&role=general&hasMic=false`;
51
+ // Connection-type badge (shown in the web UI): we run on `node`, and we reach
52
+ // the relay over the LAN iff its host is loopback / a private (RFC1918) address
53
+ // / a *.local mDNS name — otherwise the WAN. Classify from `signal` (the URL we
54
+ // actually connect to), so an $OTOJI_SIGNAL override is reflected correctly.
55
+ const isLanHost = (h) =>
56
+ /^(localhost|127\.|0\.0\.0\.0|10\.|192\.168\.|172\.(1[6-9]|2[0-9]|3[01])\.|\[?::1\]?$)/.test(h) || /\.local$/i.test(h);
57
+ const signalHost = signal.replace(/^wss?:\/\//i, "").replace(/[/?].*$/, "").replace(/:\d+$/, "");
58
+ const net = isLanHost(signalHost) ? "lan" : "wan";
59
+ const url = `${signal}/${encodeURIComponent(room)}?name=cli&deviceId=${deviceId}&role=general&hasMic=false&runtime=node&net=${net}`;
52
60
  log("connecting", url);
53
61
 
54
62
  let ws;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otoji",
3
- "version": "0.1.48",
3
+ "version": "0.1.50",
4
4
  "description": "otoji CLI — bridge a terminal's stdio into an otoji voice graph at otoji.org. Zero-dep launcher: `npx otoji node <room>`.",
5
5
  "license": "MIT",
6
6
  "author": "snomiao <snomiao@gmail.com>",