@decentnetwork/lan 0.1.50 → 0.1.52

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.
@@ -685,12 +685,12 @@ export async function cmdFriendsList(args) {
685
685
  // A friend we only friend-requested (status "requested") has no name in
686
686
  // the local SDK record yet — but the dora roster knows it. Cross-reference
687
687
  // live IPAM so the list shows "cn", "mac-dev", … instead of "(unnamed)".
688
- const ipamNames = new Map();
688
+ const ipamInfo = new Map();
689
689
  try {
690
690
  const { peers } = await fetchLiveIpam(config);
691
691
  for (const p of peers) {
692
- if (p.carrierId && p.name)
693
- ipamNames.set(p.carrierId, p.name);
692
+ if (p.carrierId)
693
+ ipamInfo.set(p.carrierId, { name: p.name, virtualIp: p.virtualIp });
694
694
  }
695
695
  }
696
696
  catch {
@@ -709,9 +709,14 @@ export async function cmdFriendsList(args) {
709
709
  console.log(`Friends (${friends.length}) ${source === "daemon" ? "[live]" : "[disk]"}:`);
710
710
  for (const friend of friends) {
711
711
  const userid = friend.carrierId || friend.pubkey;
712
- const name = friend.name || ipamNames.get(userid) || "(unnamed)";
712
+ const ipam = ipamInfo.get(userid);
713
+ // friend.name is usually the generic SDK default "@decentnetwork/peer";
714
+ // prefer the dora-roster name (cn, mac-dev, …) when that's all we have.
715
+ const realName = friend.name && friend.name !== "@decentnetwork/peer" ? friend.name : undefined;
716
+ const name = realName || ipam?.name || "(unnamed)";
717
+ const ipSuffix = ipam?.virtualIp ? ` ${ipam.virtualIp}` : "";
713
718
  console.log(``);
714
- console.log(` ${name} status=${friend.status}`);
719
+ console.log(` ${name}${ipSuffix} status=${friend.status}`);
715
720
  console.log(` userid: ${userid}`);
716
721
  if (friend.address)
717
722
  console.log(` address: ${friend.address}`);
@@ -35,11 +35,21 @@ export declare class DaemonServer {
35
35
  private pendingFriends?;
36
36
  private startedAt;
37
37
  private isRunning;
38
+ private statusTimer?;
38
39
  private pidFile?;
39
40
  private configDir;
40
41
  constructor(opts: DaemonOptions);
41
42
  start(): Promise<void>;
42
43
  stop(): Promise<void>;
44
+ /**
45
+ * Periodic one-line peer-connection summary at INFO. Between the
46
+ * startup block and the first friend flipping online the log is
47
+ * otherwise silent — which looks like the daemon is idle when it's
48
+ * actually retrying handshakes (those are only logged at debug). This
49
+ * line shows, every 30s, who's connected vs. still connecting so an
50
+ * operator can see it IS working without enabling DECENT_DEBUG.
51
+ */
52
+ private startPeerStatusSummary;
43
53
  getStatus(): DaemonStatus;
44
54
  /**
45
55
  * Periodically poke the SDK to (re-)initiate a session with the friend.
@@ -52,6 +52,7 @@ export class DaemonServer {
52
52
  pendingFriends;
53
53
  startedAt = 0;
54
54
  isRunning = false;
55
+ statusTimer;
55
56
  pidFile;
56
57
  configDir;
57
58
  constructor(opts) {
@@ -576,6 +577,7 @@ export class DaemonServer {
576
577
  }
577
578
  this.isRunning = true;
578
579
  this.logger.info("Daemon started successfully");
580
+ this.startPeerStatusSummary();
579
581
  }
580
582
  catch (error) {
581
583
  this.logger.error("Failed to start daemon:", error);
@@ -591,6 +593,41 @@ export class DaemonServer {
591
593
  await this.cleanup();
592
594
  this.logger.info("Daemon stopped");
593
595
  }
596
+ /**
597
+ * Periodic one-line peer-connection summary at INFO. Between the
598
+ * startup block and the first friend flipping online the log is
599
+ * otherwise silent — which looks like the daemon is idle when it's
600
+ * actually retrying handshakes (those are only logged at debug). This
601
+ * line shows, every 30s, who's connected vs. still connecting so an
602
+ * operator can see it IS working without enabling DECENT_DEBUG.
603
+ */
604
+ startPeerStatusSummary() {
605
+ const label = (p) => {
606
+ const id = p.carrierId || p.pubkey;
607
+ return p.name || this.ipam?.resolveCarrierId(id)?.name || `${id.slice(0, 8)}…`;
608
+ };
609
+ const tick = () => {
610
+ if (!this.isRunning || !this.peerManager)
611
+ return;
612
+ let peers;
613
+ try {
614
+ peers = this.peerManager.getFriends();
615
+ }
616
+ catch {
617
+ return;
618
+ }
619
+ if (peers.length === 0)
620
+ return;
621
+ const online = peers.filter((p) => p.status === "online");
622
+ const connecting = peers.filter((p) => p.status !== "online");
623
+ const fmt = (list) => list.length === 0 ? "none" : list.map(label).join(", ");
624
+ this.logger.info(`Peers: ${online.length} connected (${fmt(online)}) · ` +
625
+ `${connecting.length} connecting (${fmt(connecting)})`);
626
+ };
627
+ // First summary shortly after startup, then every 30s.
628
+ setTimeout(tick, 5_000);
629
+ this.statusTimer = setInterval(tick, 30_000);
630
+ }
594
631
  getStatus() {
595
632
  return {
596
633
  isRunning: this.isRunning,
@@ -681,6 +718,10 @@ export class DaemonServer {
681
718
  return this.doraIntegration;
682
719
  }
683
720
  async cleanup() {
721
+ if (this.statusTimer) {
722
+ clearInterval(this.statusTimer);
723
+ this.statusTimer = undefined;
724
+ }
684
725
  try {
685
726
  if (this.dnsServer) {
686
727
  await this.dnsServer.stop();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/lan",
3
- "version": "0.1.50",
3
+ "version": "0.1.52",
4
4
  "description": "Private virtual LAN for self-hosted services and AI agents, built on Elastos Carrier. NAT-traversal, name service, ACL, all over a peer-to-peer mesh — no public IP required.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",