diff --git a/src/lib/get-verified-fetch.ts b/src/lib/get-verified-fetch.ts index aa1550b0..08df9984 100644 --- a/src/lib/get-verified-fetch.ts +++ b/src/lib/get-verified-fetch.ts @@ -68,8 +68,11 @@ export async function getVerifiedFetch (config: ConfigDb, logger: ComponentLogge } else { config.routers.forEach((router) => { routers.push(delegatedHTTPRouting(router, { + // NOTE: in practice 'transport-ipfs-gateway-http' exists only in IPNI results, we won't have any DHT results like this unless.. + // TODO: someguy starts doing active probing (https://github.com/ipfs/someguy/issues/53) to identify peers which have functional HTTP gateway filterProtocols: ['transport-ipfs-gateway-http'], - filterAddrs: ['https'] + // Include both /https && /tls/../http + filterAddrs: ['https', 'tls'] })) }) @@ -83,24 +86,28 @@ export async function getVerifiedFetch (config: ConfigDb, logger: ComponentLogge return createVerifiedFetch(helia, { contentTypeParser }) } -type Libp2pDefaultsOptions = Pick +type Libp2pDefaultsOptions = Pick export async function libp2pDefaults (config: Libp2pDefaultsOptions): Promise { const agentVersion = `@helia/verified-fetch ${libp2pInfo.name}/${libp2pInfo.version} UserAgent=${globalThis.navigator.userAgent}` const privateKey = await generateKeyPair('Ed25519') - const filterAddrs = ['https'] - + const filterAddrs = [] as string[] const transports: Array<(components: any) => any> = [] if (config.enableWss) { transports.push(webSockets()) - filterAddrs.push('wss') + filterAddrs.push('wss') // /dns4/sv15.bootstrap.libp2p.io/tcp/443/wss/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJ + filterAddrs.push('tls') // /ip4/A.B.C.D/tcp/4002/tls/sni/A-B-C-D.peerid.libp2p.direct/ws/p2p/peerid } if (config.enableWebTransport) { transports.push(webTransport()) filterAddrs.push('webtransport') } + if (config.enableGatewayProviders) { + filterAddrs.push('https') // /dns/example.com/tcp/443/https + filterAddrs.push('tls') // /ip4/A.B.C.D/tcp/4002/tls/sni/example.com/http + } const libp2pOptions = { privateKey,