brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.84k stars 2.33k forks source link

Adjust logic for IPFS redirections #21505

Closed spylogsster closed 2 months ago

spylogsster commented 2 years ago

There are 2 options and we need to prioritise rules between each other

  1. Redirect IPFS resources to the configured IPFS gateway
  2. Automatically redirect to IPFS pages via DNSLink when possible

If (1) is enabled, we detect /ipfs/{cid} in URL, confirm {cid} is a real CID, and if so, redirect that to ipfs://{cid} (local node) or https://dweb.link/ipfs/{cid} (gateway). If (2) is enabled, we either do DNSLink lookup for every domain name (only if server returned 5xx error codes), or only if x-ipfs-path is present. If we confirm DNSLink is present (we only care about its presence, not its value), then we redirect to ipns://{example.com} (local node) or https://dweb.link/ipns/{example.com}(gateway), and IPFS node will resolve DNSLink and load the correct data internally.

Test cases:

spylogsster commented 2 years ago

related issue https://github.com/brave/brave-browser/issues/21454

stephendonner commented 2 years ago

cc @MadhaviSeelam

vadimstruts commented 2 months ago

The IPFS local node and scheme has been deprecated