Changesets · Branches · Tags · Compare
| Changeset | e90296c642fac3e0f5b43a79f4b6a3e09ba10574037a20285ffe9cff2bfcb09f |
|---|---|
| Author | Gemini CLI <gemini@example.com> · 2026-05-29 14:18 -04:00 |
| Committer | Gemini CLI <gemini@example.com> · 2026-05-29 14:18 -04:00 |
| Parents | 2add7b6f6581 |
4 files changed
modified src/app/api/osint/shodan/route.ts +1 −0
| @@ -11,6 +11,7 @@ | ||
| 11 | 11 | try { |
| 12 | 12 | const res = await fetch(`https://internetdb.shodan.io/${encodeURIComponent(ip)}`, { |
| 13 | 13 | signal: AbortSignal.timeout(8000), |
| 14 | + cache: 'no-store' | |
| 14 | 15 | }); |
| 15 | 16 | |
| 16 | 17 | if (res.status === 404) { |
modified src/app/api/osint/sweep/route.ts +6 −2
| @@ -403,11 +403,15 @@ | ||
| 403 | 403 | 20, |
| 404 | 404 | async (url) => { |
| 405 | 405 | try { |
| 406 | - const res = await fetch(url, { signal: AbortSignal.timeout(5000) }); | |
| 406 | + const res = await fetch(url, { | |
| 407 | + signal: AbortSignal.timeout(5000), | |
| 408 | + cache: 'no-store' | |
| 409 | + }); | |
| 407 | 410 | if (res.status === 404) return null; // Non-responsive host |
| 408 | 411 | if (!res.ok) return null; |
| 409 | 412 | return (await res.json()) as ShodanInternetDBResponse; |
| 410 | - } catch { | |
| 413 | + } catch (e) { | |
| 414 | + console.error(`[OSIRIS] Shodan fetch error for ${url}:`, e); | |
| 411 | 415 | return null; |
| 412 | 416 | } |
| 413 | 417 | }, |
added test_route.js +37 −0
| @@ -0,0 +1,37 @@ | ||
| 1 | +const urls = []; | |
| 2 | +for(let i=0; i<256; i++) urls.push(`https://internetdb.shodan.io/212.83.149.${i}`); | |
| 3 | + | |
| 4 | +async function batchFetch(urls, concurrency, fn) { | |
| 5 | + const results = new Array(urls.length).fill(null); | |
| 6 | + let idx = 0; | |
| 7 | + const workers = Array.from({ length: concurrency }, async () => { | |
| 8 | + while (idx < urls.length) { | |
| 9 | + const i = idx++; | |
| 10 | + results[i] = await fn(urls[i]); | |
| 11 | + } | |
| 12 | + }); | |
| 13 | + await Promise.all(workers); | |
| 14 | + return results; | |
| 15 | +} | |
| 16 | + | |
| 17 | +async function run() { | |
| 18 | + const t0 = Date.now(); | |
| 19 | + const shodanResults = await batchFetch( | |
| 20 | + urls, | |
| 21 | + 20, | |
| 22 | + async (url) => { | |
| 23 | + try { | |
| 24 | + const res = await fetch(url, { signal: AbortSignal.timeout(5000) }); | |
| 25 | + if (res.status === 404) return null; // Non-responsive host | |
| 26 | + if (!res.ok) return null; | |
| 27 | + return await res.json(); | |
| 28 | + } catch { | |
| 29 | + return null; | |
| 30 | + } | |
| 31 | + }, | |
| 32 | + ); | |
| 33 | + | |
| 34 | + const valid = shodanResults.filter(Boolean); | |
| 35 | + console.log(`Found ${valid.length} devices in ${Date.now() - t0}ms`); | |
| 36 | +} | |
| 37 | +run(); |
added test_sweep.js +10 −0
| @@ -0,0 +1,10 @@ | ||
| 1 | +const urls = []; | |
| 2 | +for(let i=0; i<256; i++) urls.push(`https://internetdb.shodan.io/212.83.149.${i}`); | |
| 3 | +async function run() { | |
| 4 | + let errors = 0; | |
| 5 | + let successes = 0; | |
| 6 | + let t0 = Date.now(); | |
| 7 | + await Promise.all(urls.map(u => fetch(u).then(r => { if(r.ok || r.status === 404) successes++; else errors++; }).catch(e => errors++))); | |
| 8 | + console.log(`Successes (200 or 404): ${successes}, Errors (Rate limit or network): ${errors}, Time: ${Date.now() - t0}ms`); | |
| 9 | +} | |
| 10 | +run(); |