From 926635137e326bfeb9c603913330090b6e8b8178 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 24 Jan 2018 15:55:28 -0800 Subject: [PATCH 1/5] gx: mass update License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@fe8846fcd75bb576f2302973cb4110f73450b937 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/corehttp.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 8 ++++---- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 9dfdfe70a..108792cc7 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmUEB5nT4LG3TkUd5mkHrfRESUSgaUD4r7jSAYvvPeuWT9/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmUEB5nT4LG3TkUd5mkHrfRESUSgaUD4r7jSAYvvPeuWT9/go-ipfs-cmds/http" + cmds "gx/ipfs/Qmc5paX4ECBARnAKkcAmUYHBGor228Tkfxeya3Nu2KRL46/go-ipfs-cmds" + cmdsHttp "gx/ipfs/Qmc5paX4ECBARnAKkcAmUYHBGor228Tkfxeya3Nu2KRL46/go-ipfs-cmds/http" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 2686ca675..dd5ea2a7b 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,10 +11,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + manet "gx/ipfs/QmRK2LxanhK2gZq6k6R7vk5ZoYZk8ULSSTB7FzDsMUX6CB/go-multiaddr-net" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" - manet "gx/ipfs/QmSGL5Uoa6gKHgBBwQG8u1CWKUC8ZnwaZiLgFVTFBR2bxr/go-multiaddr-net" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" - ma "gx/ipfs/QmW8s4zTsUoX1Q6CeYxVKPyqSKbF7H1YDUyTostBtZ8DaG/go-multiaddr" + ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 54fcd3e9b..14d3be7ff 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/Qma23bpHwQrQyvKeBemaeJh7sAoRHggPkgnge1B9489ff5/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmNRN4eZGmY89CRC4T5PC4xDYRx6GkDKEfRnvrT65fVeio/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index bf164f9cb..f4f99cfeb 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -23,11 +23,11 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" - node "gx/ipfs/QmNwUEK7QbwSqyKBu3mMtToo8SUc6wQJ7gdZq4gGGJqfnf/go-ipld-format" - routing "gx/ipfs/QmPCGUjMRuBcPybZFpjhzpifwPP9wPRoiy5geTQKU4vqWA/go-libp2p-routing" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - multibase "gx/ipfs/QmafgXF3u3QSWErQoZ2URmQp5PFG384htoE7J338nS2H7T/go-multibase" - cid "gx/ipfs/QmeSrf6pzut73u6zLQkRFQ3ygt3k6XFT2kjdYP8Tnkwwyg/go-cid" + routing "gx/ipfs/QmRijoA6zGS98ELTDbGsLWPZbVotYsGbjp3RbXcKCYBeon/go-libp2p-routing" + cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid" + node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" + multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 97a2bbe64..32c03a886 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - id "gx/ipfs/Qma23bpHwQrQyvKeBemaeJh7sAoRHggPkgnge1B9489ff5/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmNRN4eZGmY89CRC4T5PC4xDYRx6GkDKEfRnvrT65fVeio/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 3c452d5fa..4401b460c 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - inet "gx/ipfs/QmU4vCDZTPLDqSDKguWbHCiUe46mZUtmM2g2suBZ9NE8ko/go-libp2p-net" - testutil "gx/ipfs/QmZTcPxK6VqrwY94JpKZPvEqAZ6tEr1rLrpcqJbbRZbg2V/go-libp2p-netutil" - bhost "gx/ipfs/Qma23bpHwQrQyvKeBemaeJh7sAoRHggPkgnge1B9489ff5/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmNRN4eZGmY89CRC4T5PC4xDYRx6GkDKEfRnvrT65fVeio/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmQm7WmgYCa4RSz76tKEYpRjApjnRw8ZTUVQC15b8JM4a2/go-libp2p-net" + testutil "gx/ipfs/QmV1axkk86DDkYwS269AvPy9eV5h7mUyHveJkSVHPjrQtY/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 9fa584c4e1b777c0d06755d0696008c600bb306e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 25 Jan 2018 14:32:40 -0800 Subject: [PATCH 2/5] fix tests that use invalid peer IDs Our code now better validates peer IDs. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@8899e986703ad4f597c637564e2d59d3c2bb8645 --- gateway/core/corehttp/gateway_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 32c03a886..6b396812e 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -55,7 +55,7 @@ func (m mockNamesys) GetResolver(subs string) (namesys.Resolver, bool) { func newNodeWithMockNamesys(ns mockNamesys) (*core.IpfsNode, error) { c := config.Config{ Identity: config.Identity{ - PeerID: "Qmfoo", // required by offline node + PeerID: "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe", // required by offline node }, } r := &repo.Mock{ From 4dc49feb97ffa844b65a9633c570afe9e3245a6e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 25 Jan 2018 12:21:51 -0800 Subject: [PATCH 3/5] merkledag: switch to new dag interface Also: * Update the blockstore/blockservice methods to match. * Construct a new temporary offline dag instead of having a GetOfflineLinkService method. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@d154b4a990d14126227b68d21274191046a186b5 --- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 16 +++++++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f4f99cfeb..1dbc8f4f2 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -474,7 +474,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } - nnode, err := e.Finalize(i.node.DAG) + nnode, err := e.Finalize(ctx, i.node.DAG) if err != nil { webError(w, "putHandler: could not get node", err, http.StatusInternalServerError) return @@ -498,11 +498,11 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { // object set-data case pbnd.SetData(pbnewnode.Data()) - newcid, err = i.node.DAG.Add(pbnd) + newcid = pbnd.Cid() + err = i.node.DAG.Add(ctx, pbnd) if err != nil { nnk := newnode.Cid() - rk := pbnd.Cid() - webError(w, fmt.Sprintf("putHandler: Could not add newnode(%q) to root(%q)", nnk.String(), rk.String()), err, http.StatusInternalServerError) + webError(w, fmt.Sprintf("putHandler: Could not add newnode(%q) to root(%q)", nnk.String(), newcid.String()), err, http.StatusInternalServerError) return } default: @@ -561,7 +561,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { var newnode *dag.ProtoNode = pbnd for j := len(pathNodes) - 2; j >= 0; j-- { - if _, err := i.node.DAG.Add(newnode); err != nil { + if err := i.node.DAG.Add(ctx, newnode); err != nil { webError(w, "Could not add node", err, http.StatusInternalServerError) return } @@ -579,7 +579,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { } } - if _, err := i.node.DAG.Add(newnode); err != nil { + if err := i.node.DAG.Add(ctx, newnode); err != nil { webError(w, "Could not add root node", err, http.StatusInternalServerError) return } diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 6b396812e..ca03dcca5 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -178,6 +178,9 @@ func TestGatewayGet(t *testing.T) { } func TestIPNSHostnameRedirect(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + ns := mockNamesys{} ts, n := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) @@ -199,12 +202,12 @@ func TestIPNSHostnameRedirect(t *testing.T) { t.Fatal(err) } - _, err = n.DAG.Add(dagn2) + err = n.DAG.Add(ctx, dagn2) if err != nil { t.Fatal(err) } - _, err = n.DAG.Add(dagn1) + err = n.DAG.Add(ctx, dagn1) if err != nil { t.Fatal(err) } @@ -262,6 +265,9 @@ func TestIPNSHostnameRedirect(t *testing.T) { } func TestIPNSHostnameBacklinks(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + ns := mockNamesys{} ts, n := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) @@ -286,15 +292,15 @@ func TestIPNSHostnameBacklinks(t *testing.T) { t.Fatal(err) } - _, err = n.DAG.Add(dagn3) + err = n.DAG.Add(ctx, dagn3) if err != nil { t.Fatal(err) } - _, err = n.DAG.Add(dagn2) + err = n.DAG.Add(ctx, dagn2) if err != nil { t.Fatal(err) } - _, err = n.DAG.Add(dagn1) + err = n.DAG.Add(ctx, dagn1) if err != nil { t.Fatal(err) } From c9f254f6b29d7f3415b0036a4c00488168b5647b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 27 Jan 2018 18:03:59 -0800 Subject: [PATCH 4/5] update go-lib2p-loggables fixes a UUID bug I introduced (UUIDs were always an error value) License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@5acbecc26b53cddbe74484b2fdf4f55212fa9687 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 108792cc7..e555970df 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/Qmc5paX4ECBARnAKkcAmUYHBGor228Tkfxeya3Nu2KRL46/go-ipfs-cmds" - cmdsHttp "gx/ipfs/Qmc5paX4ECBARnAKkcAmUYHBGor228Tkfxeya3Nu2KRL46/go-ipfs-cmds/http" + cmds "gx/ipfs/QmPq2D7Yoyev7yeMuMnkEYBqmQuUu5kb91UXPPoiik1Xyp/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmPq2D7Yoyev7yeMuMnkEYBqmQuUu5kb91UXPPoiik1Xyp/go-ipfs-cmds/http" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 14d3be7ff..ecd5876bd 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmNRN4eZGmY89CRC4T5PC4xDYRx6GkDKEfRnvrT65fVeio/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmPd5qhppUqewTQMfStvNNCFtcxiWGsnE6Vs3va6788gsX/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index ca03dcca5..f03219264 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - id "gx/ipfs/QmNRN4eZGmY89CRC4T5PC4xDYRx6GkDKEfRnvrT65fVeio/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmPd5qhppUqewTQMfStvNNCFtcxiWGsnE6Vs3va6788gsX/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 4401b460c..1c04ecaf8 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmNRN4eZGmY89CRC4T5PC4xDYRx6GkDKEfRnvrT65fVeio/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmPd5qhppUqewTQMfStvNNCFtcxiWGsnE6Vs3va6788gsX/go-libp2p/p2p/host/basic" inet "gx/ipfs/QmQm7WmgYCa4RSz76tKEYpRjApjnRw8ZTUVQC15b8JM4a2/go-libp2p-net" - testutil "gx/ipfs/QmV1axkk86DDkYwS269AvPy9eV5h7mUyHveJkSVHPjrQtY/go-libp2p-netutil" + testutil "gx/ipfs/QmWUugnJBbcuin8qdfiCYKAsNkG8NeDLhzoBqRaqXhAHd4/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From a2bc6aeb49266bdddefa6ce67be6f36d116c0ad2 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 29 Jan 2018 11:55:34 -0800 Subject: [PATCH 5/5] rename import of go-ipld-format from node/format to ipld License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@f9d935b9841ec061e8e10fb9c3aac5b7917720cd --- gateway/core/corehttp/gateway_handler.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1dbc8f4f2..aedcac227 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -26,7 +26,7 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" routing "gx/ipfs/QmRijoA6zGS98ELTDbGsLWPZbVotYsGbjp3RbXcKCYBeon/go-libp2p-routing" cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid" - node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" + ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" ) @@ -53,7 +53,7 @@ func newGatewayHandler(n *core.IpfsNode, c GatewayConfig, api coreiface.CoreAPI) } // TODO(cryptix): find these helpers somewhere else -func (i *gatewayHandler) newDagFromReader(r io.Reader) (node.Node, error) { +func (i *gatewayHandler) newDagFromReader(r io.Reader) (ipld.Node, error) { // TODO(cryptix): change and remove this helper once PR1136 is merged // return ufs.AddFromReader(i.node, r.Body) return importer.BuildDagFromReader( @@ -316,7 +316,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // storage for directory listing var dirListing []directoryItem - dirr.ForEachLink(ctx, func(link *node.Link) error { + dirr.ForEachLink(ctx, func(link *ipld.Link) error { // See comment above where originalUrlPath is declared. di := directoryItem{humanize.Bytes(link.Size), link.Name, gopath.Join(originalUrlPath, link.Name)} dirListing = append(dirListing, di) @@ -425,7 +425,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } - var newnode node.Node + var newnode ipld.Node if rsegs[len(rsegs)-1] == "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" { newnode = ft.EmptyDirNode() } else {