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-dms3ns
Commits
697df1a9
Commit
697df1a9
authored
6 years ago
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a helper function for getting the EOL of a record
Useful for caching.
parent
abf43026
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
+17
-12
ipns.go
ipns.go
+17
-12
No files found.
ipns.go
View file @
697df1a9
...
...
@@ -42,22 +42,27 @@ func Validate(pk ic.PubKey, entry *pb.IpnsEntry) error {
return
ErrSignature
}
// Check that record has not expired
switch
entry
.
GetValidityType
()
{
case
pb
.
IpnsEntry_EOL
:
t
,
err
:=
u
.
ParseRFC3339
(
string
(
entry
.
GetValidity
()))
if
err
!=
nil
{
return
err
}
if
time
.
Now
()
.
After
(
t
)
{
return
ErrExpiredRecord
}
default
:
return
ErrUnrecognizedValidity
eol
,
err
:=
GetEOL
(
entry
)
if
err
!=
nil
{
return
err
}
if
time
.
Now
()
.
After
(
eol
)
{
return
ErrExpiredRecord
}
return
nil
}
// GetEOL returns the EOL of this IPNS entry
//
// This function returns ErrUnrecognizedValidity if the validity type of the
// record isn't EOL. Otherwise, it returns an error if it can't parse the EOL.
func
GetEOL
(
entry
*
pb
.
IpnsEntry
)
(
time
.
Time
,
error
)
{
if
entry
.
GetValidityType
()
!=
pb
.
IpnsEntry_EOL
{
return
time
.
Time
{},
ErrUnrecognizedValidity
}
return
u
.
ParseRFC3339
(
string
(
entry
.
GetValidity
()))
}
// EmbedPublicKey embeds the given public key in the given ipns entry. While not
// strictly required, some nodes (e.g., DHT servers) may reject IPNS entries
// that don't embed their public keys as they may not be able to validate them
...
...
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