skydive-cli 0.5.0-beta.9 → 0.6.0-beta.10
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/CHANGELOG.md +13 -0
- package/README.md +61 -13
- package/dist/js/api-BFQ4PQDA.mjs +315 -0
- package/dist/js/{billing-blocked-Dgu5-oDy.mjs → billing-blocked-SE6tySLd.mjs} +1 -1
- package/dist/js/bin.mjs +674 -307
- package/dist/js/{boot-Q-Kh3nn5.mjs → boot-BEvwMeO6.mjs} +4708 -1005
- package/dist/js/chunk-BbwQpWto.mjs +33 -0
- package/dist/js/{client-DabRpc_T.mjs → client-B-5eaVyt.mjs} +437 -39
- package/dist/js/{client-c4c5MmgN.mjs → client-Btq6bMzX.mjs} +108 -2
- package/dist/js/client-DebOAhwd.mjs +5 -0
- package/dist/js/{daemon-D21wQ7DI.mjs → daemon-CLc3zjcv.mjs} +238 -50
- package/dist/js/daemon-ClXSvjcv.mjs +7 -0
- package/dist/js/{daemon-client-DPUNjhBB.mjs → daemon-client-DSIb7j28.mjs} +1 -1
- package/dist/js/daemon-client-pYWyRTyi.mjs +8 -0
- package/dist/js/dist-CRtjM7ba.mjs +1750 -0
- package/dist/js/forward-C-f04uyE.mjs +208 -0
- package/dist/js/{profiler-BkCV__ao.mjs → install-Bg_9I2-2.mjs} +545 -215
- package/dist/js/launcher.mjs +49 -0
- package/dist/js/localhost-cert-Bn-UBUmj.mjs +67 -0
- package/dist/js/{print-BpuyEfWX.mjs → print-CPBx8690.mjs} +257 -35
- package/dist/js/{print-Wakr3GJd.mjs → print-CT1G1LeA.mjs} +3 -3
- package/dist/js/{print-share-CKLPmsg0.mjs → print-share-DW5pHVDz.mjs} +9 -3
- package/dist/js/raw-pty-Ci2qFR9F.mjs +5 -0
- package/dist/js/{raw-pty-DY4KelZW.mjs → raw-pty-D5PhKZSl.mjs} +1 -1
- package/dist/js/{rest-I3imNduB.mjs → rest-B2bynGwY.mjs} +153 -19
- package/dist/js/rest-DejyWmRu.mjs +6 -0
- package/dist/js/tls-cert-BpCaD5AT.mjs +4 -0
- package/dist/js/tls-cert-Rua2oV7n.mjs +67 -0
- package/package.json +15 -6
- package/dist/js/api-DG5W6iwx.mjs +0 -131
- package/dist/js/client-BuU34IVE.mjs +0 -5
- package/dist/js/daemon-LSDSvMaC.mjs +0 -6
- package/dist/js/daemon-client-CUSq-Wuh.mjs +0 -7
- package/dist/js/forward-18QoL5dO.mjs +0 -68
- package/dist/js/raw-pty-DmdUf4_w.mjs +0 -5
- package/dist/js/rest-D29qNkto.mjs +0 -6
- /package/dist/js/{billing-blocked-2wju4gC_.mjs → billing-blocked-D3l5kJlX.mjs} +0 -0
- /package/dist/js/{http-error-DzyrsLAZ.mjs → http-error-BF2NZZE3.mjs} +0 -0
- /package/dist/js/{output-DYzzdXYV.mjs → output-C9mb3sUB.mjs} +0 -0
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { t as fetchForwardTarget } from "./api-DG5W6iwx.mjs";
|
|
3
|
-
import net from "node:net";
|
|
4
|
-
import { WebSocket, createWebSocketStream } from "ws";
|
|
5
|
-
|
|
6
|
-
//#region src/chat/portal/forward.ts
|
|
7
|
-
const TARGET_REFRESH_SAFETY_MS = 12e4;
|
|
8
|
-
/**
|
|
9
|
-
* The reverse portal's client half: listen on the local machine's loopback and
|
|
10
|
-
* pipe each TCP connection to the agent sandbox's daemon (`/portal/tcp`),
|
|
11
|
-
* which pipes to the sandbox's own loopback. The daemon is reached through the
|
|
12
|
-
* agent-webserver edge Worker (sandboxes have public ingress disabled; the
|
|
13
|
-
* Worker owns boot-resolution and injects the sandbox edge-auth token), so a
|
|
14
|
-
* sandbox recycle just costs the next connection a cold-start wait rather
|
|
15
|
-
* than invalidating the forward.
|
|
16
|
-
*/
|
|
17
|
-
async function startForward({ auth, agentId, localPort, targetPort, log }) {
|
|
18
|
-
let target = await fetchForwardTarget(auth, agentId);
|
|
19
|
-
let mintedAt = Date.now();
|
|
20
|
-
async function freshTarget() {
|
|
21
|
-
const ttlMs = target.expiresInSeconds * 1e3;
|
|
22
|
-
if (Date.now() - mintedAt > ttlMs - TARGET_REFRESH_SAFETY_MS) {
|
|
23
|
-
target = await fetchForwardTarget(auth, agentId);
|
|
24
|
-
mintedAt = Date.now();
|
|
25
|
-
}
|
|
26
|
-
return target;
|
|
27
|
-
}
|
|
28
|
-
const server = net.createServer((sock) => {
|
|
29
|
-
sock.pause();
|
|
30
|
-
(async () => {
|
|
31
|
-
let resolved;
|
|
32
|
-
try {
|
|
33
|
-
resolved = await freshTarget();
|
|
34
|
-
} catch (err) {
|
|
35
|
-
log(`forward: token refresh failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
36
|
-
sock.destroy();
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const ws = new WebSocket(`${resolved.daemonOrigin.replace(/^http/, "ws")}/portal/tcp?port=${targetPort}`, { headers: { authorization: `Bearer ${resolved.token}` } });
|
|
40
|
-
ws.on("open", () => {
|
|
41
|
-
const stream = createWebSocketStream(ws);
|
|
42
|
-
stream.on("error", () => sock.destroy());
|
|
43
|
-
sock.on("error", () => stream.destroy());
|
|
44
|
-
sock.pipe(stream).pipe(sock);
|
|
45
|
-
sock.resume();
|
|
46
|
-
});
|
|
47
|
-
ws.on("error", (err) => {
|
|
48
|
-
log(`forward: tunnel connect failed: ${err.message}`);
|
|
49
|
-
sock.destroy();
|
|
50
|
-
});
|
|
51
|
-
})();
|
|
52
|
-
});
|
|
53
|
-
await new Promise((resolve, reject) => {
|
|
54
|
-
server.once("error", reject);
|
|
55
|
-
server.listen(localPort, "127.0.0.1", () => {
|
|
56
|
-
server.removeListener("error", reject);
|
|
57
|
-
resolve();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
const addr = server.address();
|
|
61
|
-
return {
|
|
62
|
-
port: addr && typeof addr === "object" ? addr.port : localPort,
|
|
63
|
-
close: () => new Promise((resolve) => server.close(() => resolve()))
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
//#endregion
|
|
68
|
-
export { startForward };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|