Skip to content

Commit

Permalink
Merge pull request #604 from libp2p/fix/disable-values-option
Browse files Browse the repository at this point in the history
Disallow GetPublicKey when DisableValues is passed
  • Loading branch information
Stebalien authored Sep 15, 2021
2 parents 7a8aeb6 + d5d5a9e commit d76b88a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 10 additions & 10 deletions dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ import (
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
"github.com/libp2p/go-libp2p-core/routing"
ma "github.com/multiformats/go-multiaddr"
"github.com/multiformats/go-multihash"
"github.com/multiformats/go-multistream"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

test "github.com/libp2p/go-libp2p-kad-dht/internal/testing"
pb "github.com/libp2p/go-libp2p-kad-dht/pb"
kb "github.com/libp2p/go-libp2p-kbucket"
record "github.com/libp2p/go-libp2p-record"
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"

"github.com/ipfs/go-cid"
detectrace "github.com/ipfs/go-detect-race"
u "github.com/ipfs/go-ipfs-util"
ma "github.com/multiformats/go-multiaddr"
"github.com/multiformats/go-multihash"
"github.com/multiformats/go-multistream"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
kb "github.com/libp2p/go-libp2p-kbucket"
record "github.com/libp2p/go-libp2p-record"
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
)

var testCaseCids []cid.Cid
Expand Down
4 changes: 4 additions & 0 deletions records.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type pubkrs struct {
// GetPublicKey gets the public key when given a Peer ID. It will extract from
// the Peer ID if inlined or ask the node it belongs to or ask the DHT.
func (dht *IpfsDHT) GetPublicKey(ctx context.Context, p peer.ID) (ci.PubKey, error) {
if !dht.enableValues {
return nil, routing.ErrNotSupported
}

logger.Debugf("getPublicKey for: %s", p)

// Check locally. Will also try to extract the public key from the peer
Expand Down

0 comments on commit d76b88a

Please sign in to comment.