Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-kad-dht
Commits
9b3d1b56
Commit
9b3d1b56
authored
Sep 03, 2016
by
George Antoniadis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bump deps, revert protobuf
parent
30d43d22
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
49 additions
and
86 deletions
+49
-86
dht.go
dht.go
+7
-6
dht_net.go
dht_net.go
+3
-2
ext_test.go
ext_test.go
+3
-2
handlers.go
handlers.go
+3
-2
package.json
package.json
+22
-27
pb/dht.pb.go
pb/dht.pb.go
+7
-42
pb/message.go
pb/message.go
+1
-2
records.go
records.go
+3
-3
No files found.
dht.go
View file @
9b3d1b56
...
...
@@ -22,6 +22,7 @@ import (
providers
"github.com/libp2p/go-libp2p-kad-dht/providers"
kb
"github.com/libp2p/go-libp2p-kbucket"
record
"github.com/libp2p/go-libp2p-record"
recpb
"github.com/libp2p/go-libp2p-record/pb"
routing
"github.com/libp2p/go-libp2p-routing"
host
"github.com/libp2p/go-libp2p/p2p/host"
protocol
"github.com/libp2p/go-libp2p/p2p/protocol"
...
...
@@ -102,7 +103,7 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.Batching) *IpfsDHT {
// putValueToPeer stores the given key/value pair at the peer 'p'
func
(
dht
*
IpfsDHT
)
putValueToPeer
(
ctx
context
.
Context
,
p
peer
.
ID
,
key
key
.
Key
,
rec
*
pb
.
Record
)
error
{
key
key
.
Key
,
rec
*
rec
pb
.
Record
)
error
{
pmes
:=
pb
.
NewMessage
(
pb
.
Message_PUT_VALUE
,
string
(
key
),
0
)
pmes
.
Record
=
rec
...
...
@@ -134,7 +135,7 @@ var errInvalidRecord = errors.New("received invalid record")
// NOTE: It will update the dht's peerstore with any new addresses
// it finds for the given peer.
func
(
dht
*
IpfsDHT
)
getValueOrPeers
(
ctx
context
.
Context
,
p
peer
.
ID
,
key
key
.
Key
)
(
*
pb
.
Record
,
[]
pstore
.
PeerInfo
,
error
)
{
key
key
.
Key
)
(
*
rec
pb
.
Record
,
[]
pstore
.
PeerInfo
,
error
)
{
pmes
,
err
:=
dht
.
getValueSingle
(
ctx
,
p
,
key
)
if
err
!=
nil
{
...
...
@@ -154,7 +155,7 @@ func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.ID,
log
.
Info
(
"Received invalid record! (discarded)"
)
// return a sentinal to signify an invalid record was received
err
=
errInvalidRecord
record
=
new
(
pb
.
Record
)
record
=
new
(
rec
pb
.
Record
)
}
return
record
,
peers
,
err
}
...
...
@@ -187,7 +188,7 @@ func (dht *IpfsDHT) getValueSingle(ctx context.Context, p peer.ID,
}
// getLocal attempts to retrieve the value from the datastore
func
(
dht
*
IpfsDHT
)
getLocal
(
key
key
.
Key
)
(
*
pb
.
Record
,
error
)
{
func
(
dht
*
IpfsDHT
)
getLocal
(
key
key
.
Key
)
(
*
rec
pb
.
Record
,
error
)
{
log
.
Debug
(
"getLocal %s"
,
key
)
v
,
err
:=
dht
.
datastore
.
Get
(
key
.
DsKey
())
...
...
@@ -200,7 +201,7 @@ func (dht *IpfsDHT) getLocal(key key.Key) (*pb.Record, error) {
if
!
ok
{
return
nil
,
errors
.
New
(
"value stored in datastore not []byte"
)
}
rec
:=
new
(
pb
.
Record
)
rec
:=
new
(
rec
pb
.
Record
)
err
=
proto
.
Unmarshal
(
byt
,
rec
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -227,7 +228,7 @@ func (dht *IpfsDHT) getOwnPrivateKey() (ci.PrivKey, error) {
}
// putLocal stores the key value pair in the datastore
func
(
dht
*
IpfsDHT
)
putLocal
(
key
key
.
Key
,
rec
*
pb
.
Record
)
error
{
func
(
dht
*
IpfsDHT
)
putLocal
(
key
key
.
Key
,
rec
*
rec
pb
.
Record
)
error
{
data
,
err
:=
proto
.
Marshal
(
rec
)
if
err
!=
nil
{
return
err
...
...
dht_net.go
View file @
9b3d1b56
...
...
@@ -8,9 +8,10 @@ import (
ggio
"github.com/gogo/protobuf/io"
peer
"github.com/ipfs/go-libp2p-peer"
ctxio
"github.com/jbenet/go-context/io"
pb
"github.com/libp2p/go-libp2p-kad-dht/pb"
inet
"github.com/libp2p/go-libp2p/p2p/net"
context
"golang.org/x/net/context"
pb
"github.com/libp2p/go-libp2p-kad-dht/pb"
)
var
dhtReadMessageTimeout
=
time
.
Minute
...
...
@@ -141,7 +142,7 @@ func (ms *messageSender) prep() error {
return
nil
}
nstr
,
err
:=
ms
.
dht
.
host
.
NewStream
(
ms
.
dht
.
ctx
,
ProtocolDHT
,
ms
.
p
)
nstr
,
err
:=
ms
.
dht
.
host
.
NewStream
(
ms
.
dht
.
ctx
,
ms
.
p
,
ProtocolDHT
)
if
err
!=
nil
{
return
err
}
...
...
ext_test.go
View file @
9b3d1b56
...
...
@@ -12,12 +12,13 @@ import (
u
"github.com/ipfs/go-ipfs-util"
key
"github.com/ipfs/go-key"
pstore
"github.com/ipfs/go-libp2p-peerstore"
pb
"github.com/libp2p/go-libp2p-kad-dht/pb"
record
"github.com/libp2p/go-libp2p-record"
routing
"github.com/libp2p/go-libp2p-routing"
inet
"github.com/libp2p/go-libp2p/p2p/net"
mocknet
"github.com/libp2p/go-libp2p/p2p/net/mock"
context
"golang.org/x/net/context"
pb
"github.com/libp2p/go-libp2p-kad-dht/pb"
)
func
TestGetFailures
(
t
*
testing
.
T
)
{
...
...
@@ -117,7 +118,7 @@ func TestGetFailures(t *testing.T) {
Record
:
rec
,
}
s
,
err
:=
hosts
[
1
]
.
NewStream
(
context
.
Background
(),
ProtocolDHT
,
hosts
[
0
]
.
ID
())
s
,
err
:=
hosts
[
1
]
.
NewStream
(
context
.
Background
(),
hosts
[
0
]
.
ID
()
,
ProtocolDHT
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
handlers.go
View file @
9b3d1b56
...
...
@@ -13,6 +13,7 @@ import (
peer
"github.com/ipfs/go-libp2p-peer"
pstore
"github.com/ipfs/go-libp2p-peerstore"
pb
"github.com/libp2p/go-libp2p-kad-dht/pb"
recpb
"github.com/libp2p/go-libp2p-record/pb"
context
"golang.org/x/net/context"
)
...
...
@@ -81,7 +82,7 @@ func (dht *IpfsDHT) handleGetValue(ctx context.Context, p peer.ID, pmes *pb.Mess
return
resp
,
nil
}
func
(
dht
*
IpfsDHT
)
checkLocalDatastore
(
k
key
.
Key
)
(
*
pb
.
Record
,
error
)
{
func
(
dht
*
IpfsDHT
)
checkLocalDatastore
(
k
key
.
Key
)
(
*
rec
pb
.
Record
,
error
)
{
log
.
Debugf
(
"%s handleGetValue looking into ds"
,
dht
.
self
)
dskey
:=
k
.
DsKey
()
iVal
,
err
:=
dht
.
datastore
.
Get
(
dskey
)
...
...
@@ -104,7 +105,7 @@ func (dht *IpfsDHT) checkLocalDatastore(k key.Key) (*pb.Record, error) {
return
nil
,
fmt
.
Errorf
(
"datastore had non byte-slice value for %v"
,
dskey
)
}
rec
:=
new
(
pb
.
Record
)
rec
:=
new
(
rec
pb
.
Record
)
err
=
proto
.
Unmarshal
(
byts
,
rec
)
if
err
!=
nil
{
log
.
Debug
(
"failed to unmarshal DHT record from datastore"
)
...
...
package.json
View file @
9b3d1b56
...
...
@@ -8,20 +8,15 @@
},
"gxDependencies"
:
[
{
"hash"
:
"Qm
NQynaz7qfriSUJkiEZUrm2Wen1u3Kj9goZzWtrPyu7XR
"
,
"hash"
:
"Qm
SpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52
"
,
"name"
:
"go-log"
,
"version"
:
"1.1.2"
},
{
"hash"
:
"QmVCe3SNMjkcPgnpFhZs719dheq6xE7gJwjzV7aWcUM4Ms"
,
"name"
:
"go-libp2p"
,
"version"
:
"3.3.7"
"version"
:
"1.2.0"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
UWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP
"
,
"hash"
:
"Qm
Voi5es8D5fNHZDqoW6DgDAEPEV5hQp8GBz161vZXiwpQ
"
,
"name"
:
"go-libp2p-crypto"
,
"version"
:
"1.0.
3
"
"version"
:
"1.0.
4
"
},
{
"author"
:
"whyrusleeping"
,
...
...
@@ -40,9 +35,9 @@
"version"
:
"0.0.0"
},
{
"hash"
:
"Qm
d5GW4ypC53YfF378JCHEmsQfGEDbtXpa5N5jPtoK2x4N
"
,
"hash"
:
"Qm
Z4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV
"
,
"name"
:
"gogo-protobuf"
,
"version"
:
"0.
3.1
"
"version"
:
"0.
0.0
"
},
{
"author"
:
"cheggaaa"
,
...
...
@@ -58,9 +53,9 @@
},
{
"author"
:
"jbenet"
,
"hash"
:
"Qm
TxLSvdhwg68WJimdS6icLPhZi28aTp6b7uihC2Yb47Xk
"
,
"hash"
:
"Qm
bzuUusHqaLLoNTDEVLcSF6vZDHZDLPC7p4bztRvvkXxU
"
,
"name"
:
"go-datastore"
,
"version"
:
"
0.2
.0"
"version"
:
"
1.0
.0"
},
{
"author"
:
"hashicorp"
,
...
...
@@ -82,9 +77,9 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
VvJ27GcLaLSXvcB4auk3Gn3xuWK5ti5ENkZ2pCoJEYW4
"
,
"hash"
:
"Qm
Sp3diFRRv4zR25nHU4MWNCdhT4R6cxrTPLx12MCi1TZb
"
,
"name"
:
"autobatch"
,
"version"
:
"0.2.
0
"
"version"
:
"0.2.
2
"
},
{
"author"
:
"kubuxu"
,
...
...
@@ -94,33 +89,33 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
XhU58jbgCbuAvo3Eq6VXg67yGSNArpzJwk3g54NuYVfx
"
,
"hash"
:
"Qm
ce4Y4zg3sYr7xKM5UueS67vhNni6EeWgCRnb7MbLJMew
"
,
"name"
:
"go-key"
,
"version"
:
"1.0.
1
"
"version"
:
"1.0.
2
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
awCBGLXch5o1wpiGxZ7zERDUwmaVWLXeVuLBNCjFGSoe
"
,
"hash"
:
"Qm
YpVUnnedgGrp6cX2pBii5HRQgcSr778FiKVe7o7nF5Z3
"
,
"name"
:
"go-testutil"
,
"version"
:
"1.0.
1
"
"version"
:
"1.0.
2
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
XrtCbBHacZAqRofuWY1M8TChGtiddF5xQrQ2Wy9rMSmA
"
,
"hash"
:
"Qm
e7D9iKHYxwq28p6PzCymywsYSRBx9uyGzW7qNB3s9VbC
"
,
"name"
:
"go-libp2p-record"
,
"version"
:
"1.0.
0
"
"version"
:
"1.0.
1
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
awBtuW8XoahofVAyAnTvWz3RaHzZ4ftsMH1wZP5j8zqj
"
,
"hash"
:
"Qm
c5r13R4j3V75ucMkGzHimsQDgkg4aUanX5upcUWns7XM
"
,
"name"
:
"go-libp2p-kbucket"
,
"version"
:
"1.0.
1
"
"version"
:
"1.0.
2
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
Q3MsUtakFm2htqYr1S2WGyA6A3jmiRa6yUuxiZJNwK42
"
,
"hash"
:
"Qm
YQadj3iegqmRPWjaWMRc8DG52hZa2HMkmyPkto5chDvs
"
,
"name"
:
"go-libp2p-routing"
,
"version"
:
"1.0.
0
"
"version"
:
"1.0.
2
"
},
{
"author"
:
"whyrusleeping"
,
...
...
@@ -130,9 +125,9 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
f4ETeAWXuThBfWwonVyFqGFSgTWepUDEr1txcctvpTXS
"
,
"hash"
:
"Qm
UEtj7KAkoLULwUHm4KA4pbRAcziPLHpHDRQsvn9g1i6t
"
,
"name"
:
"go-libp2p"
,
"version"
:
"3.4.
1
"
"version"
:
"3.4.
2
"
}
],
"gxVersion"
:
"0.4.0"
,
...
...
pb/dht.pb.go
View file @
9b3d1b56
...
...
@@ -16,16 +16,13 @@ package dht_pb
import
proto
"github.com/gogo/protobuf/proto"
import
fmt
"fmt"
import
math
"math"
import
record_pb
"github.com/libp2p/go-libp2p-record/pb"
// Reference imports to suppress errors if they are not otherwise used.
var
_
=
proto
.
Marshal
var
_
=
fmt
.
Errorf
var
_
=
math
.
Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
const
_
=
proto
.
GoGoProtoPackageIsVersion1
type
Message_MessageType
int32
const
(
...
...
@@ -70,7 +67,6 @@ func (x *Message_MessageType) UnmarshalJSON(data []byte) error {
*
x
=
Message_MessageType
(
value
)
return
nil
}
func
(
Message_MessageType
)
EnumDescriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptorDht
,
[]
int
{
0
,
0
}
}
type
Message_ConnectionType
int32
...
...
@@ -115,7 +111,6 @@ func (x *Message_ConnectionType) UnmarshalJSON(data []byte) error {
*
x
=
Message_ConnectionType
(
value
)
return
nil
}
func
(
Message_ConnectionType
)
EnumDescriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptorDht
,
[]
int
{
0
,
1
}
}
type
Message
struct
{
// defines what type of message it is.
...
...
@@ -140,7 +135,6 @@ type Message struct {
func
(
m
*
Message
)
Reset
()
{
*
m
=
Message
{}
}
func
(
m
*
Message
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
Message
)
ProtoMessage
()
{}
func
(
*
Message
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptorDht
,
[]
int
{
0
}
}
func
(
m
*
Message
)
GetType
()
Message_MessageType
{
if
m
!=
nil
&&
m
.
Type
!=
nil
{
...
...
@@ -197,7 +191,6 @@ type Message_Peer struct {
func
(
m
*
Message_Peer
)
Reset
()
{
*
m
=
Message_Peer
{}
}
func
(
m
*
Message_Peer
)
String
()
string
{
return
proto
.
CompactTextString
(
m
)
}
func
(
*
Message_Peer
)
ProtoMessage
()
{}
func
(
*
Message_Peer
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
fileDescriptorDht
,
[]
int
{
0
,
0
}
}
func
(
m
*
Message_Peer
)
GetId
()
string
{
if
m
!=
nil
&&
m
.
Id
!=
nil
{
...
...
@@ -226,31 +219,3 @@ func init() {
proto
.
RegisterEnum
(
"dht.pb.Message_MessageType"
,
Message_MessageType_name
,
Message_MessageType_value
)
proto
.
RegisterEnum
(
"dht.pb.Message_ConnectionType"
,
Message_ConnectionType_name
,
Message_ConnectionType_value
)
}
var
fileDescriptorDht
=
[]
byte
{
// 372 bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x09
,
0x6e
,
0x88
,
0x02
,
0xff
,
0x7c
,
0x90
,
0x4d
,
0x8f
,
0x9a
,
0x50
,
0x14
,
0x86
,
0xcb
,
0x87
,
0x56
,
0x0e
,
0x8a
,
0x78
,
0xe2
,
0x82
,
0xd8
,
0xa4
,
0x31
,
0xae
,
0xec
,
0x86
,
0x26
,
0x2e
,
0xba
,
0xe8
,
0xa2
,
0x09
,
0x01
,
0x6a
,
0x4c
,
0xec
,
0xc5
,
0xdc
,
0xa2
,
0x5d
,
0x12
,
0x85
,
0x9b
,
0x0e
,
0x19
,
0x22
,
0x06
,
0x18
,
0x27
,
0xfe
,
0xc2
,
0xf9
,
0x5b
,
0x73
,
0x01
,
0x99
,
0x41
,
0x17
,
0xb3
,
0xba
,
0xef
,
0x39
,
0xf7
,
0x79
,
0xcf
,
0x17
,
0x28
,
0xd1
,
0x43
,
0x61
,
0x9e
,
0xb2
,
0xb4
,
0x48
,
0xb1
,
0x5b
,
0xc9
,
0xc3
,
0xa4
,
0x9f
,
0xb1
,
0x30
,
0xcd
,
0xa2
,
0x3a
,
0x3b
,
0x7b
,
0x91
,
0xe1
,
0xf3
,
0x1f
,
0x96
,
0xe7
,
0xfb
,
0xff
,
0x0c
,
0xbf
,
0x83
,
0x5c
,
0x5c
,
0x4e
,
0xcc
,
0x10
,
0xa6
,
0xc2
,
0x5c
,
0x5b
,
0x7c
,
0x31
,
0x6b
,
0x83
,
0x79
,
0xfd
,
0x6e
,
0x5e
,
0x9f
,
0x23
,
0xb4
,
0x02
,
0x71
,
0x0e
,
0xc3
,
0x30
,
0x79
,
0xca
,
0x0b
,
0x96
,
0xad
,
0xd9
,
0x99
,
0x25
,
0x74
,
0xff
,
0x6c
,
0x00
,
0xf7
,
0x76
,
0xe8
,
0x7d
,
0x1a
,
0x75
,
0x90
,
0x1e
,
0xd9
,
0xc5
,
0x10
,
0xf9
,
0xaf
,
0x42
,
0x4b
,
0x89
,
0xdf
,
0xa0
,
0x5b
,
0x0f
,
0x62
,
0x48
,
0x3c
,
0xa9
,
0x2e
,
0x46
,
0x66
,
0x33
,
0xd7
,
0xc1
,
0xa4
,
0x95
,
0xa2
,
0x57
,
0x00
,
0x7f
,
0x80
,
0x1a
,
0x26
,
0x69
,
0xce
,
0xb2
,
0x0d
,
0x63
,
0x59
,
0x6e
,
0xf4
,
0xa6
,
0x12
,
0xe7
,
0xc7
,
0xf7
,
0xe3
,
0x95
,
0x9f
,
0xb4
,
0x0d
,
0xe2
,
0x4f
,
0x18
,
0xf0
,
0x25
,
0xcf
,
0x71
,
0xd4
,
0x38
,
0x95
,
0x0f
,
0x9c
,
0xb7
,
0xe8
,
0x24
,
0x01
,
0xb9
,
0x14
,
0xa8
,
0x81
,
0x18
,
0x47
,
0xd5
,
0x45
,
0x14
,
0xca
,
0x15
,
0x8e
,
0xa1
,
0xb3
,
0x8f
,
0x22
,
0x5e
,
0x4b
,
0xe4
,
0xb5
,
0xfa
,
0xb4
,
0x0e
,
0xf0
,
0x17
,
0x40
,
0x98
,
0x1e
,
0x8f
,
0x2c
,
0x2c
,
0xe2
,
0xf4
,
0x58
,
0x2d
,
0xa4
,
0x2d
,
0xbe
,
0xde
,
0xb7
,
0xb1
,
0xdf
,
0x88
,
0xea
,
0x84
,
0x2d
,
0xc7
,
0x2c
,
0x06
,
0xb5
,
0x75
,
0x5d
,
0x1c
,
0x80
,
0xb2
,
0xd9
,
0xfa
,
0xc1
,
0xce
,
0x5a
,
0x6f
,
0x5d
,
0xfd
,
0x53
,
0x19
,
0x2e
,
0xdd
,
0x26
,
0x14
,
0xf8
,
0x2d
,
0xfb
,
0x96
,
0xe3
,
0x04
,
0x1b
,
0xea
,
0xed
,
0x56
,
0x8e
,
0x4b
,
0x75
,
0x11
,
0x47
,
0x30
,
0x28
,
0x81
,
0x26
,
0xf3
,
0x57
,
0x97
,
0x4a
,
0xcf
,
0xef
,
0x15
,
0x71
,
0x02
,
0xe2
,
0x39
,
0xae
,
0x2e
,
0x63
,
0x8f
,
0xaf
,
0xb3
,
0x22
,
0x4b
,
0xbd
,
0x33
,
0xfb
,
0x07
,
0xda
,
0xed
,
0x20
,
0xa5
,
0x9b
,
0x78
,
0x7e
,
0x60
,
0x7b
,
0x84
,
0xb8
,
0xb6
,
0xef
,
0x3a
,
0x75
,
0xc7
,
0xf7
,
0x50
,
0xc0
,
0x21
,
0xa8
,
0xb6
,
0x45
,
0x1a
,
0x82
,
0x37
,
0x44
,
0x5e
,
0xc4
,
0x22
,
0x2d
,
0x97
,
0x2e
,
0xbd
,
0x06
,
0x00
,
0x00
,
0xff
,
0xff
,
0x2a
,
0x4c
,
0x62
,
0x25
,
0x6b
,
0x02
,
0x00
,
0x00
,
}
pb/message.go
View file @
9b3d1b56
package
dht_pb
import
(
ma
"github.com/jbenet/go-multiaddr"
key
"github.com/ipfs/go-key"
peer
"github.com/ipfs/go-libp2p-peer"
pstore
"github.com/ipfs/go-libp2p-peerstore"
logging
"github.com/ipfs/go-log"
ma
"github.com/jbenet/go-multiaddr"
inet
"github.com/libp2p/go-libp2p/p2p/net"
)
...
...
records.go
View file @
9b3d1b56
...
...
@@ -7,8 +7,8 @@ import (
ci
"github.com/ipfs/go-libp2p-crypto"
peer
"github.com/ipfs/go-libp2p-peer"
ctxfrac
"github.com/jbenet/go-context/frac"
pb
"github.com/libp2p/go-libp2p-kad-dht/pb"
record
"github.com/libp2p/go-libp2p-record"
recpb
"github.com/libp2p/go-libp2p-record/pb"
routing
"github.com/libp2p/go-libp2p-routing"
"golang.org/x/net/context"
)
...
...
@@ -106,7 +106,7 @@ func (dht *IpfsDHT) getPublicKeyFromNode(ctx context.Context, p peer.ID) (ci.Pub
// verifyRecordLocally attempts to verify a record. if we do not have the public
// key, we fail. we do not search the dht.
func
(
dht
*
IpfsDHT
)
verifyRecordLocally
(
r
*
pb
.
Record
)
error
{
func
(
dht
*
IpfsDHT
)
verifyRecordLocally
(
r
*
rec
pb
.
Record
)
error
{
if
len
(
r
.
Signature
)
>
0
{
// First, validate the signature
...
...
@@ -129,7 +129,7 @@ func (dht *IpfsDHT) verifyRecordLocally(r *pb.Record) error {
// retrieving arbitrary public keys from the DHT as a result of passively
// receiving records (e.g. through a PUT_VALUE or ADD_PROVIDER) can cause a
// massive amplification attack on the dht. Use with care.
func
(
dht
*
IpfsDHT
)
verifyRecordOnline
(
ctx
context
.
Context
,
r
*
pb
.
Record
)
error
{
func
(
dht
*
IpfsDHT
)
verifyRecordOnline
(
ctx
context
.
Context
,
r
*
rec
pb
.
Record
)
error
{
if
len
(
r
.
Signature
)
>
0
{
// get the public key, search for it if necessary.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment