@decentnetwork/lan 0.1.50 → 0.1.51

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.
@@ -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.51",
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",