@decentnetwork/lan 0.1.88 → 0.1.90

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
@@ -13,6 +13,9 @@ export interface PeerManagerOptions {
13
13
  expressNodes?: BootstrapNode[];
14
14
  /** Use express only for friend-request bootstrap, never for data-plane sendText. */
15
15
  expressControlPlaneOnly?: boolean;
16
+ /** Display name advertised to friends (this node's name, so friend lists show
17
+ * "cn"/"tokyo"/"mac-dev" instead of the generic "@decentnetwork/peer"). */
18
+ nickname?: string;
16
19
  }
17
20
  export declare class PeerManager extends EventEmitter {
18
21
  private peer;
@@ -26,6 +26,7 @@ export class PeerManager extends EventEmitter {
26
26
  bootstrapNodes: opts.bootstrapNodes,
27
27
  expressNodes: opts.expressNodes,
28
28
  expressControlPlaneOnly: opts.expressControlPlaneOnly,
29
+ nickname: opts.nickname,
29
30
  // Register our IP channel (163) as the SDK's bulk-data stream so it
30
31
  // rides a single transport instead of fanning out over UDP + relay +
31
32
  // TCP relay (which delivered 3-4 duplicates of every IP packet).
@@ -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
  });
package/dist/cli/index.js CHANGED
File without changes
@@ -181,6 +181,9 @@ export class DaemonServer {
181
181
  bootstrapNodes: this.config.carrier.bootstrapNodes,
182
182
  expressNodes: this.config.carrier.expressNodes ?? [],
183
183
  expressControlPlaneOnly: true,
184
+ // Advertise this node's name so friends see "cn"/"tokyo"/"mac-dev"
185
+ // instead of the generic "@decentnetwork/peer".
186
+ nickname: this.config.node.name,
184
187
  });
185
188
  await this.peerManager.start();
186
189
  this.logger.info(`Identity: ${this.peerManager.getAddress()}`);
@@ -235,10 +238,13 @@ export class DaemonServer {
235
238
  const uid = f.carrierId ?? f.pubkey ?? "";
236
239
  const meta = this.friendMeta?.get(uid);
237
240
  const lastMsg = last.get(uid);
241
+ // The build-default nickname is useless (every node sends it) —
242
+ // treat it as no-name so the UI falls back to alias/userid.
243
+ const realName = f.name && f.name !== "@decentnetwork/peer" ? f.name : undefined;
238
244
  return {
239
245
  userid: uid,
240
246
  alias: meta?.alias,
241
- name: meta?.alias || f.name || uid,
247
+ name: meta?.alias || realName || uid,
242
248
  status: f.status,
243
249
  lastSeen: f.lastSeen,
244
250
  pinned: meta?.pinned ?? false,
@@ -349,6 +355,7 @@ export class DaemonServer {
349
355
  }));
350
356
  return {
351
357
  identity: this.peerManager?.getIdentity(),
358
+ node: { name: this.config.node.name },
352
359
  tun: this.tunDevice?.getConfig(),
353
360
  allocatedIp: this.doraIntegration?.getAllocatedIp() ?? this.config.network.ip,
354
361
  dht: this.peerManager?.getDhtHealth() ?? null,