Update market, account, and onion operations
Capture the current CyberLux UI, commerce, messaging, and Tor ops updates so local main can be pushed to the remote. Made-with: Cursor
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
* node scripts/onion-status.cjs
|
||||
* npm run onions:status
|
||||
*
|
||||
* Reading /var/lib/tor/*/hostname usually requires sudo:
|
||||
* Reading hostname files under /var/lib/tor (one directory per service) usually
|
||||
* requires sudo:
|
||||
* sudo node scripts/onion-status.cjs
|
||||
*/
|
||||
|
||||
@@ -20,21 +21,46 @@ const REPO = path.join(__dirname, "..");
|
||||
const jsonPath = path.join(__dirname, "onion-nodes.json");
|
||||
const data = JSON.parse(fs.readFileSync(jsonPath, "utf8"));
|
||||
|
||||
/** Populated by export-onion-urls.sh — readable when /var/lib/tor is root-only. */
|
||||
function readOnionFromExportFile(torDir) {
|
||||
const exportPath = path.join(REPO, "onion-urls.txt");
|
||||
let raw;
|
||||
try {
|
||||
raw = fs.readFileSync(exportPath, "utf8");
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
const line = raw.split("\n").find((l) => l.trimStart().startsWith(torDir));
|
||||
if (!line) return "";
|
||||
const m = line.match(/https?:\/\/([a-z2-7]{56}\.onion)\b/i);
|
||||
return m ? m[1] : "";
|
||||
}
|
||||
|
||||
function readOnionHost(torDir) {
|
||||
const f = path.join("/var/lib/tor", torDir, "hostname");
|
||||
try {
|
||||
return fs.readFileSync(f, "utf8").trim();
|
||||
} catch (e) {
|
||||
if (e.code === "EACCES" || e.code === "EPERM") {
|
||||
return "(hostname file exists but not readable — try: sudo node scripts/onion-status.cjs)";
|
||||
const fromFile = readOnionFromExportFile(torDir);
|
||||
if (fromFile) return `${fromFile} (from onion-urls.txt)`;
|
||||
return "(hostname not readable — run: sudo bash scripts/export-onion-urls.sh, then retry)";
|
||||
}
|
||||
if (e.code === "ENOENT") {
|
||||
const fromFile = readOnionFromExportFile(torDir);
|
||||
if (fromFile) return `${fromFile} (from onion-urls.txt)`;
|
||||
return "(no hostname yet — is Tor running?)";
|
||||
}
|
||||
return `(${e.message})`;
|
||||
}
|
||||
}
|
||||
|
||||
function onionHttpUrl(onionField) {
|
||||
const m = String(onionField).match(/([a-z2-7]{56}\.onion)/i);
|
||||
if (m) return `http://${m[1]}`;
|
||||
return onionField;
|
||||
}
|
||||
|
||||
function checkLocalPort(port) {
|
||||
return new Promise((resolve) => {
|
||||
const req = http.request(
|
||||
@@ -77,14 +103,14 @@ async function main() {
|
||||
}
|
||||
|
||||
console.log("");
|
||||
console.log("CyberLux — onion URLs (from /var/lib/tor/*/hostname) + loopback health");
|
||||
console.log("CyberLux — onion URLs (from /var/lib/tor/<service>/hostname) + loopback health");
|
||||
console.log("─".repeat(100));
|
||||
let bad = 0;
|
||||
for (const r of rows) {
|
||||
const url =
|
||||
r.onion.startsWith("(") || r.onion.includes("not readable")
|
||||
? r.onion
|
||||
: `http://${r.onion}`;
|
||||
: onionHttpUrl(r.onion);
|
||||
const local = `http://127.0.0.1:${r.port}/`;
|
||||
const status =
|
||||
r.httpCode === 0 ? "DOWN/timeout" : `HTTP ${r.httpCode}`;
|
||||
|
||||
Reference in New Issue
Block a user