Skip to content
Snippets Groups Projects
Commit 4e4eb707 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

added a ton of logging to garbled messages

parent 82885c9d
No related branches found
No related tags found
2 merge requests!170Release,!125Garbled message logging
...@@ -8,10 +8,12 @@ ...@@ -8,10 +8,12 @@
package message package message
import ( import (
"encoding/base64"
"fmt" "fmt"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/stoppable" "gitlab.com/elixxir/client/stoppable"
"gitlab.com/elixxir/crypto/fingerprint"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral" "gitlab.com/xx_network/primitives/id/ephemeral"
...@@ -45,6 +47,7 @@ func (m *Manager) processGarbledMessages(stop *stoppable.Single) { ...@@ -45,6 +47,7 @@ func (m *Manager) processGarbledMessages(stop *stoppable.Single) {
stop.ToStopped() stop.ToStopped()
return return
case <-m.triggerGarbled: case <-m.triggerGarbled:
jww.INFO.Printf("[GARBLE] Checking Garbled messages")
m.handleGarbledMessages() m.handleGarbledMessages()
} }
} }
...@@ -56,11 +59,16 @@ func (m *Manager) handleGarbledMessages() { ...@@ -56,11 +59,16 @@ func (m *Manager) handleGarbledMessages() {
e2eKv := m.Session.E2e() e2eKv := m.Session.E2e()
var failedMsgs []format.Message var failedMsgs []format.Message
//try to decrypt every garbled message, excising those who's counts are too high //try to decrypt every garbled message, excising those who's counts are too high
i:=0
for grbldMsg, count, timestamp, has := garbledMsgs.Next(); has; grbldMsg, count, timestamp, has = garbledMsgs.Next() { for grbldMsg, count, timestamp, has := garbledMsgs.Next(); has; grbldMsg, count, timestamp, has = garbledMsgs.Next() {
//if it exists, check against all in the list //if it exists, check against all in the list
modifiedContents := append([]byte{0}, grbldMsg.GetContents()...) modifiedContents := append([]byte{0}, grbldMsg.GetContents()...)
identity := m.Session.GetUser().GetContact().ID identity := m.Session.GetUser().ReceptionID
_, forMe, _ := m.Session.GetEdge().Check(identity, grbldMsg.GetIdentityFP(), modifiedContents) hasID, forMe, _ := m.Session.GetEdge().Check(identity, grbldMsg.GetIdentityFP(), modifiedContents)
jww.INFO.Printf("[GARBLE] Msg %d -- hasID: %t, forMe: %t, identity: %s, " +
"fp: %s, contentsHash: %s", i, hasID, forMe, identity,
base64.StdEncoding.EncodeToString(grbldMsg.GetIdentityFP()),
base64.StdEncoding.EncodeToString(fingerprint.GetMessageHash(modifiedContents)))
if forMe { if forMe {
fingerprint := grbldMsg.GetKeyFP() fingerprint := grbldMsg.GetKeyFP()
// Check if the key is there, process it if it is // Check if the key is there, process it if it is
...@@ -121,6 +129,7 @@ func (m *Manager) handleGarbledMessages() { ...@@ -121,6 +129,7 @@ func (m *Manager) handleGarbledMessages() {
m.Session.GetGarbledMessages().Add(grbldMsg) m.Session.GetGarbledMessages().Add(grbldMsg)
m.Switchboard.Speak(raw) m.Switchboard.Speak(raw)
} }
i++
} }
// fail the message if any part of the decryption fails, // fail the message if any part of the decryption fails,
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
package message package message
import ( import (
"encoding/base64"
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/interfaces/message"
...@@ -159,7 +160,8 @@ func buildSlotMessage(msg format.Message, recipient *id.ID, target *id.ID, ...@@ -159,7 +160,8 @@ func buildSlotMessage(msg format.Message, recipient *id.ID, target *id.ID,
msg.SetIdentityFP(ifp) msg.SetIdentityFP(ifp)
jww.INFO.Printf("Sending to %s with preimage %v, ifp: %v", recipient, preimage, ifp) jww.INFO.Printf("Sending to %s with preimage %v, ifp: %v, messageHash: %s", recipient, preimage,
ifp, base64.StdEncoding.EncodeToString(append([]byte{0}, msg.GetContents()...)))
// Encrypt the message // Encrypt the message
salt := make([]byte, 32) salt := make([]byte, 32)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment