jes / hardbin

Encrypted pastebin using IPFS
252 stars 30 forks source link

Subdomain gateway support #9

Open didnt1able opened 4 years ago

didnt1able commented 4 years ago

When accessing via a subdomain gateway it is unable to resolve

ipfs resolve -r /ipfs/bafybeidu5fa3wnoj6ixuluw6h5otbnsicgwbma7xhnao7zs3wpcn3nj7te/ipfs/bafybeiczbt5m3sox6r7drnzhg5dln33vffy372b42x2v7pmchncqrbbxxu: no link named "ipfs" under bafybeidu5fa3wnoj6ixuluw6h5otbnsicgwbma7xhnao7zs3wpcn3nj7te

Could change the hash replace to <cid>.ipfs.localhost:8080/#<decryption_key>-firstview

jes commented 4 years ago

Thanks, I haven't actually looked at IPFS in a long time.

From what you've said, in principle I agree. We'd want to detect if it's a subdomain gateway (How? Do we just check if the domain looks like ipfs.$foo? What about ipfs.io or other public non-subdomain gateways? Or are they subdomain gateways now too? Maybe we just check for a cid at the start of the domain?), and if it looks like it's a subdomain gateway, then do what you said.

It's unlikely I'll implement this but I'd merge a sensible pull request.

didnt1able commented 4 years ago

Could check with a regexp

^(http|https)://+(b[^.]{42,}\.ipfs\.+)

Im going to do some research on how to implement something like this