@sifxprime/krouter 0.5.157 → 0.5.159
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/app/.next-cli-build/BUILD_ID +1 -1
- package/app/.next-cli-build/app-path-routes-manifest.json +11 -11
- package/app/.next-cli-build/build-manifest.json +2 -2
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/environment/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/presidio/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error.html +1 -1
- package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_not-found.html +1 -1
- package/app/.next-cli-build/server/app/_not-found.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/api/models/route.js +1 -1
- package/app/.next-cli-build/server/app/api/providers/route.js +1 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/route.js +1 -1
- package/app/.next-cli-build/server/app/api/translator/console-logs/stream/route.js +1 -1
- package/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/app/.next-cli-build/server/app/api/version/shutdown/route.js +1 -1
- package/app/.next-cli-build/server/app/api/version/update/route.js +1 -1
- package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/callback.html +1 -1
- package/app/.next-cli-build/server/app/callback.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/basic-chat.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/basic-chat.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/!KGRhc2hib2FyZCk/dashboard/basic-chat/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/basic-chat.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/cli-tools.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/cli-tools.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/!KGRhc2hib2FyZCk/dashboard/cli-tools/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/cli-tools.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/combos.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/combos.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/combos.segments/!KGRhc2hib2FyZCk/dashboard/combos/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/combos.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/combos.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/endpoint.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/endpoint.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/!KGRhc2hib2FyZCk/dashboard/endpoint/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/endpoint.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/environment.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/environment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/environment.segments/!KGRhc2hib2FyZCk/dashboard/environment/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/environment.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/environment.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/!KGRhc2hib2FyZCk/dashboard/media-providers/web/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/media-providers/web.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/mitm.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/mitm.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/!KGRhc2hib2FyZCk/dashboard/mitm/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/mitm.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/presidio.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/presidio.rsc +4 -4
- package/app/.next-cli-build/server/app/dashboard/presidio.segments/!KGRhc2hib2FyZCk/dashboard/presidio/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/dashboard/presidio.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/dashboard/presidio.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/profile.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/profile.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/profile.segments/!KGRhc2hib2FyZCk/dashboard/profile/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/profile.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/profile.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers/new.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers/new.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/!KGRhc2hib2FyZCk/dashboard/providers/new/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/providers/new.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/providers.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/providers.segments/!KGRhc2hib2FyZCk/dashboard/providers/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/providers.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/providers.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/!KGRhc2hib2FyZCk/dashboard/proxy-pools/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/proxy-pools.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/pxpipe.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/pxpipe.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/!KGRhc2hib2FyZCk/dashboard/pxpipe/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/pxpipe.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/quota.html +2 -2
- package/app/.next-cli-build/server/app/dashboard/quota.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/quota.segments/!KGRhc2hib2FyZCk/dashboard/quota/__PAGE__.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/quota.segments/_full.segment.rsc +6 -6
- package/app/.next-cli-build/server/app/dashboard/quota.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/skills.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/skills.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/skills.segments/!KGRhc2hib2FyZCk/dashboard/skills/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/skills.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/skills.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/token-saver.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/token-saver.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/!KGRhc2hib2FyZCk/dashboard/token-saver/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/token-saver.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/translator.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/translator.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/translator.segments/!KGRhc2hib2FyZCk/dashboard/translator/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/translator.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/translator.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/usage.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/usage.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/usage.segments/!KGRhc2hib2FyZCk/dashboard/usage/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/usage.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard/usage.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard.html +1 -1
- package/app/.next-cli-build/server/app/dashboard.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard.segments/!KGRhc2hib2FyZCk/dashboard/__PAGE__.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard.segments/_full.segment.rsc +5 -5
- package/app/.next-cli-build/server/app/dashboard.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/index.html +1 -1
- package/app/.next-cli-build/server/app/index.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/landing.html +1 -1
- package/app/.next-cli-build/server/app/landing.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/login.html +1 -1
- package/app/.next-cli-build/server/app/login.rsc +4 -4
- package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app-paths-manifest.json +11 -11
- package/app/.next-cli-build/server/chunks/2365.js +1 -1
- package/app/.next-cli-build/server/chunks/4921.js +1 -1
- package/app/.next-cli-build/server/chunks/5718.js +1 -1
- package/app/.next-cli-build/server/chunks/706.js +3 -3
- package/app/.next-cli-build/server/chunks/8238.js +1 -1
- package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
- package/app/.next-cli-build/server/pages/404.html +1 -1
- package/app/.next-cli-build/server/pages/500.html +1 -1
- package/app/.next-cli-build/static/chunks/{1321-081b63f7d78bf41f.js → 1321-1c2a824823ca3ce1.js} +1 -1
- package/app/cli/package.json +1 -1
- package/app/package.json +1 -1
- package/cli.js +29 -14
- package/package.json +1 -1
- package/src/cli/api/client.js +4 -9
- package/src/lib/dataDir.js +75 -0
- /package/app/.next-cli-build/static/{LZeC-BuWxbn-5kt1kNc58 → 5yjzy8V3yYGJ5_YtOmrKY}/_buildManifest.js +0 -0
- /package/app/.next-cli-build/static/{LZeC-BuWxbn-5kt1kNc58 → 5yjzy8V3yYGJ5_YtOmrKY}/_ssgManifest.js +0 -0
package/app/cli/package.json
CHANGED
package/app/package.json
CHANGED
package/cli.js
CHANGED
|
@@ -45,6 +45,7 @@ function createSpinner(text) {
|
|
|
45
45
|
const pkg = require("./package.json");
|
|
46
46
|
const { ensureSqliteRuntime, buildEnvWithRuntime } = require("./hooks/sqliteRuntime");
|
|
47
47
|
const { ensureTrayRuntime } = require("./hooks/trayRuntime");
|
|
48
|
+
const { getDataDir: getAppDataDir } = require("./src/lib/dataDir");
|
|
48
49
|
const args = process.argv.slice(2);
|
|
49
50
|
|
|
50
51
|
// Self-heal SQLite runtime deps (sql.js + better-sqlite3) into ~/.krouter/runtime
|
|
@@ -202,13 +203,11 @@ function compareVersions(a, b) {
|
|
|
202
203
|
return 0;
|
|
203
204
|
}
|
|
204
205
|
|
|
205
|
-
//
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
: path.join(os.homedir(), `.${DATA_DIR_NAME}`);
|
|
211
|
-
}
|
|
206
|
+
// getAppDataDir comes from ./src/lib/dataDir (required at the top). It used to be
|
|
207
|
+
// a local copy that resolved ~/.krouter unconditionally and ignored DATA_DIR, so
|
|
208
|
+
// the three call sites below -- the tunnel directory, the mitm pidfile, and the
|
|
209
|
+
// db.json write in the crash-loop handler -- all looked in the wrong place
|
|
210
|
+
// whenever DATA_DIR was set. The db.json one failed silently.
|
|
212
211
|
|
|
213
212
|
// Kill PID from file (best-effort, removes file after)
|
|
214
213
|
function killByPidFile(pidFile) {
|
|
@@ -726,6 +725,9 @@ async function showInterfaceMenu(latestVersion) {
|
|
|
726
725
|
}
|
|
727
726
|
|
|
728
727
|
const MAX_RESTARTS = 2;
|
|
728
|
+
// Must match MITM_RECOVERY_MARKER in src/shared/services/initializeApp.js.
|
|
729
|
+
// tests/unit/mitm-recovery-marker.test.js pins the two together.
|
|
730
|
+
const MITM_RECOVERY_MARKER = ".mitm-recovery";
|
|
729
731
|
const RESTART_RESET_MS = 30000; // Reset counter if alive > 30s
|
|
730
732
|
|
|
731
733
|
// First non-internal IPv4 — the address remote peers actually reach when bound to 0.0.0.0.
|
|
@@ -1033,14 +1035,27 @@ function startServer(latestVersion) {
|
|
|
1033
1035
|
|
|
1034
1036
|
if (restartCount >= MAX_RESTARTS) {
|
|
1035
1037
|
console.error(`\n⚠️ Server crashed ${MAX_RESTARTS} times. Disabling MIT and restarting...`);
|
|
1038
|
+
// Ask the app to disable MITM; do not write the setting here. This used to
|
|
1039
|
+
// patch mitmEnabled in DATA_DIR/db.json, which the app migrated into SQLite
|
|
1040
|
+
// and now keeps only as a rollback artifact -- so the write landed in a file
|
|
1041
|
+
// nothing reads, and this recovery path had quietly done nothing for a long
|
|
1042
|
+
// time. A supervisor has no business knowing how the app stores settings.
|
|
1043
|
+
// MITM_RECOVERY_MARKER must match the constant of the same name in
|
|
1044
|
+
// src/shared/services/initializeApp.js.
|
|
1036
1045
|
try {
|
|
1037
|
-
const
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
} catch {
|
|
1046
|
+
const marker = path.join(getAppDataDir(), MITM_RECOVERY_MARKER);
|
|
1047
|
+
fs.mkdirSync(path.dirname(marker), { recursive: true });
|
|
1048
|
+
fs.writeFileSync(
|
|
1049
|
+
marker,
|
|
1050
|
+
JSON.stringify({ reason: "crash-loop", restarts: MAX_RESTARTS, at: new Date().toISOString() }, null, 2)
|
|
1051
|
+
);
|
|
1052
|
+
} catch (e) {
|
|
1053
|
+
// Not swallowed: if the request cannot be recorded, the restart below is
|
|
1054
|
+
// very likely to crash again for the same reason, and the user should be
|
|
1055
|
+
// told why rather than watching it loop.
|
|
1056
|
+
console.error(` Could not record the MITM recovery request: ${e.message}`);
|
|
1057
|
+
console.error(" If this keeps crashing, disable MITM from the dashboard.");
|
|
1058
|
+
}
|
|
1044
1059
|
restartCount = 0;
|
|
1045
1060
|
server = spawnServer();
|
|
1046
1061
|
attachServerEvents();
|
package/package.json
CHANGED
package/src/cli/api/client.js
CHANGED
|
@@ -3,7 +3,6 @@ const https = require("https");
|
|
|
3
3
|
const crypto = require("crypto");
|
|
4
4
|
const fs = require("node:fs");
|
|
5
5
|
const path = require("node:path");
|
|
6
|
-
const os = require("node:os");
|
|
7
6
|
const { machineIdSync } = require("node-machine-id");
|
|
8
7
|
|
|
9
8
|
// Default configuration
|
|
@@ -15,14 +14,10 @@ const DEFAULT_CONFIG = {
|
|
|
15
14
|
|
|
16
15
|
const CLI_TOKEN_HEADER = "x-9r-cli-token";
|
|
17
16
|
const CLI_TOKEN_SALT = "9r-cli-auth";
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return path.join(process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming"), "krouter");
|
|
23
|
-
}
|
|
24
|
-
return path.join(os.homedir(), ".krouter");
|
|
25
|
-
}
|
|
17
|
+
// Was a third hand-synced copy of this resolver. It honoured DATA_DIR but
|
|
18
|
+
// without the Windows-path and writability guards the others have, so the same
|
|
19
|
+
// setting could resolve three different ways in one process.
|
|
20
|
+
const { getDataDir } = require("../../lib/dataDir");
|
|
26
21
|
|
|
27
22
|
const MACHINE_ID_FILE = path.join(getDataDir(), "machine-id");
|
|
28
23
|
const AUTH_DIR = path.join(getDataDir(), "auth");
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Where the CLI keeps its data. One definition for the whole published package.
|
|
5
|
+
*
|
|
6
|
+
* This exists because there were three hand-synced copies of this logic, each
|
|
7
|
+
* carrying a "kept in sync with..." comment, and one of them had drifted:
|
|
8
|
+
* cli.js resolved `~/.krouter` unconditionally and ignored DATA_DIR entirely.
|
|
9
|
+
* That is a documented setting (README: "DATA_DIR | ~/.krouter | Data directory
|
|
10
|
+
* (SQLite, certs, cache)") and ARCHITECTURE.md promises db.json lives at
|
|
11
|
+
* `${DATA_DIR}/db.json`, so anyone who set it -- Docker users, mainly -- got a
|
|
12
|
+
* split brain: auth and machine-id read from DATA_DIR, while db.json, the
|
|
13
|
+
* tunnel directory and the mitm pidfile read from the home directory.
|
|
14
|
+
*
|
|
15
|
+
* The worst of it was silent. cli.js disables MITM in DATA_DIR/db.json to break
|
|
16
|
+
* a crash loop; looking in the wrong place made existsSync false, the
|
|
17
|
+
* best-effort catch swallowed it, and the server kept crash-looping with the
|
|
18
|
+
* safety valve doing nothing.
|
|
19
|
+
*
|
|
20
|
+
* Mirrors the app's own src/lib/dataDir.js. It cannot import it: that module is
|
|
21
|
+
* ESM and lives outside this package's `files`, so the published CLI has no
|
|
22
|
+
* access to it. Keep the two in step.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const fs = require("node:fs");
|
|
26
|
+
const path = require("node:path");
|
|
27
|
+
const os = require("node:os");
|
|
28
|
+
|
|
29
|
+
const APP_NAME = "krouter";
|
|
30
|
+
|
|
31
|
+
/** The platform default, used when DATA_DIR is unset or unusable. */
|
|
32
|
+
function appDir() {
|
|
33
|
+
if (process.platform === "win32") {
|
|
34
|
+
// Falling back to "" here would yield a *relative* path, which is how the
|
|
35
|
+
// previous cli.js copy could end up writing into the current directory.
|
|
36
|
+
return path.join(
|
|
37
|
+
process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming"),
|
|
38
|
+
APP_NAME
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return path.join(os.homedir(), `.${APP_NAME}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Resolve the data directory, honouring DATA_DIR.
|
|
46
|
+
*
|
|
47
|
+
* Creating the directory is deliberate and matches the app: callers immediately
|
|
48
|
+
* join subpaths onto the result, so a configured-but-absent directory would
|
|
49
|
+
* otherwise fail at the first write rather than here.
|
|
50
|
+
*/
|
|
51
|
+
function getDataDir() {
|
|
52
|
+
const configured = process.env.DATA_DIR;
|
|
53
|
+
if (!configured) return appDir();
|
|
54
|
+
|
|
55
|
+
// A Unix path on Windows almost always means a Linux-targeted .env or Docker
|
|
56
|
+
// config leaked into a Windows run. Honouring it would write somewhere the
|
|
57
|
+
// user never intended.
|
|
58
|
+
if (process.platform === "win32" && /^\//.test(configured)) {
|
|
59
|
+
console.warn(`[DATA_DIR] '${configured}' is a Unix path on Windows - falling back to the default`);
|
|
60
|
+
return appDir();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
fs.mkdirSync(configured, { recursive: true });
|
|
65
|
+
return configured;
|
|
66
|
+
} catch (e) {
|
|
67
|
+
if (e && (e.code === "EACCES" || e.code === "EPERM")) {
|
|
68
|
+
console.warn(`[DATA_DIR] '${configured}' is not writable - falling back to ~/.${APP_NAME}`);
|
|
69
|
+
return appDir();
|
|
70
|
+
}
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = { getDataDir, appDir, APP_NAME };
|
|
File without changes
|
/package/app/.next-cli-build/static/{LZeC-BuWxbn-5kt1kNc58 → 5yjzy8V3yYGJ5_YtOmrKY}/_ssgManifest.js
RENAMED
|
File without changes
|