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