Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPFS Gateway #198

Merged
merged 5 commits into from
May 11, 2020
Merged

IPFS Gateway #198

merged 5 commits into from
May 11, 2020

Conversation

sanderpick
Copy link
Member

@sanderpick sanderpick commented May 9, 2020

Closes #145

  • Handles /ipfs, /ipns, /p2p, /ipld namespaces in the gateway
  • These namespaces are redirected to their respective subdomains, using some logic copied from go-ipfs
  • Updates go-ipfs to v0.5.1, which includes a fix for the hard-coded max timeout when publishing

Signed-off-by: Sander Pick <sanderpick@gmail.com>
Signed-off-by: Sander Pick <sanderpick@gmail.com>
Signed-off-by: Sander Pick <sanderpick@gmail.com>
@sanderpick sanderpick self-assigned this May 9, 2020
@@ -0,0 +1,271 @@
package gateway
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the gateway bucket stuff was moved here.

@@ -0,0 +1,211 @@
package gateway
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the IPFS related gateway stuff is here.

// if object turns out to be a valid CID,
// ensure text representation used in subdomain is CIDv1 in Base32
// https://github.com/ipfs/in-web-browsers/issues/89
rootID, err = cid.NewCidV1(multicodec, rootCid.Hash()).StringOfBase(mbase.Base32)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old style cids are case-sensitive. So, they get converted to base32.

// We ease the transition by fixing multicodec on the fly:
// https://github.com/ipfs/go-ipfs/issues/5287#issuecomment-492163929
if isPeerIDNamespace(ns) && multicodec != cid.Libp2pKey {
multicodec = cid.Libp2pKey
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we have these key type cids. Everything is a cid now.

@@ -1,6 +1,6 @@
{{template "header" "Bucket"}}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This template is now used for normal IPFS dirs and bucket dirs.

@@ -0,0 +1,82 @@
package gateway
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing new here, just moving this thread gateway stuff to its own file.

m.ctxsLock.Lock()
m.ctxs[keyID] = cancel
m.ctxsLock.Unlock()
if err := m.publishUnsafe(pctx, pth, keyID); err != nil {
if !errors.Is(err, context.Canceled) {
// Logging as a warning because this often fails with "context deadline exceeded",
// even if the entry can be found on the network (not fully saturated).
// The publish deadline seems to be fixed at one minute. ¯\_(ツ)_/¯
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They fixed it: ipfs/kubo#7256. Now we can use a longer timeout since these are just spinning on their own anyway.

@sanderpick sanderpick changed the title Sander/ipfs gateway IPFS Gateway May 9, 2020
Signed-off-by: Sander Pick <sanderpick@gmail.com>
Signed-off-by: Sander Pick <sanderpick@gmail.com>
Copy link
Contributor

@jsign jsign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sanderpick sanderpick merged commit 35fe877 into master May 11, 2020
@sanderpick sanderpick deleted the sander/ipfs-gateway branch May 11, 2020 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support ipfs/ipns hashes on the gateway
2 participants