@teamscala/service-boot 0.23.298 → 0.23.299

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.
Files changed (2) hide show
  1. package/package.json +2 -1
  2. package/src/serve/serve.ts +26 -0
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "name": "@teamscala/service-boot",
8
8
  "type": "module",
9
- "version": "0.23.298",
9
+ "version": "0.23.299",
10
10
  "sideEffects": false,
11
11
  "files": [
12
12
  "src"
@@ -35,6 +35,7 @@
35
35
  "@teamscala/object-storage": "*",
36
36
  "@teamscala/orpc": "*",
37
37
  "@teamscala/os": "*",
38
+ "@teamscala/proc-walker": "*",
38
39
  "@teamscala/realtime-utils": "*",
39
40
  "@teamscala/resolver-engine": "*",
40
41
  "@teamscala/timing": "*",
@@ -10,6 +10,7 @@
10
10
 
11
11
  import type { Hono } from "hono";
12
12
  import { createBunWebSocket } from "hono/bun";
13
+ import { resolveSocketPeer } from "@teamscala/proc-walker/socket-peer";
13
14
 
14
15
  const _bunWs = createBunWebSocket();
15
16
 
@@ -88,6 +89,31 @@ function createFetchHandler(
88
89
  headers.delete("x-caller-remote-address");
89
90
  headers.set("x-caller-remote-address", String(address));
90
91
  }
92
+ // Local-caller attribution: a local `fetch` carries no forwarding
93
+ // header, so for a loopback peer (no CF-Connecting-IP / X-Forwarded-
94
+ // For) resolve the owning local PROCESS from the socket + stamp it for
95
+ // the access log. Names the daemon behind every local request —
96
+ // including an unidentified sweeper keeping scale-to-zero apps awake.
97
+ // Trust stays transport-derived (no-client-controlled-trust-signals);
98
+ // the comm is attribution only. resolveSocketPeer is TTL-cached + never
99
+ // throws (returns null on any miss); skipped for external callers.
100
+ if (
101
+ address &&
102
+ (address === "127.0.0.1" ||
103
+ address === "::1" ||
104
+ address === "::ffff:127.0.0.1") &&
105
+ !headers.has("cf-connecting-ip") &&
106
+ !headers.get("x-forwarded-for") &&
107
+ typeof port === "number" &&
108
+ port > 0
109
+ ) {
110
+ const owner = resolveSocketPeer(port);
111
+ if (owner) {
112
+ headers.set("x-caller-local-comm", owner.comm);
113
+ const cmd = owner.cmdline.join(" ").trim();
114
+ if (cmd) headers.set("x-caller-local-cmd", cmd.slice(0, 160));
115
+ }
116
+ }
91
117
  const cloned = new Request(req.url, {
92
118
  method: req.method,
93
119
  headers,