@decentnetwork/lan 0.1.89 → 0.1.91

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.
Binary file
Binary file
Binary file
Binary file
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * CLI command handlers
3
3
  */
4
- import { resolve, dirname } from "path";
4
+ import { resolve, dirname, join } from "path";
5
5
  import { existsSync, mkdirSync, readFileSync } from "fs";
6
6
  import { createConnection } from "net";
7
+ import { createRequire } from "module";
8
+ import { fileURLToPath } from "url";
7
9
  import { ConfigLoader, DEFAULT_DORAS, DEFAULT_EXITS } from "../config/loader.js";
8
10
  import { ipcSocketPath } from "../daemon/ipc.js";
9
11
  import { DaemonServer } from "../daemon/server.js";
@@ -1120,10 +1122,37 @@ export async function cmdUi(args) {
1120
1122
  ? [resolve(args.doraDir, "roster.yaml")]
1121
1123
  : [resolve(homedir(), ".dora-test", "roster.yaml"), resolve(homedir(), ".decent-registry", "roster.yaml")];
1122
1124
  const doraRosterPath = doraCandidates.find((p) => existsSync(p)) ?? (args.doraDir ? doraCandidates[0] : undefined);
1125
+ // Versions for the desktop "my node" panel — read off the installed
1126
+ // packages (diag doesn't carry them). lan = our own package.json (relative
1127
+ // to this compiled module: dist/cli/ → ../../package.json); peer = resolved
1128
+ // via require.
1129
+ const moduleDir = dirname(fileURLToPath(import.meta.url));
1130
+ const readJsonVer = (file) => {
1131
+ try {
1132
+ return JSON.parse(readFileSync(file, "utf-8")).version ?? "";
1133
+ }
1134
+ catch {
1135
+ return "";
1136
+ }
1137
+ };
1138
+ let peerVer = "";
1139
+ try {
1140
+ const req = createRequire(import.meta.url);
1141
+ peerVer = readJsonVer(req.resolve("@decentnetwork/peer/package.json"));
1142
+ }
1143
+ catch {
1144
+ peerVer = "";
1145
+ }
1123
1146
  startFriendUi({
1124
1147
  call: (req) => ipcCall(config, req),
1125
1148
  routesPath: resolve(dir, "routes.yaml"),
1126
1149
  doraRosterPath,
1150
+ meExtra: {
1151
+ lanVer: readJsonVer(join(moduleDir, "..", "..", "package.json")),
1152
+ peerVer,
1153
+ wire: "163",
1154
+ channel: "@next",
1155
+ },
1127
1156
  listenHost: args.listen ?? "127.0.0.1",
1128
1157
  listenPort: args.port ?? 8765,
1129
1158
  });
@@ -355,6 +355,7 @@ export class DaemonServer {
355
355
  }));
356
356
  return {
357
357
  identity: this.peerManager?.getIdentity(),
358
+ node: { name: this.config.node.name },
358
359
  tun: this.tunDevice?.getConfig(),
359
360
  allocatedIp: this.doraIntegration?.getAllocatedIp() ?? this.config.network.ip,
360
361
  dht: this.peerManager?.getDhtHealth() ?? null,