Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

const crypto = require('crypto');
const fs = require('fs');
const os = require('os');
const path = require('path');
const config = require('./config');
const { resolveCcxrayHome } = require('./paths');

// ─── Root secret resolution ──────────────────────────────────────────

function getHubDir() {
return process.env.CCXRAY_HOME || path.join(os.homedir(), '.ccxray');
return resolveCcxrayHome();
}

function ensureHubDir() {
Expand Down
4 changes: 2 additions & 2 deletions server/hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

const fs = require('fs');
const path = require('path');
const os = require('os');
const net = require('net');
const http = require('http');
const { resolveCcxrayHome } = require('./paths');

const HUB_DIR = process.env.CCXRAY_HOME || path.join(os.homedir(), '.ccxray');
const HUB_DIR = resolveCcxrayHome();
const HUB_LOCK_PATH = path.join(HUB_DIR, 'hub.json');
const HUB_LOG_PATH = path.join(HUB_DIR, 'hub.log');
const SOCK_PATH = path.join(HUB_DIR, 'hub.sock');
Expand Down
11 changes: 5 additions & 6 deletions server/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
const path = require('path');
const os = require('os');

// Single source of truth for ccxray's on-disk locations. config.js and
// storage/index.js both resolve the logs dir from here, so the startup banner
// and legacy-migration target can no longer drift from where logs actually
// get written. hub.js, settings.js, ratelimit-log.js, and auth.js still
// duplicate the home-dir resolution inline and are candidates for future
// consolidation here.
// Single source of truth for ccxray's on-disk locations. config.js,
// storage/index.js, hub.js, settings.js, ratelimit-log.js, and auth.js all
// resolve their ccxray home/logs paths from here, so the startup banner,
// legacy-migration target, and every other consumer stay in sync and can no
// longer drift from where logs actually get written.
//
// Precedence (mirrors the storage adapter's historical resolution):
// logs dir : LOGS_DIR > <home>/logs
Expand Down
4 changes: 2 additions & 2 deletions server/ratelimit-log.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';

const fs = require('fs');
const os = require('os');
const path = require('path');
const { resolveCcxrayHome } = require('./paths');

// Append-only log of `anthropic-ratelimit-*` headers observed from upstream responses.
// Used for future calibration of plan-specific limits (Max 5x vs 20x tokens5h quota).
// File: ~/.ccxray/ratelimit-samples.jsonl (respects CCXRAY_HOME env)

const CCXRAY_HOME = process.env.CCXRAY_HOME || path.join(os.homedir(), '.ccxray');
const CCXRAY_HOME = resolveCcxrayHome();
const SAMPLES_FILE = path.join(CCXRAY_HOME, 'ratelimit-samples.jsonl');

// Dedupe per model: skip writing if headers identical to last sample for
Expand Down
4 changes: 2 additions & 2 deletions server/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

const fs = require('fs');
const path = require('path');
const os = require('os');
const { resolveCcxrayHome } = require('./paths');

const SETTINGS_DIR = process.env.CCXRAY_HOME || path.join(os.homedir(), '.ccxray');
const SETTINGS_DIR = resolveCcxrayHome();
const SETTINGS_PATH = path.join(SETTINGS_DIR, 'settings.json');

const DEFAULTS = {
Expand Down
Loading