@@ -246,10 +246,11 @@ func (m *MessageRetriever) fetchIPFS(pid peer.ID, n *core.IpfsNode, addr ma.Mult
246
246
select {
247
247
case <- c :
248
248
if err != nil {
249
- log .Errorf ("Error retrieving offline message from %s, %s" , addr .String (), err .Error ())
249
+ log .Errorf ("Error retrieving offline message from: %s, Error: %s" , addr .String (), err .Error ())
250
250
return
251
251
}
252
- log .Debugf ("Successfully downloaded offline message from %s" , addr .String ())
252
+ log .Debugf ("Successfully downloaded offline message %s from: %s" , addr .String (), pid .Pretty ())
253
+
253
254
err = m .db .OfflineMessages ().Put (addr .String ())
254
255
if err != nil {
255
256
log .Error (err )
@@ -308,44 +309,46 @@ func (m *MessageRetriever) attemptDecrypt(ciphertext []byte, pid peer.ID, addr m
308
309
// Decrypt and unmarshal plaintext
309
310
plaintext , err := net .Decrypt (m .node .PrivateKey , ciphertext )
310
311
if err != nil {
311
- log .Warningf ("Unable to decrypt offline message from %s: %s " , addr .String (), err .Error ())
312
+ log .Warningf ("Unable to decrypt cipher text to plain text, CID: %s: Error:%s \n " , addr .String (), err .Error ())
312
313
return
313
314
}
314
315
315
316
// Unmarshal plaintext
316
317
env := pb.Envelope {}
317
318
err = proto .Unmarshal (plaintext , & env )
318
319
if err != nil {
319
- log .Warningf ("Unable to decrypt offline message from %s: %s " , addr .String (), err .Error ())
320
+ log .Warningf ("Unable to unmarshal plaintext to encrypted Envelope, CID: %s: Error:%s \n " , addr .String (), err .Error ())
320
321
return
321
322
}
322
323
323
324
// Validate the signature
324
325
ser , err := proto .Marshal (env .Message )
325
326
if err != nil {
326
- log .Warningf ("Unable to decrypt offline message from %s: %s " , addr .String (), err .Error ())
327
+ log .Warningf ("Unable to serialize the encrypted message, CID: %s: Error:%s \n " , addr .String (), err .Error ())
327
328
return
328
329
}
329
330
pubkey , err := libp2p .UnmarshalPublicKey (env .Pubkey )
330
331
if err != nil {
331
- log .Warningf ("Unable to decrypt offline message from %s: %s " , addr .String (), err .Error ())
332
+ log .Warningf ("Unable to unmarshal the public key from, CID: %s: Error:%s \n " , addr .String (), err .Error ())
332
333
return
333
334
}
334
335
335
336
valid , err := pubkey .Verify (ser , env .Signature )
336
337
if err != nil || ! valid {
337
- log .Warningf ("Unable to decrypt offline message from %s: %s " , addr .String (), err .Error ())
338
+ log .Warningf ("Unable to verify message signature, CID: %s: Error:%s \n " , addr .String (), err .Error ())
338
339
return
339
340
}
340
341
341
342
id , err := peer .IDFromPublicKey (pubkey )
342
343
if err != nil {
343
- log .Warningf ("Unable to decrypt offline message from %s: %s " , addr .String (), err .Error ())
344
+ log .Warningf ("Unable to get a peer ID from the pubkey, CID: %s: Error:%s \n " , addr .String (), err .Error ())
344
345
return
345
346
}
346
347
348
+ log .Debugf ("Received offline message %s from: %s\n " , addr .String (), id .Pretty ())
349
+
347
350
if m .bm .IsBanned (id ) {
348
- log .Warningf ("Received and dropped offline message from banned user: %s " , id .String ())
351
+ log .Warningf ("Received and dropped offline message from banned user: %s\n " , id .Pretty ())
349
352
return
350
353
}
351
354
0 commit comments