Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

IPFS rebase to v0.4.18 #1425

Merged
merged 34 commits into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d7b3cb1
First pass IPFS rebase to v0.4.18
cpacia Jan 24, 2019
1e6ea35
Remove resolve config loading from mobile package
cpacia Jan 24, 2019
eb7c8be
Add back libsecp256k1 lib
cpacia Jan 24, 2019
41943e8
Fix routing type assertion in message retreiver
cpacia Jan 24, 2019
200e74c
Remove dumplicate enum descriptors from go-libp2p-kad-dht
cpacia Jan 24, 2019
d41e263
Update go-onion-transport with new constructor
cpacia Jan 24, 2019
b842da2
Add libsecp256k1 back
cpacia Jan 24, 2019
3c9bc64
Fix indentity key configuration
cpacia Jan 25, 2019
e1e3331
Refactor IPFS pointer package to use IpfsDHT rather than the IpfsNode
cpacia Jan 25, 2019
c2ad5aa
Patch go-multiaddr dependency to handle CID in /ipfs/ field
cpacia Jan 25, 2019
7d17eb5
Patch secio package handle old style hashed ed25519 keys
cpacia Jan 25, 2019
cc5c139
Update DHT package to signal bootstrap complete
cpacia Jan 29, 2019
9aa8e6d
Fix compatibility bugs in ipfs library
cpacia Jan 30, 2019
e72c46f
Patch go-multiaddr to handle backwards compatible cids
cpacia Feb 4, 2019
d41059e
Patch multiaddr codec to handle alternative serializations
cpacia Feb 4, 2019
6710f07
Move identity set to after fsrepo.Init
cpacia Feb 4, 2019
ddaa673
Add migration018
cpacia Feb 4, 2019
0bc8157
Wire up dht quorum and fallback API config values
cpacia Feb 4, 2019
25a9591
Fix lint
cpacia Feb 4, 2019
1b5528d
Add github.com/google/uuid to vendor
cpacia Feb 4, 2019
81d2470
Update jsonapi test data with new hash format
cpacia Feb 5, 2019
a431c4e
Update ipfs add function to also pin
cpacia Feb 5, 2019
409e652
Update hash format in migration and storage tests
cpacia Feb 5, 2019
7a83231
Gofmt project
cpacia Feb 5, 2019
4f3d6e2
Update QA test package with new bootstrap process
cpacia Feb 5, 2019
3ce3377
Handle json marshalling error in Migration018
cpacia Feb 8, 2019
f181a99
Add test for ipns path transform
cpacia Feb 8, 2019
4bc3728
Move cleanIdentityFromConfig to schema and add test
cpacia Feb 8, 2019
b7b287e
Fix typo in gateway url
cpacia Feb 19, 2019
07f029f
Fix bugs in tor transport
cpacia Feb 19, 2019
1094881
Add blockingStartupMiddleware to select endpoints
cpacia Feb 20, 2019
f8d2231
Merge branch 'master' into ipfsrebase
cpacia Feb 20, 2019
53396e8
Set DHT in test node and close bootstrapchan
cpacia Feb 20, 2019
b527ba5
Add CID compatibility test
cpacia Feb 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2,268 changes: 1,217 additions & 1,051 deletions Godeps/Godeps.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ func get(i *jsonAPIHandler, path string, w http.ResponseWriter, r *http.Request)
i.GETHealthCheck(w, r)
case strings.HasPrefix(path, "/wallet/status"):
i.GETWalletStatus(w, r)
case strings.HasPrefix(path, "/ob/resolve"):
i.GETResolve(w, r)
case strings.HasPrefix(path, "/ob/ipns"):
i.GETIPNS(w, r)
case strings.HasPrefix(path, "/ob/peerinfo"):
Expand Down
123 changes: 37 additions & 86 deletions api/jsonapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
routing "gx/ipfs/QmRaVcGchmC1stHHK7YhcgEuTk5k1JiGS568pfYWMgT91H/go-libp2p-kad-dht"
dshelp "gx/ipfs/QmTmqJGRQfuH8eKWD1FjThwPRipt1QhqJQNZ8MpzmfAAxo/go-ipfs-ds-help"
ps "gx/ipfs/QmXauCuJzmzapetmC6W4TuDJLL1yFFrVzSHoWv8YdbmnxH/go-libp2p-peerstore"
peer "gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
"gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid"
mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash"
routing "gx/ipfs/QmPpYHPRGVpSJTkQDQDwTYZ1cYUR2NM4HS6M3iAXi8aoUa/go-libp2p-kad-dht"
"gx/ipfs/QmTRhk7cgjUf2gfQ3p2M9KPECNZEW9XUrmHcFCgog4cPgB/go-libp2p-peer"
ps "gx/ipfs/QmTTJcDL3gsnGDALjh2fDGg1onGRUdVgNL2hU2WEZcVrMX/go-libp2p-peerstore"
"gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore"
"io/ioutil"
"net/http"
"net/http/httputil"
Expand All @@ -27,6 +27,12 @@ import (
"sync"
"time"

"github.com/ipfs/go-ipfs/core/coreapi"
"github.com/ipfs/go-ipfs/core/coreapi/interface"
"github.com/ipfs/go-ipfs/namesys"

ipnspath "gx/ipfs/QmT3rzed1ppXefourpmoZ7tyVQfsGPQZ1pHDngLmCvXxd3/go-path"

"github.com/OpenBazaar/jsonpb"
"github.com/OpenBazaar/openbazaar-go/core"
"github.com/OpenBazaar/openbazaar-go/ipfs"
Expand All @@ -39,10 +45,7 @@ import (
"github.com/btcsuite/btcutil/base58"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/ipfs/go-ipfs/core/coreunix"
ipnspb "github.com/ipfs/go-ipfs/namesys/pb"
ipnspath "github.com/ipfs/go-ipfs/path"
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
"github.com/ipfs/go-ipfs/repo/fsrepo"
)

type JSONAPIConfig struct {
Expand Down Expand Up @@ -1074,12 +1077,6 @@ func (i *jsonAPIHandler) GETFollowers(w http.ResponseWriter, r *http.Request) {
}
SanitizedResponse(w, string(ret))
} else {
pid, err := i.node.NameSystem.Resolve(context.Background(), peerID)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
return
}
peerID = pid.Pretty()
followBytes, err := i.node.IPNSResolveThenCat(ipnspath.FromString(path.Join(peerID, "followers.json")), time.Minute, useCache)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
Expand Down Expand Up @@ -1133,12 +1130,6 @@ func (i *jsonAPIHandler) GETFollowing(w http.ResponseWriter, r *http.Request) {
}
SanitizedResponse(w, string(ret))
} else {
pid, err := i.node.NameSystem.Resolve(context.Background(), peerID)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
return
}
peerID = pid.Pretty()
followBytes, err := i.node.IPNSResolveThenCat(ipnspath.FromString(path.Join(peerID, "following.json")), time.Minute, useCache)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
Expand Down Expand Up @@ -1350,12 +1341,6 @@ func (i *jsonAPIHandler) GETListings(w http.ResponseWriter, r *http.Request) {
}
SanitizedResponse(w, string(listingsBytes))
} else {
pid, err := i.node.NameSystem.Resolve(context.Background(), peerID)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
return
}
peerID = pid.Pretty()
listingsBytes, err := i.node.IPNSResolveThenCat(ipnspath.FromString(path.Join(peerID, "listings.json")), time.Minute, useCache)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
Expand Down Expand Up @@ -1441,12 +1426,6 @@ func (i *jsonAPIHandler) GETListing(w http.ResponseWriter, r *http.Request) {
hash = listingID
w.Header().Set("Cache-Control", "public, max-age=29030400, immutable")
} else {
pid, err := i.node.NameSystem.Resolve(context.Background(), peerID)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
return
}
peerID = pid.Pretty()
listingBytes, err = i.node.IPNSResolveThenCat(ipnspath.FromString(path.Join(peerID, "listings", listingID+".json")), time.Minute, useCache)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
Expand Down Expand Up @@ -1491,12 +1470,6 @@ func (i *jsonAPIHandler) GETProfile(w http.ResponseWriter, r *http.Request) {
return
}
} else {
pid, err := i.node.NameSystem.Resolve(context.Background(), peerID)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
return
}
peerID = pid.Pretty()
profile, err = i.node.FetchProfile(peerID, useCache)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
Expand Down Expand Up @@ -2615,11 +2588,20 @@ func (i *jsonAPIHandler) GETImage(w http.ResponseWriter, r *http.Request) {
_, imageHash := path.Split(r.URL.Path)
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*2)
defer cancel()
dr, err := coreunix.Cat(ctx, i.node.IpfsNode, "/ipfs/"+imageHash)

