Skip to content

Commit

Permalink
Do not publish public keys extractable from ID
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Justin Drake <drakefjustin@gmail.com>
  • Loading branch information
JustinDrake committed Jul 14, 2017
1 parent 06c567d commit f4e93c3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions namesys/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,24 @@ func PutRecordToRouting(ctx context.Context, k ci.PrivKey, value path.Path, seqn
entry.Ttl = proto.Uint64(uint64(ttl.Nanoseconds()))
}

errs := make(chan error, 2)
errs := make(chan error, 2) // At most two errors (IPNS, and public key)

// Attempt to extract the public key from the ID
var extractedPublicKey = id.ExtractPublicKey()

go func() {
errs <- PublishEntry(ctx, r, ipnskey, entry)
}()

go func() {
errs <- PublishPublicKey(ctx, r, namekey, k.GetPublic())
}()
// Publish the public key if a public key cannot be extracted from the ID
if extractedPublicKey == nil {
go func() {
errs <- PublishPublicKey(ctx, r, namekey, k.GetPublic())
}()

if err := waitOnErrChan(ctx, errs); err != nil {
return err
if err := waitOnErrChan(ctx, errs); err != nil {
return err
}
}

return waitOnErrChan(ctx, errs)
Expand Down

0 comments on commit f4e93c3

Please sign in to comment.