diff --git a/groupChat/receive.go b/groupChat/receive.go index 93a149c4e0e480d4d56b98123ce1627cf5962d55..52bed4a06a082087d87ae07d30ba84d2a4952379 100644 --- a/groupChat/receive.go +++ b/groupChat/receive.go @@ -42,11 +42,17 @@ func (m Manager) receive(rawMsgs chan message.Receive, stop *stoppable.Single) { stop.ToStopped() return case receiveMsg := <-rawMsgs: - jww.TRACE.Print("Group message reception received cMix message.") + jww.DEBUG.Printf("Group message reception received cMix message on round %d (%d).", + receiveMsg.RoundId, receiveMsg.RoundTimestamp.Unix()) + + // If given zero time, try to guesstimate roundTimestamp as right now + if receiveMsg.RoundTimestamp.Equal(time.Unix(0, 0)) { + jww.ERROR.Printf("getCryptKey missing roundTimestamp") + receiveMsg.RoundTimestamp = time.Now() + } // Attempt to read the message - g, msgID, timestamp, senderID, msg, noFpMatch, err := - m.readMessage(receiveMsg) + g, msgID, timestamp, senderID, msg, noFpMatch, err := m.readMessage(receiveMsg) if err != nil { if noFpMatch { jww.TRACE.Printf("Received message not for group chat: %+v", @@ -145,6 +151,9 @@ func (m *Manager) decryptMessage(g gs.Group, cMixMsg format.Message, messageID := group.NewMessageID(g.ID, intlMsg.Marshal()) + // Remove from garbled message on success to prevent reprocessing + m.store.GetGarbledMessages().Remove(cMixMsg) + return messageID, intlMsg.GetTimestamp(), senderID, intlMsg.GetPayload(), nil } diff --git a/network/message/garbled.go b/network/message/garbled.go index b2449ca9f0d79c8d1b5cdd7a8e9cd9db1ae2863f..8d0950f3d2a781e3f5836cb7ffa225f10e01c294 100644 --- a/network/message/garbled.go +++ b/network/message/garbled.go @@ -109,11 +109,11 @@ func (m *Manager) handleGarbledMessages() { MessageType: message.Raw, Sender: &id.ID{}, EphemeralID: ephemeral.Id{}, - Timestamp: time.Time{}, + Timestamp: time.Unix(0, 0), Encryption: message.None, RecipientID: &id.ID{}, RoundId: 0, - RoundTimestamp: time.Time{}, + RoundTimestamp: time.Unix(0, 0), } im := fmt.Sprintf("[GARBLE] RAW Message reprocessed: keyFP: %v, "+ "msgDigest: %s", grbldMsg.GetKeyFP(), grbldMsg.Digest()) diff --git a/network/message/handler.go b/network/message/handler.go index 7aa63e6ad85293b57d716d9bdf894736a3fd4bed..1c89d9a53c68beffc9f44d0a3b83994949dfdf3f 100644 --- a/network/message/handler.go +++ b/network/message/handler.go @@ -111,15 +111,17 @@ func (m *Manager) handleMessage(ecrMsg format.Message, bundle Bundle, edge *edge // and add it to garbled messages to be handled later msg = ecrMsg raw := message.Receive{ - Payload: msg.Marshal(), - MessageType: message.Raw, - Sender: &id.ID{}, - EphemeralID: identity.EphId, - Timestamp: time.Time{}, - Encryption: message.None, - RecipientID: identity.Source, - RoundId: id.Round(bundle.RoundInfo.ID), - RoundTimestamp: time.Unix(0, int64(bundle.RoundInfo.Timestamps[states.QUEUED])), + Payload: msg.Marshal(), + MessageType: message.Raw, + Sender: &id.ID{}, + EphemeralID: identity.EphId, + Timestamp: time.Time{}, + Encryption: message.None, + RecipientID: identity.Source, + RoundId: id.Round(bundle.RoundInfo.ID), + // We use PRECOMPUTING here because all Rounds have that timestamp available to them + // QUEUED can be missing sometimes and cause a lot of hidden problems further down the line + RoundTimestamp: time.Unix(0, int64(bundle.RoundInfo.Timestamps[states.PRECOMPUTING])), } im := fmt.Sprintf("Received message of type Garbled/RAW: keyFP: %v, round: %d, "+ "msgDigest: %s", msg.GetKeyFP(), bundle.Round, msg.Digest()) diff --git a/network/rounds/check.go b/network/rounds/check.go index afcd20f1d52a0f1b089adb82b28606f576ebf1ec..39068df86502617f96edd55b07f6614f40db1860 100644 --- a/network/rounds/check.go +++ b/network/rounds/check.go @@ -63,7 +63,7 @@ func (m *Manager) GetMessagesFromRound(roundID id.Round, identity reception.Iden jww.INFO.Printf("Messages found in round %d for %d (%s), looking "+ "up messages via historical lookup", roundID, identity.EphId.Int64(), identity.Source) - //store the round as an unretreived round + //store the round as an unreceived round err = m.Session.UncheckedRounds().AddRound(roundID, nil, identity.Source, identity.EphId) if err != nil { @@ -79,7 +79,7 @@ func (m *Manager) GetMessagesFromRound(roundID id.Round, identity reception.Iden jww.INFO.Printf("Messages found in round %d for %d (%s), looking "+ "up messages via in ram lookup", roundID, identity.EphId.Int64(), identity.Source) - //store the round as an unretreived round + //store the round as an unreceived round if !m.params.RealtimeOnly { err = m.Session.UncheckedRounds().AddRound(roundID, ri, identity.Source, identity.EphId) diff --git a/network/rounds/historical.go b/network/rounds/historical.go index c3b9b4b9b4296ed776dfa7503f01b301ffc9e46d..39fd0b318d19db8613e57d2a9b335cc7e24577a3 100644 --- a/network/rounds/historical.go +++ b/network/rounds/historical.go @@ -120,7 +120,7 @@ func (m *Manager) processHistoricalRounds(comm historicalRoundsComms, stop *stop // process the returned historical roundRequests. for i, roundInfo := range response.Rounds { // The interface has missing returns returned as nil, such roundRequests - // need be be removes as processing so the network follower will + // need to be removes as processing so the network follower will // pick them up in the future. if roundInfo == nil { var errMsg string