mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 13:22:11 +03:00
- Add collapsible '16 Real Pain Points' section to all 30 READMEs - Fix 5 files bypassing dataPaths.ts with hardcoded os.homedir() (closes #156) - Add per-provider User-Agent env var overrides in base executor (closes #155) - Sync .env and .env.example with 9 provider UA defaults - Update CHANGELOG.md for v1.7.0
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import { ensureCliConfigWriteAllowed, getCliConfigPaths } from "@/shared/services/cliRuntime";
|
||||
import { resolveDataDir } from "@/lib/dataPaths";
|
||||
|
||||
const PROFILES_DIR = path.join(os.homedir(), ".omniroute", "codex-profiles");
|
||||
const PROFILES_DIR = path.join(resolveDataDir(), "codex-profiles");
|
||||
|
||||
/**
|
||||
* Ensure profiles directory exists
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
import { resolveDataDir } from "@/lib/dataPaths";
|
||||
|
||||
const TARGET_HOST = "daily-cloudcode-pa.googleapis.com";
|
||||
|
||||
@@ -8,7 +8,7 @@ const TARGET_HOST = "daily-cloudcode-pa.googleapis.com";
|
||||
* Generate self-signed SSL certificate using selfsigned (pure JS, no openssl needed)
|
||||
*/
|
||||
export async function generateCert() {
|
||||
const certDir = path.join(os.homedir(), ".omniroute", "mitm");
|
||||
const certDir = path.join(resolveDataDir(), "mitm");
|
||||
const keyPath = path.join(certDir, "server.key");
|
||||
const certPath = path.join(certDir, "server.crt");
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { spawn } from "child_process";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
import { resolveDataDir } from "@/lib/dataPaths";
|
||||
import { addDNSEntry, removeDNSEntry } from "./dns/dnsConfig";
|
||||
import { generateCert } from "./cert/generate";
|
||||
import { installCert } from "./cert/install";
|
||||
@@ -24,7 +24,7 @@ export function clearCachedPassword() {
|
||||
}
|
||||
|
||||
// server.js is in same directory as this file
|
||||
const PID_FILE = path.join(os.homedir(), ".omniroute", "mitm", ".mitm.pid");
|
||||
const PID_FILE = path.join(resolveDataDir(), "mitm", ".mitm.pid");
|
||||
|
||||
// Check if a PID is alive
|
||||
function isProcessAlive(pid) {
|
||||
@@ -71,7 +71,7 @@ export async function getMitmStatus() {
|
||||
}
|
||||
|
||||
// Check cert
|
||||
const certDir = path.join(os.homedir(), ".omniroute", "mitm");
|
||||
const certDir = path.join(resolveDataDir(), "mitm");
|
||||
const certExists = fs.existsSync(path.join(certDir, "server.crt"));
|
||||
|
||||
return { running, pid, dnsConfigured, certExists };
|
||||
@@ -89,7 +89,7 @@ export async function startMitm(apiKey, sudoPassword) {
|
||||
}
|
||||
|
||||
// 1. Generate SSL certificate if not exists
|
||||
const certPath = path.join(os.homedir(), ".omniroute", "mitm", "server.crt");
|
||||
const certPath = path.join(resolveDataDir(), "mitm", "server.crt");
|
||||
if (!fs.existsSync(certPath)) {
|
||||
console.log("Generating SSL certificate...");
|
||||
await generateCert();
|
||||
|
||||
@@ -5,13 +5,21 @@ const dns = require("dns");
|
||||
const { promisify } = require("util");
|
||||
const os = require("os");
|
||||
|
||||
// Resolve data directory — mirrors src/lib/dataPaths.ts logic.
|
||||
// This file runs as a standalone CommonJS process and cannot import the ES module.
|
||||
function getDataDir() {
|
||||
if (process.env.DATA_DIR) return path.resolve(process.env.DATA_DIR.trim());
|
||||
return path.join(os.homedir(), ".omniroute");
|
||||
}
|
||||
|
||||
// Configuration
|
||||
const TARGET_HOST = "daily-cloudcode-pa.googleapis.com";
|
||||
const LOCAL_PORT = 443;
|
||||
const ROUTER_URL = "http://localhost:20128/v1/chat/completions";
|
||||
const API_KEY = process.env.ROUTER_API_KEY;
|
||||
const DB_FILE = path.join(os.homedir(), ".omniroute", "db.json");
|
||||
const SQLITE_FILE = path.join(os.homedir(), ".omniroute", "storage.sqlite");
|
||||
const DATA_DIR = getDataDir();
|
||||
const DB_FILE = path.join(DATA_DIR, "db.json");
|
||||
const SQLITE_FILE = path.join(DATA_DIR, "storage.sqlite");
|
||||
|
||||
let _sqliteDb = null;
|
||||
|
||||
@@ -24,7 +32,7 @@ if (!API_KEY) {
|
||||
}
|
||||
|
||||
// Load SSL certificates
|
||||
const certDir = path.join(os.homedir(), ".omniroute", "mitm");
|
||||
const certDir = path.join(DATA_DIR, "mitm");
|
||||
const sslOptions = {
|
||||
key: fs.readFileSync(path.join(certDir, "server.key")),
|
||||
cert: fs.readFileSync(path.join(certDir, "server.crt")),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import { resolveDataDir } from "@/lib/dataPaths";
|
||||
|
||||
const BACKUP_DIR = path.join(os.homedir(), ".omniroute", "backups");
|
||||
const BACKUP_DIR = path.join(resolveDataDir(), "backups");
|
||||
const MAX_BACKUPS_PER_TOOL = 5;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user