api := coreapi.NewCoreAPI(i.node.IpfsNode)
pth, err := iface.ParsePath("/ipfs/" + imageHash)
if err != nil {
ErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}

dr, err := api.Unixfs().Get(ctx, pth)
if err != nil {
ErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}

defer dr.Close()
w.Header().Set("Cache-Control", "public, max-age=29030400, immutable")
w.Header().Del("Content-Type")
Expand Down Expand Up @@ -3099,7 +3081,7 @@ func (i *jsonAPIHandler) POSTBlockNode(w http.ResponseWriter, r *http.Request) {
nodes = append(nodes, pid)
}
}
go ipfs.RemoveAll(i.node.IpfsNode, peerID)
go ipfs.RemoveAll(i.node.IpfsNode, peerID, i.node.IPNSQuorumSize)
nodes = append(nodes, peerID)
settings.BlockedNodes = &nodes
if err := i.node.Datastore.Settings().Put(settings); err != nil {
Expand Down Expand Up @@ -3686,38 +3668,30 @@ func (i *jsonAPIHandler) GETWalletStatus(w http.ResponseWriter, r *http.Request)
SanitizedResponse(w, string(out))
}

func (i *jsonAPIHandler) GETResolve(w http.ResponseWriter, r *http.Request) {
_, name := path.Split(r.URL.Path)
pid, err := i.node.NameSystem.Resolve(context.Background(), name)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
return
}
fmt.Fprint(w, pid.Pretty())
}

