GeminiBot
commited on
Commit
·
afd22b0
1
Parent(s):
e97c1d1
Add IP check to diagnostics
Browse files- src/server.ts +22 -17
src/server.ts
CHANGED
|
@@ -123,23 +123,28 @@ const server = createServer(async (req: IncomingMessage, res: ServerResponse) =>
|
|
| 123 |
uptime: process.uptime()
|
| 124 |
};
|
| 125 |
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
// 3. Check JSDOM & Canvas Mock
|
| 144 |
try {
|
| 145 |
const { JSDOM } = require("jsdom");
|
|
|
|
| 123 |
uptime: process.uptime()
|
| 124 |
};
|
| 125 |
|
| 126 |
+
// 2. Check Network & DuckDuckGo Connectivity
|
| 127 |
+
try {
|
| 128 |
+
const start = Date.now();
|
| 129 |
+
|
| 130 |
+
// Check IP
|
| 131 |
+
const ipRes = await fetch("https://api.ipify.org?format=json");
|
| 132 |
+
const ipData = await ipRes.json() as any;
|
| 133 |
+
|
| 134 |
+
const res = await fetch("https://duckduckgo.com/duckchat/v1/status?q=1", {
|
| 135 |
+
headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" }
|
| 136 |
+
});
|
| 137 |
+
const hash = res.headers.get("x-vqd-hash-1");
|
| 138 |
+
report.checks.duckduckgo = {
|
| 139 |
+
status: res.status,
|
| 140 |
+
latency_ms: Date.now() - start,
|
| 141 |
+
vqd_present: !!hash,
|
| 142 |
+
ip_blocked: res.status === 403 || res.status === 418,
|
| 143 |
+
server_ip: ipData.ip
|
| 144 |
+
};
|
| 145 |
+
} catch (e: any) {
|
| 146 |
+
report.checks.duckduckgo = { error: e.message };
|
| 147 |
+
}
|
| 148 |
// 3. Check JSDOM & Canvas Mock
|
| 149 |
try {
|
| 150 |
const { JSDOM } = require("jsdom");
|