Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1876 from OpenBazaar/brian.fixlogging
Browse files Browse the repository at this point in the history
Fix formatted logging messages
  • Loading branch information
cpacia authored Nov 27, 2019
2 parents b256516 + 025c646 commit 62f1faa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions net/retriever/retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,44 +303,44 @@ func (m *MessageRetriever) attemptDecrypt(ciphertext []byte, pid peer.ID, addr m
// Decrypt and unmarshal plaintext
plaintext, err := net.Decrypt(m.node.PrivateKey, ciphertext)
if err != nil {
log.Warning("Unable to decrypt offline message from %s: %s", addr.String(), err.Error())
log.Warningf("Unable to decrypt offline message from %s: %s", addr.String(), err.Error())
return
}

// Unmarshal plaintext
env := pb.Envelope{}
err = proto.Unmarshal(plaintext, &env)
if err != nil {
log.Warning("Unable to decrypt offline message from %s: %s", addr.String(), err.Error())
log.Warningf("Unable to decrypt offline message from %s: %s", addr.String(), err.Error())
return
}

// Validate the signature
ser, err := proto.Marshal(env.Message)
if err != nil {
log.Warning("Unable to decrypt offline message from %s: %s", addr.String(), err.Error())
log.Warningf("Unable to decrypt offline message from %s: %s", addr.String(), err.Error())
return
}
pubkey, err := libp2p.UnmarshalPublicKey(env.Pubkey)
if err != nil {
log.Warning("Unable to decrypt offline message from %s: %s", addr.String(), err.Error())
log.Warningf("Unable to decrypt offline message from %s: %s", addr.String(), err.Error())
return
}

valid, err := pubkey.Verify(ser, env.Signature)
if err != nil || !valid {
log.Warning("Unable to decrypt offline message from %s: %s", addr.String(), err.Error())
log.Warningf("Unable to decrypt offline message from %s: %s", addr.String(), err.Error())
return
}

id, err := peer.IDFromPublicKey(pubkey)
if err != nil {
log.Warning("Unable to decrypt offline message from %s: %s", addr.String(), err.Error())
log.Warningf("Unable to decrypt offline message from %s: %s", addr.String(), err.Error())
return
}

if m.bm.IsBanned(id) {
log.Warning("Received and dropped offline message from banned user: %s ", id.String())
log.Warningf("Received and dropped offline message from banned user: %s ", id.String())
return
}

Expand Down

0 comments on commit 62f1faa

Please sign in to comment.