mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-23 04:09:49 +00:00
# v0.4.29 (2026-05-10)
## Features - Add Cline & Kilo Code tool cards - Tailscale TUN mode for stable Funnel TLS - Sort APIKEY providers by usage, collapse to top 20 ## Improvements - Local Material Symbols font (no Google Fonts) - Docker base: Bun → Node 22-alpine - MITM reads aliases from JSON cache (no native sqlite) - Stream stall timeout (2 min) in open-sse ## Fixes - Fal.ai key test: use stable models endpoint
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// JSON cache for mitmAlias — read by standalone MITM server (no SQLite native binding).
|
||||
// Source of truth = SQLite kv['mitmAlias']. JSON is a read-replica synced on app start
|
||||
// and after every UI write.
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
|
||||
const DATA_DIR = process.env.DATA_DIR
|
||||
|| (process.platform === "win32"
|
||||
? path.join(process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming"), "9router")
|
||||
: path.join(os.homedir(), ".9router"));
|
||||
|
||||
const CACHE_FILE = path.join(DATA_DIR, "mitm", "aliases.json");
|
||||
|
||||
function writeAtomic(data) {
|
||||
const dir = path.dirname(CACHE_FILE);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
const tmp = `${CACHE_FILE}.tmp`;
|
||||
fs.writeFileSync(tmp, JSON.stringify(data, null, 2), "utf8");
|
||||
fs.renameSync(tmp, CACHE_FILE);
|
||||
}
|
||||
|
||||
// Sync entire mitmAlias map from DB → JSON file
|
||||
export async function syncToJson() {
|
||||
try {
|
||||
const { getMitmAlias } = await import("@/lib/db/repos/aliasRepo.js");
|
||||
const all = await getMitmAlias();
|
||||
writeAtomic(all || {});
|
||||
} catch (e) {
|
||||
console.log("[mitmAliasCache] sync failed:", e.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Update cache for a single tool after UI saves to DB
|
||||
export function writeAliasForTool(tool, mappings) {
|
||||
try {
|
||||
let current = {};
|
||||
if (fs.existsSync(CACHE_FILE)) {
|
||||
try { current = JSON.parse(fs.readFileSync(CACHE_FILE, "utf8")); } catch { /* corrupted → reset */ }
|
||||
}
|
||||
current[tool] = mappings || {};
|
||||
writeAtomic(current);
|
||||
} catch (e) {
|
||||
console.log("[mitmAliasCache] write failed:", e.message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user