@codemem/server 0.26.2 → 0.27.0

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.
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { serveStatic } from "@hono/node-server/serve-static";
5
5
  import { Hono } from "hono";
6
6
  import { createMiddleware } from "hono/factory";
7
7
  import { RateLimiter } from "limiter";
8
- import { homedir } from "node:os";
8
+ import { homedir, networkInterfaces } from "node:os";
9
9
  import { and, count, desc, eq, inArray, isNotNull, max, ne } from "drizzle-orm";
10
10
  import { drizzle } from "drizzle-orm/better-sqlite3";
11
11
  import { createHash, randomUUID } from "node:crypto";
@@ -1436,6 +1436,13 @@ function coordinatorAdminStatusPayload(config = readCoordinatorSyncConfig()) {
1436
1436
  has_groups: hasGroups
1437
1437
  };
1438
1438
  }
1439
+ function pairingAdvertiseAddresses(config = readCoordinatorSyncConfig()) {
1440
+ const advertise = String(config.syncAdvertise || "auto").trim().toLowerCase();
1441
+ if (advertise && advertise !== "auto" && advertise !== "default") return mergeAddresses([], String(config.syncAdvertise || "").split(",").map((item) => item.trim()).filter(Boolean));
1442
+ if (config.syncHost && config.syncHost !== "0.0.0.0") return [`${config.syncHost}:${config.syncPort}`];
1443
+ const addresses = Object.values(networkInterfaces()).flatMap((entries) => entries ?? []).filter((entry) => !entry.internal).map((entry) => entry.address).filter((address) => address && address !== "127.0.0.1" && address !== "::1").map((address) => `${address}:${config.syncPort}`);
1444
+ return [...new Set(addresses)];
1445
+ }
1439
1446
  function resolveCoordinatorAdminGroup(requestedGroup, status) {
1440
1447
  const explicit = String(requestedGroup ?? "").trim();
1441
1448
  if (explicit) return explicit;
@@ -2484,6 +2491,7 @@ function syncRoutes(getStore, getSyncRuntimeStatus) {
2484
2491
  redacted: true,
2485
2492
  pairing_filter_hint: PAIRING_FILTER_HINT
2486
2493
  });
2494
+ const config = readCoordinatorSyncConfig();
2487
2495
  const d = drizzle(store.db, { schema });
2488
2496
  const deviceRow = d.select({
2489
2497
  device_id: schema.syncDevice.device_id,
@@ -2511,7 +2519,7 @@ function syncRoutes(getStore, getSyncRuntimeStatus) {
2511
2519
  fingerprint,
2512
2520
  public_key: publicKey ?? null,
2513
2521
  pairing_filter_hint: PAIRING_FILTER_HINT,
2514
- addresses: []
2522
+ addresses: pairingAdvertiseAddresses(config)
2515
2523
  });
2516
2524
  }
2517
2525
  });