ipfs / dir-index-html

Directory listing HTML for go-ipfs gateways

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Broken CID column on DNSLink gateway

lidel opened this issue · comments

There is a problem when directory listing happens on DNSLink gateway (website under own domain name, backed by go-ipfs+DNSLink)

How to reproduce

To illustrate, if I render HTML like this (with go-ipfs 0.7.0):

$ curl -H "Host: dist.ipfs.io" -sD - "http://127.0.0.1:8080/go-ipfs/v0.7.0"

The breadcrumbs are broken:

          Index of
          /ipns/<a href="/ipns/dist.ipfs.io">dist.ipfs.io</a>/<a href="/ipns/dist.ipfs.io/go-ipfs">go-ipfs</a>/<a href="/ipns/dist.ipfs.io/go-ipfs/v0.7.0">v0.7.0</a>

Links under filenames are ok, but direct links to CID under truncated CIDs are broken:

        <td>
          <a href="/go-ipfs/v0.7.0/go-ipfs_v0.7.0_windows-amd64.zip.sha512">go-ipfs_v0.7.0_windows-amd64.zip.sha512</a>
        </td>
        <td class="no-linebreak">
          
          <a class="ipfs-hash" href="/ipfs/QmZwRgWU2St6St7bQi1uAh2j6EQHEJsTxuY7igVDi3dY1h">
            QmZw…dY1h
          </a>

This is because the /ipfs/... gateway is not mounted under DNSLink hostnames.
That is why attempt to load content path will fail:

$ curl -H "Host: dist.ipfs.io" -sD - "http://127.0.0.1:8080/ipfs/QmZwRgWU2St6St7bQi1uAh2j6EQHEJsTxuY7igVDi3dY1h"
HTTP/1.1 404 Not Found

TLDR

Good news is that the main link under filename continue to work, what is broken is this newly added CID column Its broken on DNSLink websites such as https://dist.ipfs.io/go-ipfs/v0.7.0 (when loaded without redirect to local gateway).

How to fix

  • Quick&dirty fix is to hide CID colum and disable links to /ipfs and /ipns when used on DNSLink gateway (path being /ipns/{Host} where Host match value from the header of the same name)
  • A proper fix require additional analysis
    • It should be possible to make breadcrumbs functional
    • ... but I don't think we can fix CID colum in DNSLink mod: we don't have knowledge if there is a public gateway available at all, and probably don't want to hardcode links to ipfs.io.
      • 💔 perhaps it should remain hidden in that mode?
      • 💚 or, to keep UI the same everywhere, when /ipfs/<cid> is not available, link to https://cid.ipfs.io#<cid> instead
  • sidenote: while working on this disable IPFS Companion to ensure you are looking at DNSlink gateway (context of this bug), and not the subdomain gateway at *.ipns.localhost (no bug in subdomain contexts)