Spaces:
Running
Running
debug: scan Redis DB 0/1/2 + keyspace in debug-logs
Browse files- health-server.js +24 -32
health-server.js
CHANGED
|
@@ -1943,40 +1943,32 @@ const server = http.createServer((req, res) => {
|
|
| 1943 |
let redisSection = "=== REDIS codeVerifier CHECK ===\n";
|
| 1944 |
try {
|
| 1945 |
const { execSync } = require("child_process");
|
| 1946 |
-
const
|
| 1947 |
-
|
| 1948 |
-
|
| 1949 |
-
|
| 1950 |
-
|
| 1951 |
-
|
| 1952 |
-
|
| 1953 |
-
|
| 1954 |
-
|
| 1955 |
-
|
| 1956 |
-
|
| 1957 |
-
|
| 1958 |
-
|
| 1959 |
-
|
| 1960 |
-
|
| 1961 |
-
|
| 1962 |
-
redisSection += ` ${key}:
|
| 1963 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1964 |
}
|
| 1965 |
-
const colonIdx = val.indexOf(":");
|
| 1966 |
-
const token = colonIdx > 0 ? val.slice(0, colonIdx) : "(none β no colon found!)";
|
| 1967 |
-
const secret = colonIdx > 0 ? val.slice(colonIdx + 1) : "(none β no colon found!)";
|
| 1968 |
-
const extraColons = (val.match(/:/g) || []).length - 1;
|
| 1969 |
-
const tokenShow = token.slice(0, 12) + "... (len=" + token.length + ")";
|
| 1970 |
-
const secretShow = secret.slice(0, 12) + "... (len=" + secret.length + ")";
|
| 1971 |
-
const note = colonIdx < 0
|
| 1972 |
-
? "β NO COLON β split will fail β empty secret β bad signature!"
|
| 1973 |
-
: extraColons > 0
|
| 1974 |
-
? `β ${extraColons} extra colon(s) in value β split(':')[1] truncates secret!`
|
| 1975 |
-
: secret.length < 30
|
| 1976 |
-
? "β secret looks short β might be truncated"
|
| 1977 |
-
: "β format ok";
|
| 1978 |
-
redisSection += ` ${key}\n token : ${tokenShow}\n secret: ${secretShow}\n ttl : ${ttl}s\n note : ${note}\n`;
|
| 1979 |
}
|
|
|
|
| 1980 |
}
|
| 1981 |
} catch (e) {
|
| 1982 |
redisSection += `(redis-cli error: ${e.message})`;
|
|
|
|
| 1943 |
let redisSection = "=== REDIS codeVerifier CHECK ===\n";
|
| 1944 |
try {
|
| 1945 |
const { execSync } = require("child_process");
|
| 1946 |
+
const rc = (cmd) => { try { return execSync(cmd, { timeout: 5000 }).toString().trim(); } catch(e) { return "(err: " + e.message.slice(0,60) + ")"; } };
|
| 1947 |
+
|
| 1948 |
+
const keyspace = rc("redis-cli -h 127.0.0.1 -p 6379 info keyspace 2>/dev/null");
|
| 1949 |
+
redisSection += `Redis keyspace:\n${keyspace || "(empty)"}\n\n`;
|
| 1950 |
+
|
| 1951 |
+
// Check DB 0 (default) and DB 1 for all keys
|
| 1952 |
+
for (const db of [0, 1, 2]) {
|
| 1953 |
+
const dbFlag = db === 0 ? "" : `-n ${db}`;
|
| 1954 |
+
const allKeys = rc(`redis-cli -h 127.0.0.1 -p 6379 ${dbFlag} keys "*" 2>/dev/null`);
|
| 1955 |
+
const loginKeys = rc(`redis-cli -h 127.0.0.1 -p 6379 ${dbFlag} keys "login:*" 2>/dev/null`);
|
| 1956 |
+
redisSection += `DB ${db}: total keys preview: ${allKeys ? allKeys.split("\n").slice(0,8).join(", ") : "(none)"}\n`;
|
| 1957 |
+
redisSection += `DB ${db}: login:* keys: ${loginKeys || "(none)"}\n`;
|
| 1958 |
+
if (loginKeys && !loginKeys.startsWith("(")) {
|
| 1959 |
+
for (const key of loginKeys.split("\n").filter(Boolean).slice(0, 3)) {
|
| 1960 |
+
const val = rc(`redis-cli -h 127.0.0.1 -p 6379 ${dbFlag} get "${key}" 2>/dev/null`);
|
| 1961 |
+
const ttl = rc(`redis-cli -h 127.0.0.1 -p 6379 ${dbFlag} ttl "${key}" 2>/dev/null`);
|
| 1962 |
+
if (!val) { redisSection += ` ${key}: EMPTY!\n`; continue; }
|
| 1963 |
+
const colonIdx = val.indexOf(":");
|
| 1964 |
+
const token = colonIdx > 0 ? val.slice(0, colonIdx) : "";
|
| 1965 |
+
const secret = colonIdx > 0 ? val.slice(colonIdx + 1) : "";
|
| 1966 |
+
const extraColons = (val.match(/:/g) || []).length - 1;
|
| 1967 |
+
const note = colonIdx < 0 ? "β NO COLON!" : extraColons > 0 ? `β ${extraColons} extra colon(s)` : secret.length < 30 ? "β secret short" : "β ok";
|
| 1968 |
+
redisSection += ` ${key} [TTL=${ttl}s]\n token: ${token.slice(0,12)}... (len=${token.length})\n secret: ${secret.slice(0,12)}... (len=${secret.length})\n note: ${note}\n`;
|
| 1969 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1970 |
}
|
| 1971 |
+
redisSection += "\n";
|
| 1972 |
}
|
| 1973 |
} catch (e) {
|
| 1974 |
redisSection += `(redis-cli error: ${e.message})`;
|