From 7b4ab36817c8dffade3781fa269bf8f88dde58b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 3 Jan 2019 23:13:25 +0100 Subject: [PATCH 1/9] gx: update go-ipfs-config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- cmd/ipfs/init.go | 2 +- cmd/ipfs/main.go | 2 +- cmd/ipfswatch/main.go | 2 +- commands/context.go | 2 +- core/bootstrap.go | 2 +- core/bootstrap_test.go | 2 +- core/builder.go | 2 +- core/commands/bootstrap.go | 2 +- core/commands/cmdenv/env.go | 2 +- core/commands/config.go | 2 +- core/commands/mount_unix.go | 2 +- core/commands/repo.go | 2 +- core/commands/swarm.go | 2 +- core/core.go | 2 +- core/core_test.go | 2 +- core/coreapi/test/api_test.go | 2 +- core/corehttp/commands.go | 2 +- core/corehttp/gateway_test.go | 2 +- core/coreunix/add_test.go | 2 +- core/mock/mock.go | 2 +- package.json | 8 ++++---- repo/fsrepo/config_test.go | 2 +- repo/fsrepo/fsrepo.go | 4 ++-- repo/fsrepo/fsrepo_test.go | 2 +- repo/fsrepo/misc.go | 2 +- repo/mock.go | 2 +- repo/repo.go | 2 +- test/bench/bench_cli_ipfs_add/main.go | 2 +- test/bench/offline_add/main.go | 2 +- test/dependencies/iptb/iptb.go | 2 +- 30 files changed, 34 insertions(+), 34 deletions(-) diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index d6a572bc3..7f11c5c12 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -16,9 +16,9 @@ import ( namesys "github.com/ipfs/go-ipfs/namesys" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" + "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" - "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go index 6b0cfbdfa..8ed78f076 100644 --- a/cmd/ipfs/main.go +++ b/cmd/ipfs/main.go @@ -25,12 +25,12 @@ import ( loggables "gx/ipfs/QmQSREHX6CMoPkT5FfuA4A9cWSFwoKY8RAzjf5m7Gpdtqu/go-libp2p-loggables" manet "gx/ipfs/QmQVUtnrNGtCRkCMpXgpApfzQjc8FDaDVxHqWH8cnZQeh5/go-multiaddr-net" ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" + "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" madns "gx/ipfs/QmT4zgnKCyZBpRyxzsvZqUjzUkMWLJ2pZCw7uk6M6Kto5m/go-multiaddr-dns" osh "gx/ipfs/QmXuBJ7DR6k3rmUEKtvVMhwjmXDuJgXXPUt4LQXKBMsU93/go-os-helper" "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds/cli" "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds/http" - "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" ) diff --git a/cmd/ipfswatch/main.go b/cmd/ipfswatch/main.go index cd1fad941..7be4f2d78 100644 --- a/cmd/ipfswatch/main.go +++ b/cmd/ipfswatch/main.go @@ -15,8 +15,8 @@ import ( coreunix "github.com/ipfs/go-ipfs/core/coreunix" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" process "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" homedir "gx/ipfs/QmdcULN1WCzgoQmcCaUAmEhwcxHYsDrbZ2LvRJKCL8dMrK/go-homedir" fsnotify "gx/ipfs/QmfNjggF4Pt6erqg3NDafD3MdvDHk1qqCVr8pL5hnPucS8/fsnotify" ) diff --git a/commands/context.go b/commands/context.go index 0f9d93f89..0ddbd91c2 100644 --- a/commands/context.go +++ b/commands/context.go @@ -11,8 +11,8 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" loader "github.com/ipfs/go-ipfs/plugin/loader" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" ) diff --git a/core/bootstrap.go b/core/bootstrap.go index ff0565549..f7b1afff5 100644 --- a/core/bootstrap.go +++ b/core/bootstrap.go @@ -13,12 +13,12 @@ import ( lgbl "gx/ipfs/QmQSREHX6CMoPkT5FfuA4A9cWSFwoKY8RAzjf5m7Gpdtqu/go-libp2p-loggables" inet "gx/ipfs/QmPtFaR7BWHLAjSwLh9kXcyrgTzDpuhcWLkx8ioa9RMYnx/go-libp2p-net" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" goprocess "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" procctx "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/context" periodicproc "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/periodic" peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" host "gx/ipfs/QmfD51tKgJiTMnW9JEiDiPwsCY4mqUoxkhKhBfyW12spTC/go-libp2p-host" ) diff --git a/core/bootstrap_test.go b/core/bootstrap_test.go index 58f356ed2..cd7d2d25c 100644 --- a/core/bootstrap_test.go +++ b/core/bootstrap_test.go @@ -5,8 +5,8 @@ import ( "testing" testutil "gx/ipfs/QmPuhRE325DR8ChNcFtgd6F1eANCHy1oohXZPpYop4xsK6/go-testutil" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" ) func TestSubsetWhenMaxIsGreaterThanLengthOfSlice(t *testing.T) { diff --git a/core/builder.go b/core/builder.go index 93abd3a13..07b97702a 100644 --- a/core/builder.go +++ b/core/builder.go @@ -20,6 +20,7 @@ import ( bserv "gx/ipfs/QmPoh3SrQzFBWtdGK6qmHDV4EanKR6kYPj4DD3J2NLoEmZ/go-blockservice" ipns "gx/ipfs/QmPrt2JqvtFcgMBmYBjtZ5jFzq6HoFXy8PTwLb2Dpm2cGf/go-ipns" libp2p "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p" + cfg "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" bstore "gx/ipfs/QmS2aqUZLJp8kF1ihE5rvDGE5LvmKDPnx32w9Z1BW9xLV5/go-ipfs-blockstore" goprocessctx "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/context" peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" @@ -28,7 +29,6 @@ import ( pstoremem "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore/pstoremem" resolver "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" - cfg "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" offroute "gx/ipfs/QmdmWkx54g7VfVyxeG8ic84uf4G6Eq1GohuyKA3XDuJ8oC/go-ipfs-routing/offline" metrics "gx/ipfs/QmekzFM3hPZjTjUFGTABdQkEnQ3PTiMstY198PwSFr5w1Q/go-metrics-interface" diff --git a/core/commands/bootstrap.go b/core/commands/bootstrap.go index 0cbe0fe9f..56acd2dec 100644 --- a/core/commands/bootstrap.go +++ b/core/commands/bootstrap.go @@ -9,8 +9,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/cmdenv/env.go b/core/commands/cmdenv/env.go index 15eaf8981..d0b3f4509 100644 --- a/core/commands/cmdenv/env.go +++ b/core/commands/cmdenv/env.go @@ -9,8 +9,8 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" ) diff --git a/core/commands/config.go b/core/commands/config.go index 4bf1028bd..248c13e69 100644 --- a/core/commands/config.go +++ b/core/commands/config.go @@ -15,8 +15,8 @@ import ( "github.com/ipfs/go-ipfs/repo/fsrepo" "gx/ipfs/QmP2i47tnU23ijdshrZtuvrSkQPtf9HhsMb9fwGVe8owj2/jsondiff" + "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" - "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/mount_unix.go b/core/commands/mount_unix.go index 734f41a5a..d6bfc492f 100644 --- a/core/commands/mount_unix.go +++ b/core/commands/mount_unix.go @@ -9,8 +9,8 @@ import ( cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" nodeMount "github.com/ipfs/go-ipfs/fuse/node" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/repo.go b/core/commands/repo.go index 51e358967..5f2bee460 100644 --- a/core/commands/repo.go +++ b/core/commands/repo.go @@ -17,9 +17,9 @@ import ( fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" bstore "gx/ipfs/QmS2aqUZLJp8kF1ihE5rvDGE5LvmKDPnx32w9Z1BW9xLV5/go-ipfs-blockstore" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/commands/swarm.go b/core/commands/swarm.go index 6001550af..13512b5df 100644 --- a/core/commands/swarm.go +++ b/core/commands/swarm.go @@ -15,12 +15,12 @@ import ( inet "gx/ipfs/QmPtFaR7BWHLAjSwLh9kXcyrgTzDpuhcWLkx8ioa9RMYnx/go-libp2p-net" swarm "gx/ipfs/QmQdLXW5JTSsrVb3ZpnpbASRwyM8CcE4XcM5nPbN19dWLr/go-libp2p-swarm" ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" mafilter "gx/ipfs/QmSMZwvs3n4GBikZ7hKzT17c3bk65FmyZo2JqtJ16swqCv/multiaddr-filter" iaddr "gx/ipfs/QmSzEdVLaPMQGAKKGo4mKjsbWcfz6w8CoDjhRPxdk7xYdn/go-ipfs-addr" peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) diff --git a/core/core.go b/core/core.go index 955896c71..1899e805c 100644 --- a/core/core.go +++ b/core/core.go @@ -45,6 +45,7 @@ import ( rhost "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/host/routed" identify "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/protocol/identify" ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" ifconnmgr "gx/ipfs/QmRkzmq686MdtAVHZLncm3sXCzyFzBq4eLxk2rch2r788f/go-libp2p-interface-connmgr" bstore "gx/ipfs/QmS2aqUZLJp8kF1ihE5rvDGE5LvmKDPnx32w9Z1BW9xLV5/go-ipfs-blockstore" goprocess "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" @@ -67,7 +68,6 @@ import ( metrics "gx/ipfs/QmbYN6UmTJn5UUQdi5CTsU86TXVBSrTcRk5UmyA36Qx2J6/go-libp2p-metrics" ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" autonat "gx/ipfs/QmdFdMoDmvuEJYsAKRA2BMobzNaeunmc16DqPxdHHfQ25K/go-libp2p-autonat-svc" merkledag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" diff --git a/core/core_test.go b/core/core_test.go index 9d5d9e5a6..b0c7c1f58 100644 --- a/core/core_test.go +++ b/core/core_test.go @@ -7,7 +7,7 @@ import ( "github.com/ipfs/go-ipfs/repo" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" ) diff --git a/core/coreapi/test/api_test.go b/core/coreapi/test/api_test.go index f44716b7e..d113e9f05 100644 --- a/core/coreapi/test/api_test.go +++ b/core/coreapi/test/api_test.go @@ -16,9 +16,9 @@ import ( ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/net/mock" + "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" - "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" ) diff --git a/core/corehttp/commands.go b/core/corehttp/commands.go index 99d3b3eff..5ccb31d98 100644 --- a/core/corehttp/commands.go +++ b/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds/http" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" ) var ( diff --git a/core/corehttp/gateway_test.go b/core/corehttp/gateway_test.go index 3aa82c9ce..162f70b8a 100644 --- a/core/corehttp/gateway_test.go +++ b/core/corehttp/gateway_test.go @@ -20,8 +20,8 @@ import ( ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" id "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/protocol/identify" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" diff --git a/core/coreunix/add_test.go b/core/coreunix/add_test.go index 270e8094a..d41ab23f8 100644 --- a/core/coreunix/add_test.go +++ b/core/coreunix/add_test.go @@ -19,10 +19,10 @@ import ( "gx/ipfs/QmPoh3SrQzFBWtdGK6qmHDV4EanKR6kYPj4DD3J2NLoEmZ/go-blockservice" pi "gx/ipfs/QmR6YMs8EkXQLXNwQKxLnQp2VBZSepoEJ8KCZAyanJHhJu/go-ipfs-posinfo" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" blockstore "gx/ipfs/QmS2aqUZLJp8kF1ihE5rvDGE5LvmKDPnx32w9Z1BW9xLV5/go-ipfs-blockstore" blocks "gx/ipfs/QmWoXtvgC8inqFkAATB7cp2Dax7XBi9VDvSg9RCCZufmRk/go-block-format" files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" diff --git a/core/mock/mock.go b/core/mock/mock.go index 870849564..03a2c0fad 100644 --- a/core/mock/mock.go +++ b/core/mock/mock.go @@ -10,9 +10,9 @@ import ( testutil "gx/ipfs/QmPuhRE325DR8ChNcFtgd6F1eANCHy1oohXZPpYop4xsK6/go-testutil" libp2p "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p" mocknet "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/net/mock" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" peer "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" pstore "gx/ipfs/QmZ9zH2FnLcxv1xyzFeUpDUeo55xEhZQHgveZijcxr7TLj/go-libp2p-peerstore" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" host "gx/ipfs/QmfD51tKgJiTMnW9JEiDiPwsCY4mqUoxkhKhBfyW12spTC/go-libp2p-host" diff --git a/package.json b/package.json index 432ba0108..5ba540adc 100644 --- a/package.json +++ b/package.json @@ -518,9 +518,9 @@ }, { "author": "magik6k", - "hash": "QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse", + "hash": "QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C", "name": "go-ipfs-config", - "version": "0.2.22" + "version": "0.2.23" }, { "author": "why", @@ -589,9 +589,9 @@ }, { "author": "travisperson", - "hash": "QmQLcRTxMtdUmmTse5uoqBLM5YZgjZP4qiCPynY6qEz6qA", + "hash": "QmcoFdD9yWySMu9HuyqFiwjztkRA59xS1E2B5LjhEt8iKr", "name": "iptb-plugins", - "version": "1.0.8" + "version": "1.0.9" }, { "author": "hsanjuan", diff --git a/repo/fsrepo/config_test.go b/repo/fsrepo/config_test.go index 28466fc31..20690860c 100644 --- a/repo/fsrepo/config_test.go +++ b/repo/fsrepo/config_test.go @@ -10,7 +10,7 @@ import ( "github.com/ipfs/go-ipfs/plugin/loader" "github.com/ipfs/go-ipfs/repo/fsrepo" - "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" + "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" ) // note: to test sorting of the mountpoints in the disk spec they are diff --git a/repo/fsrepo/fsrepo.go b/repo/fsrepo/fsrepo.go index 8b9d43846..20cc14d92 100644 --- a/repo/fsrepo/fsrepo.go +++ b/repo/fsrepo/fsrepo.go @@ -20,9 +20,9 @@ import ( util "gx/ipfs/QmNohiVssaPw3KVLZik59DBVGTSm2dGvYT9eoXt5DQ36Yz/go-ipfs-util" ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" + serialize "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config/serialize" lockfile "gx/ipfs/QmcWjZkQxyPMkgZRpda4hqWwaD6E1yqCvcxZfxbt98CEAK/go-fs-lock" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" - serialize "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config/serialize" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" measure "gx/ipfs/QmdCQgMgoMjur6D15ZB3z1LodiSP3L6EBHMyVx4ekqzRWA/go-ds-measure" homedir "gx/ipfs/QmdcULN1WCzgoQmcCaUAmEhwcxHYsDrbZ2LvRJKCL8dMrK/go-homedir" diff --git a/repo/fsrepo/fsrepo_test.go b/repo/fsrepo/fsrepo_test.go index df69630ff..6db88bc06 100644 --- a/repo/fsrepo/fsrepo_test.go +++ b/repo/fsrepo/fsrepo_test.go @@ -9,7 +9,7 @@ import ( "github.com/ipfs/go-ipfs/thirdparty/assert" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" ) diff --git a/repo/fsrepo/misc.go b/repo/fsrepo/misc.go index 21be949cd..a82f543d8 100644 --- a/repo/fsrepo/misc.go +++ b/repo/fsrepo/misc.go @@ -3,7 +3,7 @@ package fsrepo import ( "os" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" homedir "gx/ipfs/QmdcULN1WCzgoQmcCaUAmEhwcxHYsDrbZ2LvRJKCL8dMrK/go-homedir" ) diff --git a/repo/mock.go b/repo/mock.go index 9bbdbb01d..57fc310df 100644 --- a/repo/mock.go +++ b/repo/mock.go @@ -7,7 +7,7 @@ import ( keystore "github.com/ipfs/go-ipfs/keystore" ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" ) var errTODO = errors.New("TODO: mock repo") diff --git a/repo/repo.go b/repo/repo.go index 650b70ebc..8f6131a60 100644 --- a/repo/repo.go +++ b/repo/repo.go @@ -8,7 +8,7 @@ import ( keystore "github.com/ipfs/go-ipfs/keystore" ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" ds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" ) diff --git a/test/bench/bench_cli_ipfs_add/main.go b/test/bench/bench_cli_ipfs_add/main.go index e64367b7e..8f05271e0 100644 --- a/test/bench/bench_cli_ipfs_add/main.go +++ b/test/bench/bench_cli_ipfs_add/main.go @@ -12,8 +12,8 @@ import ( "github.com/ipfs/go-ipfs/thirdparty/unit" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" random "gx/ipfs/QmSJ9n2s9NUoA9D849W5jj5SJ94nMcZpj1jCgQJieiNqSt/go-random" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" ) var ( diff --git a/test/bench/offline_add/main.go b/test/bench/offline_add/main.go index 13a33bf6c..b80abb0ad 100644 --- a/test/bench/offline_add/main.go +++ b/test/bench/offline_add/main.go @@ -11,8 +11,8 @@ import ( "github.com/ipfs/go-ipfs/thirdparty/unit" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" random "gx/ipfs/QmSJ9n2s9NUoA9D849W5jj5SJ94nMcZpj1jCgQJieiNqSt/go-random" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" ) func main() { diff --git a/test/dependencies/iptb/iptb.go b/test/dependencies/iptb/iptb.go index fbbfb7e11..c5aa7085c 100644 --- a/test/dependencies/iptb/iptb.go +++ b/test/dependencies/iptb/iptb.go @@ -7,7 +7,7 @@ import ( cli "gx/ipfs/QmckeQ2zrYLAXoSHYTGn5BDdb22BqbUoHEHm8KZ9YWRxd1/iptb/cli" testbed "gx/ipfs/QmckeQ2zrYLAXoSHYTGn5BDdb22BqbUoHEHm8KZ9YWRxd1/iptb/testbed" - plugin "gx/ipfs/QmQLcRTxMtdUmmTse5uoqBLM5YZgjZP4qiCPynY6qEz6qA/iptb-plugins/local" + plugin "gx/ipfs/QmcoFdD9yWySMu9HuyqFiwjztkRA59xS1E2B5LjhEt8iKr/iptb-plugins/local" ) func init() { From aa5daed3cb0fe9a98f6ab0bba1a50eddfc6cc572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 26 Oct 2018 02:28:28 +0200 Subject: [PATCH 2/9] NoFetch gateway option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- core/corehttp/gateway.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/corehttp/gateway.go b/core/corehttp/gateway.go index 52560750a..de909a0ef 100644 --- a/core/corehttp/gateway.go +++ b/core/corehttp/gateway.go @@ -2,6 +2,7 @@ package corehttp import ( "fmt" + "github.com/ipfs/go-ipfs/core/coreapi/interface/options" "net" "net/http" @@ -25,7 +26,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { return nil, err } - api, err := coreapi.NewCoreAPI(n) + api, err := coreapi.NewCoreAPI(n, options.Api.Offline(cfg.Gateway.NoFetch)) if err != nil { return nil, err } From 041c46e75c35e2412cfb31518b10640dbc9e3dfe Mon Sep 17 00:00:00 2001 From: Iaroslav Gridin Date: Thu, 11 Oct 2018 11:54:17 +0300 Subject: [PATCH 3/9] Add tests for FetchBlocks gateway option License: MIT Signed-off-by: Iaroslav Gridin --- test/sharness/t0110-gateway.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/sharness/t0110-gateway.sh b/test/sharness/t0110-gateway.sh index 89901a22f..9b2f6430e 100755 --- a/test/sharness/t0110-gateway.sh +++ b/test/sharness/t0110-gateway.sh @@ -215,4 +215,36 @@ test_expect_success "GET compact blocks succeeds" ' test_kill_ipfs_daemon + +GWPORT=32563 + +test_expect_success "set up iptb testbed" ' + iptb testbed create -type localipfs -count 2 -force -init && + ipfsi 0 config Addresses.Gateway /ip4/127.0.0.1/tcp/$GWPORT +' + +test_expect_success "set NoFetch to true in config of node 0" ' + ipfsi 0 config --bool=true Gateway.NoFetch true +' + +test_expect_success "start ipfs nodes" ' + iptb start -wait && + iptb connect 0 1 +' + +test_expect_success "try fetching not present key from node 0" ' + echo "hi" | ipfsi 1 add -Q > hi.hash && + test_expect_code 22 curl -f "http://127.0.0.1:$GWPORT/ipfs/$(cat hi.hash)" +' + +test_expect_success "try fetching present key from from node 0" ' + echo "hi" | ipfsi 0 add -Q > hi.hash && + PORT1=$(ipfs config Addresses.Gateway | cut -d/ -f 5) && + curl -f "http://127.0.0.1:$GWPORT/ipfs/$(cat hi.hash)" +' + +test_expect_success "stop testbed" ' + iptb stop +' + test_done From 6cee21d39a2f76ea75d487e35230c801c5eff25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 4 Jan 2019 02:35:40 +0100 Subject: [PATCH 4/9] Fix offline gateway directory logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- core/coreapi/coreapi.go | 3 +- core/coreapi/interface/path.go | 9 +++-- core/coreapi/interface/tests/path.go | 12 +++++++ core/coreapi/unixfile.go | 7 +++- core/corehttp/gateway.go | 2 +- core/corehttp/gateway_handler.go | 49 +++++++++++++--------------- test/sharness/t0110-gateway.sh | 8 ++--- 7 files changed, 53 insertions(+), 37 deletions(-) diff --git a/core/coreapi/coreapi.go b/core/coreapi/coreapi.go index d5f6a7a3f..bea2f05ad 100644 --- a/core/coreapi/coreapi.go +++ b/core/coreapi/coreapi.go @@ -212,9 +212,8 @@ func (api *CoreAPI) WithOptions(opts ...options.ApiOption) (coreiface.CoreAPI, e subApi.recordValidator = nil subApi.exchange = offlinexch.Exchange(subApi.blockstore) - subApi.blocks = bserv.New(api.blockstore, subApi.exchange) + subApi.blocks = bserv.New(subApi.blockstore, subApi.exchange) subApi.dag = dag.NewDAGService(subApi.blocks) - } return subApi, nil diff --git a/core/coreapi/interface/path.go b/core/coreapi/interface/path.go index 01dda97d5..96f30852d 100644 --- a/core/coreapi/interface/path.go +++ b/core/coreapi/interface/path.go @@ -1,9 +1,8 @@ package iface import ( + "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipfspath "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - - cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ) //TODO: merge with ipfspath so we don't depend on it @@ -106,6 +105,12 @@ type resolvedPath struct { remainder string } +// Join appends provided segments to the base path +func Join(base Path, a ...string) Path { + s := ipfspath.Join(append([]string{base.String()}, a...)) + return &path{path: ipfspath.FromString(s)} +} + // IpfsPath creates new /ipfs path from the provided CID func IpfsPath(c cid.Cid) ResolvedPath { return &resolvedPath{ diff --git a/core/coreapi/interface/tests/path.go b/core/coreapi/interface/tests/path.go index e74053c04..7057d6286 100644 --- a/core/coreapi/interface/tests/path.go +++ b/core/coreapi/interface/tests/path.go @@ -15,6 +15,7 @@ func (tp *provider) TestPath(t *testing.T) { t.Run("TestEmptyPathRemainder", tp.TestEmptyPathRemainder) t.Run("TestInvalidPathRemainder", tp.TestInvalidPathRemainder) t.Run("TestPathRoot", tp.TestPathRoot) + t.Run("TestPathJoin", tp.TestPathJoin) } func (tp *provider) TestMutablePath(t *testing.T) { @@ -165,3 +166,14 @@ func (tp *provider) TestPathRoot(t *testing.T) { t.Error("unexpected path cid") } } + +func (tp *provider) TestPathJoin(t *testing.T) { + p1, err := coreiface.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz") + if err != nil { + t.Error(err) + } + + if coreiface.Join(p1, "foo").String() != "/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz/foo" { + t.Error("unexpected path") + } +} diff --git a/core/coreapi/unixfile.go b/core/coreapi/unixfile.go index 7e4f1782b..4ddeb771a 100644 --- a/core/coreapi/unixfile.go +++ b/core/coreapi/unixfile.go @@ -119,7 +119,12 @@ func (d *ufsDirectory) Entries() files.DirIterator { } func (d *ufsDirectory) Size() (int64, error) { - return 0, files.ErrNotSupported + n, err := d.dir.GetNode() + if err != nil { + return 0, err + } + s, err := n.Size() + return int64(s), err } type ufsFile struct { diff --git a/core/corehttp/gateway.go b/core/corehttp/gateway.go index de909a0ef..105f24361 100644 --- a/core/corehttp/gateway.go +++ b/core/corehttp/gateway.go @@ -2,13 +2,13 @@ package corehttp import ( "fmt" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" "net" "net/http" version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" + options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" id "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/protocol/identify" ) diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index 553ebdcf8..e80a9fa45 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -7,7 +7,6 @@ import ( "io" "net/http" "net/url" - "os" gopath "path" "runtime/debug" "strings" @@ -26,7 +25,6 @@ import ( "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer" - uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" @@ -254,22 +252,14 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } i.serveFile(w, r, name, modtime, f) return - } - - nd, err := i.api.ResolveNode(ctx, resolvedPath) - if err != nil { - internalWebError(w, err) + dir, ok := dr.(files.Directory) + if !ok { + internalWebError(w, fmt.Errorf("unsupported file type")) return } - dirr, err := uio.NewDirectoryFromNode(i.node.DAG, nd) - if err != nil { - internalWebError(w, err) - return - } - - ixnd, err := dirr.Find(ctx, "index.html") + idx, err := i.api.Unixfs().Get(ctx, coreiface.Join(resolvedPath, "index.html")) switch { case err == nil: dirwithoutslash := urlPath[len(urlPath)-1] != '/' @@ -280,14 +270,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - dr, err := i.api.Unixfs().Get(ctx, coreiface.IpfsPath(ixnd.Cid())) - if err != nil { - internalWebError(w, err) - return - } - defer dr.Close() - - f, ok := dr.(files.File) + f, ok := idx.(files.File) if !ok { internalWebError(w, files.ErrNotReader) return @@ -297,9 +280,11 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr http.ServeContent(w, r, "index.html", modtime, f) return default: + if _, ok := err.(resolver.ErrNoLink); ok { + break + } internalWebError(w, err) return - case os.IsNotExist(err): } if r.Method == "HEAD" { @@ -308,12 +293,22 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // storage for directory listing var dirListing []directoryItem - dirr.ForEachLink(ctx, func(link *ipld.Link) error { + dirit := dir.Entries() + for dirit.Next() { // See comment above where originalUrlPath is declared. - di := directoryItem{humanize.Bytes(link.Size), link.Name, gopath.Join(originalUrlPath, link.Name)} + s, err := dirit.Node().Size() + if err != nil { + internalWebError(w, err) + return + } + + di := directoryItem{humanize.Bytes(uint64(s)), dirit.Name(), gopath.Join(originalUrlPath, dirit.Name())} dirListing = append(dirListing, di) - return nil - }) + } + if dirit.Err() != nil { + internalWebError(w, dirit.Err()) + return + } // construct the correct back link // https://github.com/ipfs/go-ipfs/issues/1365 diff --git a/test/sharness/t0110-gateway.sh b/test/sharness/t0110-gateway.sh index 9b2f6430e..26686ccc4 100755 --- a/test/sharness/t0110-gateway.sh +++ b/test/sharness/t0110-gateway.sh @@ -233,14 +233,14 @@ test_expect_success "start ipfs nodes" ' ' test_expect_success "try fetching not present key from node 0" ' - echo "hi" | ipfsi 1 add -Q > hi.hash && - test_expect_code 22 curl -f "http://127.0.0.1:$GWPORT/ipfs/$(cat hi.hash)" + echo "foo" | ipfsi 1 add -Q > foo.hash && + test_expect_code 22 curl -f "http://127.0.0.1:$GWPORT/ipfs/$(cat foo.hash)" ' test_expect_success "try fetching present key from from node 0" ' - echo "hi" | ipfsi 0 add -Q > hi.hash && + echo "bar" | ipfsi 0 add -Q > bar.hash && PORT1=$(ipfs config Addresses.Gateway | cut -d/ -f 5) && - curl -f "http://127.0.0.1:$GWPORT/ipfs/$(cat hi.hash)" + curl -f "http://127.0.0.1:$GWPORT/ipfs/$(cat bar.hash)" ' test_expect_success "stop testbed" ' From 7efffc3579b5ca100d29e68c9b39bfaac65b0152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 4 Jan 2019 03:06:23 +0100 Subject: [PATCH 5/9] Make Gateway.NoFetch apply to API too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- cmd/ipfs/daemon.go | 5 ++++- commands/context.go | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index e4c891053..88da7ff96 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -560,13 +560,16 @@ func serveHTTPGateway(req *cmds.Request, cctx *oldcmds.Context) (<-chan error, e listeners = append(listeners, gwLis) } + cmdctx := *cctx + cmdctx.Gateway = true + var opts = []corehttp.ServeOption{ corehttp.MetricsCollectionOption("gateway"), corehttp.IPNSHostnameOption(), corehttp.GatewayOption(writable, "/ipfs", "/ipns"), corehttp.VersionOption(), corehttp.CheckVersionOption(), - corehttp.CommandsROOption(*cctx), + corehttp.CommandsROOption(cmdctx), } if cfg.Experimental.P2pHttpProxy { diff --git a/commands/context.go b/commands/context.go index 0ddbd91c2..3934a4c79 100644 --- a/commands/context.go +++ b/commands/context.go @@ -9,6 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" + options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" loader "github.com/ipfs/go-ipfs/plugin/loader" config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" @@ -29,6 +30,7 @@ type Context struct { config *config.Config LoadConfig func(path string) (*config.Config, error) + Gateway bool api coreiface.CoreAPI node *core.IpfsNode ConstructNode func() (*core.IpfsNode, error) @@ -68,7 +70,16 @@ func (c *Context) GetAPI() (coreiface.CoreAPI, error) { if err != nil { return nil, err } - c.api, err = coreapi.NewCoreAPI(n) + offline := false + if c.Gateway { + cfg, err := c.GetConfig() + if err != nil { + return nil, err + } + offline = cfg.Gateway.NoFetch + } + + c.api, err = coreapi.NewCoreAPI(n, options.Api.Offline(offline)) if err != nil { return nil, err } From 2c28ef19ae9850dc4ed903f0210245b07426baa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 4 Jan 2019 15:40:15 +0100 Subject: [PATCH 6/9] coreapi: FetchBlocks option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- core/coreapi/coreapi.go | 2 ++ core/coreapi/interface/options/global.go | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/core/coreapi/coreapi.go b/core/coreapi/coreapi.go index bea2f05ad..11a798d97 100644 --- a/core/coreapi/coreapi.go +++ b/core/coreapi/coreapi.go @@ -210,7 +210,9 @@ func (api *CoreAPI) WithOptions(opts ...options.ApiOption) (coreiface.CoreAPI, e subApi.peerstore = nil subApi.peerHost = nil subApi.recordValidator = nil + } + if settings.Offline || !settings.FetchBlocks { subApi.exchange = offlinexch.Exchange(subApi.blockstore) subApi.blocks = bserv.New(subApi.blockstore, subApi.exchange) subApi.dag = dag.NewDAGService(subApi.blocks) diff --git a/core/coreapi/interface/options/global.go b/core/coreapi/interface/options/global.go index 93d635e41..90e2586f1 100644 --- a/core/coreapi/interface/options/global.go +++ b/core/coreapi/interface/options/global.go @@ -1,14 +1,16 @@ package options type ApiSettings struct { - Offline bool + Offline bool + FetchBlocks bool } type ApiOption func(*ApiSettings) error func ApiOptions(opts ...ApiOption) (*ApiSettings, error) { options := &ApiSettings{ - Offline: false, + Offline: false, + FetchBlocks: true, } return ApiOptionsTo(options, opts...) @@ -34,3 +36,12 @@ func (apiOpts) Offline(offline bool) ApiOption { return nil } } + +// FetchBlocks when set to false prevents api from fetching blocks from the +// network while allowing other services such as IPNS to still be online +func (apiOpts) FetchBlocks(fetch bool) ApiOption { + return func(settings *ApiSettings) error { + settings.FetchBlocks = fetch + return nil + } +} From fea7b5da79287f243f004706d629e6bb552f2c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 4 Jan 2019 15:50:48 +0100 Subject: [PATCH 7/9] gateway: NoFetch ipns test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- test/sharness/t0110-gateway.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/test/sharness/t0110-gateway.sh b/test/sharness/t0110-gateway.sh index 26686ccc4..4078a4794 100755 --- a/test/sharness/t0110-gateway.sh +++ b/test/sharness/t0110-gateway.sh @@ -219,8 +219,9 @@ test_kill_ipfs_daemon GWPORT=32563 test_expect_success "set up iptb testbed" ' - iptb testbed create -type localipfs -count 2 -force -init && - ipfsi 0 config Addresses.Gateway /ip4/127.0.0.1/tcp/$GWPORT + iptb testbed create -type localipfs -count 5 -force -init && + ipfsi 0 config Addresses.Gateway /ip4/127.0.0.1/tcp/$GWPORT && + PEERID_1=$(iptb attr get 1 id) ' test_expect_success "set NoFetch to true in config of node 0" ' @@ -233,14 +234,23 @@ test_expect_success "start ipfs nodes" ' ' test_expect_success "try fetching not present key from node 0" ' - echo "foo" | ipfsi 1 add -Q > foo.hash && - test_expect_code 22 curl -f "http://127.0.0.1:$GWPORT/ipfs/$(cat foo.hash)" + FOO=$(echo "foo" | ipfsi 1 add -Q) && + test_expect_code 22 curl -f "http://127.0.0.1:$GWPORT/ipfs/$FOO" +' + +test_expect_success "try fetching not present ipns key from node 0" ' + ipfsi 1 name publish /ipfs/$FOO && + test_expect_code 22 curl -f "http://127.0.0.1:$GWPORT/ipns/$PEERID_1" ' test_expect_success "try fetching present key from from node 0" ' - echo "bar" | ipfsi 0 add -Q > bar.hash && - PORT1=$(ipfs config Addresses.Gateway | cut -d/ -f 5) && - curl -f "http://127.0.0.1:$GWPORT/ipfs/$(cat bar.hash)" + BAR=$(ipfsi 0 add -Q > bar.hash) && + curl -f "http://127.0.0.1:$GWPORT/ipfs/$BAR" +' + +test_expect_success "try fetching present ipns key from node 0" ' + ipfsi 1 name publish /ipfs/$BAR && + test_expect_code 22 curl -f "http://127.0.0.1:$GWPORT/ipns/$PEERID_1" ' test_expect_success "stop testbed" ' From c9168ecf058af53adcb5712f3706af0a534df381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 4 Jan 2019 15:56:08 +0100 Subject: [PATCH 8/9] gateway: use Api.FetchBlocks for NoFetch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- commands/context.go | 6 +++--- core/corehttp/gateway.go | 2 +- test/sharness/t0110-gateway.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/commands/context.go b/commands/context.go index 3934a4c79..fd498a9d1 100644 --- a/commands/context.go +++ b/commands/context.go @@ -70,16 +70,16 @@ func (c *Context) GetAPI() (coreiface.CoreAPI, error) { if err != nil { return nil, err } - offline := false + fetchBlocks := true if c.Gateway { cfg, err := c.GetConfig() if err != nil { return nil, err } - offline = cfg.Gateway.NoFetch + fetchBlocks = !cfg.Gateway.NoFetch } - c.api, err = coreapi.NewCoreAPI(n, options.Api.Offline(offline)) + c.api, err = coreapi.NewCoreAPI(n, options.Api.FetchBlocks(fetchBlocks)) if err != nil { return nil, err } diff --git a/core/corehttp/gateway.go b/core/corehttp/gateway.go index 105f24361..6aad23786 100644 --- a/core/corehttp/gateway.go +++ b/core/corehttp/gateway.go @@ -26,7 +26,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { return nil, err } - api, err := coreapi.NewCoreAPI(n, options.Api.Offline(cfg.Gateway.NoFetch)) + api, err := coreapi.NewCoreAPI(n, options.Api.FetchBlocks(!cfg.Gateway.NoFetch)) if err != nil { return nil, err } diff --git a/test/sharness/t0110-gateway.sh b/test/sharness/t0110-gateway.sh index 4078a4794..51cae3a27 100755 --- a/test/sharness/t0110-gateway.sh +++ b/test/sharness/t0110-gateway.sh @@ -244,13 +244,13 @@ test_expect_success "try fetching not present ipns key from node 0" ' ' test_expect_success "try fetching present key from from node 0" ' - BAR=$(ipfsi 0 add -Q > bar.hash) && + BAR=$(echo "bar" | ipfsi 0 add -Q) && curl -f "http://127.0.0.1:$GWPORT/ipfs/$BAR" ' test_expect_success "try fetching present ipns key from node 0" ' ipfsi 1 name publish /ipfs/$BAR && - test_expect_code 22 curl -f "http://127.0.0.1:$GWPORT/ipns/$PEERID_1" + curl "http://127.0.0.1:$GWPORT/ipns/$PEERID_1" ' test_expect_success "stop testbed" ' From 818e0e40c7163bea0f3f171028a895f6e181aebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 5 Jan 2019 22:29:46 +0100 Subject: [PATCH 9/9] gateway: cleanup err switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera --- core/corehttp/gateway_handler.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index e80a9fa45..0e1e7e0af 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -260,8 +260,8 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } idx, err := i.api.Unixfs().Get(ctx, coreiface.Join(resolvedPath, "index.html")) - switch { - case err == nil: + switch err.(type) { + case nil: dirwithoutslash := urlPath[len(urlPath)-1] != '/' goget := r.URL.Query().Get("go-get") == "1" if dirwithoutslash && !goget { @@ -279,10 +279,9 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // write to request http.ServeContent(w, r, "index.html", modtime, f) return + case resolver.ErrNoLink: + // no index.html; noop default: - if _, ok := err.(resolver.ErrNoLink); ok { - break - } internalWebError(w, err) return }