func (i *jsonAPIHandler) GETIPNS(w http.ResponseWriter, r *http.Request) {
_, peerID := path.Split(r.URL.Path)

val, err := i.node.IpfsNode.Repo.Datastore().Get(dshelp.NewKeyFromBinary([]byte("/ipns/" + peerID)))
if err != nil { // No record in datastore
ErrorResponse(w, http.StatusNotFound, err.Error())
return
}
pid, err := peer.IDB58Decode(peerID)
if err != nil {
ErrorResponse(w, http.StatusBadRequest, err.Error())
return
}

val, err := i.node.IpfsNode.Repo.Datastore().Get(namesys.IpnsDsKey(pid))
if err != nil { // No record in datastore
ErrorResponse(w, http.StatusNotFound, err.Error())
return
}

var keyBytes []byte
pubkey := i.node.IpfsNode.Peerstore.PubKey(pid)
if pubkey == nil || !pid.MatchesPublicKey(pubkey) {
keyval, err := i.node.IpfsNode.Repo.Datastore().Get(dshelp.NewKeyFromBinary([]byte(core.KeyCachePrefix + peerID)))
keyval, err := i.node.IpfsNode.Repo.Datastore().Get(datastore.NewKey(core.KeyCachePrefix + peerID))
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
return
}
keyBytes = keyval.([]byte)
keyBytes = keyval
} else {
keyBytes, err = pubkey.Bytes()
if err != nil {
Expand All @@ -3727,28 +3701,17 @@ func (i *jsonAPIHandler) GETIPNS(w http.ResponseWriter, r *http.Request) {
}

type KeyAndRecord struct {
Pubkey string `json:"pubkey"`
SerializedRecord string `json:"serializedRecord"`
Pubkey string `json:"pubkey"`
Record string `json:"record"`
}

entry := new(ipnspb.IpnsEntry)
err = proto.Unmarshal(val.([]byte), entry)
if err != nil {
ErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
b, err := proto.Marshal(entry)
if err != nil {
ErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
ret := KeyAndRecord{hex.EncodeToString(keyBytes), hex.EncodeToString(b)}
ret := KeyAndRecord{hex.EncodeToString(keyBytes), string(val)}
retBytes, err := json.MarshalIndent(ret, "", " ")
if err != nil {
ErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
go ipfs.Resolve(i.node.IpfsNode, pid, time.Minute, false)
go ipfs.Resolve(i.node.IpfsNode, pid, time.Minute, i.node.IPNSQuorumSize, false)
fmt.Fprint(w, string(retBytes))
}

Expand Down Expand Up @@ -3979,12 +3942,6 @@ func (i *jsonAPIHandler) GETPosts(w http.ResponseWriter, r *http.Request) {
}
SanitizedResponse(w, string(postsBytes))
} else {
pid, err := i.node.NameSystem.Resolve(context.Background(), peerID)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
return
}
peerID = pid.Pretty()
postsBytes, err := i.node.IPNSResolveThenCat(ipnspath.FromString(path.Join(peerID, "posts.json")), time.Minute, useCache)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
Expand Down Expand Up @@ -4051,12 +4008,6 @@ func (i *jsonAPIHandler) GETPost(w http.ResponseWriter, r *http.Request) {
hash = postID
w.Header().Set("Cache-Control", "public, max-age=29030400, immutable")
} else {
pid, err := i.node.NameSystem.Resolve(context.Background(), peerID)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
return
}
peerID = pid.Pretty()
postBytes, err = i.node.IPNSResolveThenCat(ipnspath.FromString(path.Join(peerID, "posts", postID+".json")), time.Minute, useCache)
if err != nil {
ErrorResponse(w, http.StatusNotFound, err.Error())
Expand Down
30 changes: 15 additions & 15 deletions api/jsonapi_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ const avatarValidJSON = `{
}`

const avatarValidJSONResponse = `{
"large": "zb2rhbEB183zRmazfsY7ytQWfyPEQUuLy3Ryso4h8jkwSxQY6",
"medium": "zb2rhhf3ZxHrUyb43sQ2ivQTJvWUPgTyF5T2h4fM8xLxmtHuU",
"original": "zb2rhmfTQq3yixcKnEy5q68ujAayJLP3KsxjAR5gMocFcRQy5",
"small": "zb2rhY2W79RCbZDM87t9pVL4CHicYjQxmVih3q7u7QRDc5xqP",
"tiny": "zb2rhbrsSgjXymYSGqH6pvma72g6WRmx69sbCsc5ANCbVMAJs"
"large": "QmcUNDbsazULoEddnRSsiK1LgUCx6FnujgUG6r17GEviq2",
"medium": "Qmdj2NnzQwGuHN7RZmMhu1VEeLP7APDzFE5KmBKsPxZmuH",
"original": "QmYGE9UNEMvQ8W1qcVAMkJTYLpjNu1JHQtwqvppJ2QXiJe",
"small": "Qmf198F1mX2hhFJKkWUepxLh3vC853Xr79VQuhJFuBizZD",
"tiny": "QmPxXHGMm5J3y2G4S9brxe83CxLgt6D3MZKhxMBkNyKQWn"
}`

const avatarUnexpectedEOFJSON = `{
Expand Down Expand Up @@ -261,11 +261,11 @@ const imageValidJSON = `[{
const imageValidJSONResponse = `[{
"filename": "blue_tshirt.jpg",
"hashes": {
"large": "zb2rhkProdDprVM9jGYwyN1sGTrTVQXebAup6oLLpQfcC9WsK",
"medium": "zb2rhZqKFguaaEodgYKHUUmvDVWeFpF2eWMNgvhxrdoKYjUKw",
"original": "zb2rhcuzHEovhfy4u2mvGkghj5FyEHZKu1fkzMB8t7MXo7fru",
"small": "zb2rhgKxh4gLKrqoVYmE3gzJve61PVwHP277rSQh4jyL4ftrK",
"tiny": "zb2rhnmhLobuoHHpbXoz3YE2aaptRvxMg4DCUY62MVr56ooUL"
"large": "Qmcy4pW7cv18RMCprxrxhiihQzUJNaCNr5v2qvZGjGAwsj",
"medium": "QmVGiFSwTkMPjvGnnreHkspb9Ui2upkctYtqMR5sBKncHR",
"original": "QmQ2QdYMLCPWuVpdAvj49Kf7FvbpPrN4bdborHGb3G9jQv",
"small": "QmUBvfRXHYmzNx6uke5USD3C5PgWr5Wa3XHzcK3zaTeytS",
"tiny": "QmNi2H4MUkLe9eBEPmyE9QVQ6Y3F1RwpPxB4B1us5HnxwG"
}
}]`

Expand All @@ -275,11 +275,11 @@ const headerValidJSON = `{
}`

const headerValidJSONResponse = `{
"large": "zb2rhmowivBcCAR9XQFm8yTYiescwZjzYqJzyiqsVuQwEpYFr",
"medium": "zb2rhhwb8anfu1GmJrD1yZcqp6AmxHA3h4yfNr1RdV8gqci5y",
"original": "zb2rhmfTQq3yixcKnEy5q68ujAayJLP3KsxjAR5gMocFcRQy5",
"small": "zb2rhXFSGMLsi5sSmVb5rrTx7E9biwycYzYVpAAbAkk7pypB5",
"tiny": "zb2rhbQwzGdgYeiqy213dqrFJkDruvid3EVVFUgkWn6samyCA"
"large": "QmSqNf7gM4LKMsqej8b4q2su14TButMZduF5FJRodttbTZ",
"medium": "QmZqF47LXvKvKh5YyCerkEAiS4EmVubACeoQTQKXzU79WV",
"original": "QmYGE9UNEMvQ8W1qcVAMkJTYLpjNu1JHQtwqvppJ2QXiJe",
"small": "QmQHHKV7cBFFE4WDJN9Vojxc3U14dt4dK5ihgtxwphdQij",
"tiny": "QmRheKdYREcdSHBdamY3ejZxh89UmnnjRQcqPPxAoQxn9X"
}`

//
Expand Down
6 changes: 3 additions & 3 deletions api/jsonapi_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bytes"
"encoding/json"
"fmt"
manet "gx/ipfs/QmRK2LxanhK2gZq6k6R7vk5ZoYZk8ULSSTB7FzDsMUX6CB/go-multiaddr-net"
ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr"
ma "gx/ipfs/QmT4U94DnD8FRfqr21obWY32HLM5VExccPKMjQHofeYqr9/go-multiaddr"
manet "gx/ipfs/Qmaabb1tJZ2CX5cp6MuuiGgns71NYoxdgQP6Xdid1dVceC/go-multiaddr-net"
"io/ioutil"
"net/http"
"os"
Expand Down Expand Up @@ -54,7 +54,7 @@ func newTestGateway() (*Gateway, error) {
return nil, err
}

return NewGateway(node, *test.GetAuthCookie(), listener.NetListener(), *apiConfig, logging.NewLogBackend(os.Stdout, "", 0))
return NewGateway(node, *test.GetAuthCookie(), manet.NetListener(listener), *apiConfig, logging.NewLogBackend(os.Stdout, "", 0))
}

// apiTest is a test case to be run against the api blackbox
Expand Down
3 changes: 1 addition & 2 deletions cmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ func (x *Convert) Execute(args []string) error {
ExtraOpts: map[string]bool{
"mplex": true,
},
DNSResolver: nil,
Routing: nil,
Routing: nil,
}

nd, err := ipfscore.NewNode(cctx, ncfg)
Expand Down
Loading