Changeset cae8ded in Klonkt for src/services/ActivityPubService.js
- Timestamp:
- 07/31/2026 11:03:47 AM (6 weeks ago)
- Branches:
- main
- Children:
- 0ca7e5d0
- Parents:
- 0f48411
- File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
r0f48411 rcae8ded 96 96 if (!addrs.length || addrs.some((a) => isBlockedIp(a.address))) throw new Error('ssrf-blocked-host'); 97 97 } 98 // One honest name on ALL outbound federation traffic (Robins vraag, 31-7): 99 // safeFetch went out with the bare Node default before, and polite fediverse 100 // citizens say who they are (some instances even refuse anonymous UAs). A 101 // caller-provided User-Agent (the EmbedResolver) still wins. 102 let _uaVer = '1.0'; 103 try { _uaVer = JSON.parse(fs.readFileSync(new URL('../../package.json', import.meta.url))).version || _uaVer; } catch { /* keep default */ } 104 const KLONKT_UA = `Klonkt/${_uaVer} (+https://klonkt.com)`; 105 98 106 export async function safeFetch(url, opts = {}, maxRedirects = 3) { 99 107 let target = url; … … 102 110 if (u.protocol !== 'https:' && u.protocol !== 'http:') throw new Error('ssrf-bad-scheme'); 103 111 await assertPublicHost(u.hostname); 104 const r = await fetch(target, { ...opts, redirect: 'manual', signal: AbortSignal.timeout(8000) }); 112 const r = await fetch(target, { 113 ...opts, 114 headers: { 'User-Agent': KLONKT_UA, ...(opts.headers || {}) }, 115 redirect: 'manual', 116 signal: AbortSignal.timeout(8000), 117 }); 105 118 const loc = (r.status >= 300 && r.status < 400) ? r.headers.get('location') : null; 106 119 if (loc && hop < maxRedirects) { target = new URL(loc, target).toString(); continue; }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)