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
dms3
go-dms3
Commits
cd4e23bc
Commit
cd4e23bc
authored
10 years ago
by
Jeromy
Committed by
Juan Batiz-Benet
10 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some comments
parent
58b66f0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
namesys/publisher.go
namesys/publisher.go
+4
-0
routing/dht/records.go
routing/dht/records.go
+10
-0
No files found.
namesys/publisher.go
View file @
cd4e23bc
...
...
@@ -20,6 +20,8 @@ import (
// invalid due to being too old
var
ErrExpiredRecord
=
errors
.
New
(
"expired record"
)
// ErrUnrecognizedValidity is returned when an IpnsRecord has an
// unknown validity type.
var
ErrUnrecognizedValidity
=
errors
.
New
(
"unrecognized validity type"
)
// ipnsPublisher is capable of publishing and resolving names to the IPFS
...
...
@@ -107,6 +109,8 @@ func ipnsEntryDataForSig(e *pb.IpnsEntry) []byte {
[]
byte
{})
}
// ValidateIpnsRecord implements ValidatorFunc and verifies that the
// given 'val' is an IpnsEntry and that that entry is valid.
func
ValidateIpnsRecord
(
k
u
.
Key
,
val
[]
byte
)
error
{
entry
:=
new
(
pb
.
IpnsEntry
)
err
:=
proto
.
Unmarshal
(
val
,
entry
)
...
...
This diff is collapsed.
Click to expand it.
routing/dht/records.go
View file @
cd4e23bc
...
...
@@ -14,9 +14,16 @@ import (
u
"github.com/jbenet/go-ipfs/util"
)
// ValidatorFunc is a function that is called to validate a given
// type of DHTRecord.
type
ValidatorFunc
func
(
u
.
Key
,
[]
byte
)
error
// ErrBadRecord is returned any time a dht record is found to be
// incorrectly formatted or signed.
var
ErrBadRecord
=
errors
.
New
(
"bad dht record"
)
// ErrInvalidRecordType is returned if a DHTRecord keys prefix
// is not found in the Validator map of the DHT.
var
ErrInvalidRecordType
=
errors
.
New
(
"invalid record keytype"
)
// creates and signs a dht record for the given key/value pair
...
...
@@ -96,6 +103,9 @@ func (dht *IpfsDHT) verifyRecord(r *pb.Record) error {
return
fnc
(
u
.
Key
(
r
.
GetKey
()),
r
.
GetValue
())
}
// ValidatePublicKeyRecord implements ValidatorFunc and
// verifies that the passed in record value is the PublicKey
// that matches the passed in key.
func
ValidatePublicKeyRecord
(
k
u
.
Key
,
val
[]
byte
)
error
{
keyparts
:=
bytes
.
Split
([]
byte
(
k
),
[]
byte
(
"/"
))
if
len
(
keyparts
)
<
3
{
...
...
This diff is collapsed.
Click to expand it.
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