Skip to content
Snippets Groups Projects
Commit 9fc6d2cf authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Add a wait loop to wait for rekeying when we run out of keys

parent 0583d19d
No related branches found
No related tags found
No related merge requests found
......@@ -15,12 +15,15 @@ import (
type E2E struct {
Type SendType
RetryCount int
CMIX
}
func GetDefaultE2E() E2E {
return E2E{Type: Standard,
return E2E{
Type: Standard,
CMIX: GetDefaultCMIX(),
RetryCount: 10,
}
}
func (e E2E) Marshal() ([]byte, error) {
......
......@@ -50,7 +50,7 @@ func (m *Manager) handleMessage(ecrMsg format.Message, identity reception.Identi
forMe, err := fingerprint2.CheckIdentityFP(ecrMsg.GetIdentityFP(),
ecrMsg.GetContents(), identity.Source)
if err != nil {
jww.FATAL.Panicf("Could not check IdentityFIngerprint: %+v", err)
jww.FATAL.Panicf("Could not check IdentityFingerprint: %+v", err)
}
if !forMe {
return
......
......@@ -9,6 +9,7 @@ package message
import (
"github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/keyExchange"
......@@ -17,7 +18,6 @@ import (
"gitlab.com/xx_network/primitives/id"
"sync"
"time"
jww "github.com/spf13/jwalterweatherman"
)
func (m *Manager) SendE2E(msg message.Send, param params.E2E) ([]id.Round, e2e.MessageID, error) {
......@@ -51,7 +51,6 @@ func (m *Manager) SendE2E(msg message.Send, param params.E2E) ([]id.Round, e2e.M
jww.INFO.Printf("E2E sending %d messages to %s",
len(partitions), msg.Recipient)
for i, p := range partitions {
//create the cmix message
msgCmix := format.NewMessage(m.Session.Cmix().GetGroup().GetP().ByteLen())
......@@ -59,6 +58,18 @@ func (m *Manager) SendE2E(msg message.Send, param params.E2E) ([]id.Round, e2e.M
//get a key to end to end encrypt
key, err := partner.GetKeyForSending(param.Type)
keyTries := 0
for err != nil && keyTries < param.RetryCount {
jww.WARN.Printf("Out of sending keys for %s "+
"(msgDigest: %s, partition: %d), this can "+
"happen when sending messages faster than "+
"the client can negotiate keys. Please "+
"adjust your e2e key parameters",
msg.Recipient, msgCmix.Digest(), i)
keyTries++
time.Sleep(param.RetryDelay)
key, err = partner.GetKeyForSending(param.Type)
}
if err != nil {
return nil, e2e.MessageID{}, errors.WithMessagef(err, "Failed to get key "+
"for end to end encryption")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment