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

more work

parent 787b1590
No related branches found
No related tags found
3 merge requests!510Release,!207WIP: Client Restructure,!203Symmetric broadcast
......@@ -13,7 +13,7 @@ require (
github.com/spf13/viper v1.7.1
gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228
gitlab.com/elixxir/comms v0.0.4-0.20220308183624-c2183e687a03
gitlab.com/elixxir/crypto v0.0.7-0.20220309234716-1ba339865787
gitlab.com/elixxir/crypto v0.0.7-0.20220325215559-7489d68d7714
gitlab.com/elixxir/ekv v0.1.6
gitlab.com/elixxir/primitives v0.0.3-0.20220222212109-d412a6e46623
gitlab.com/xx_network/comms v0.0.4-0.20220311192415-d95fe8906580
......
......@@ -279,6 +279,8 @@ gitlab.com/elixxir/crypto v0.0.3/go.mod h1:ZNgBOblhYToR4m8tj4cMvJ9UsJAUKq+p0gCp0
gitlab.com/elixxir/crypto v0.0.7-0.20220222221347-95c7ae58da6b/go.mod h1:tD6XjtQh87T2nKZL5I/pYPck5M2wLpkZ1Oz7H/LqO10=
gitlab.com/elixxir/crypto v0.0.7-0.20220309234716-1ba339865787 h1:+qmsWov412+Yn7AKUhTbOcDgAydNXlNLPmFpO2W5LwY=
gitlab.com/elixxir/crypto v0.0.7-0.20220309234716-1ba339865787/go.mod h1:tD6XjtQh87T2nKZL5I/pYPck5M2wLpkZ1Oz7H/LqO10=
gitlab.com/elixxir/crypto v0.0.7-0.20220325215559-7489d68d7714 h1:epnov8zyFWod14MUNtGHSbZCVSkZjN4NvoiBs1TgEV8=
gitlab.com/elixxir/crypto v0.0.7-0.20220325215559-7489d68d7714/go.mod h1:tD6XjtQh87T2nKZL5I/pYPck5M2wLpkZ1Oz7H/LqO10=
gitlab.com/elixxir/ekv v0.1.6 h1:M2hUSNhH/ChxDd+s8xBqSEKgoPtmE6hOEBqQ73KbN6A=
gitlab.com/elixxir/ekv v0.1.6/go.mod h1:e6WPUt97taFZe5PFLPb1Dupk7tqmDCTQu1kkstqJvw4=
gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg=
......
package network
import (
"gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/network/identity/receptionID"
"gitlab.com/elixxir/client/stoppable"
"gitlab.com/elixxir/comms/mixmessages"
......@@ -35,7 +34,7 @@ type Manager interface {
// replaced with multiple uses of SendCmix in most cases. Returns the round
// ID of the round the payload was sent or an error if it fails.
// WARNING: Potentially Unsafe
SendManyCMIX(messages []message.TargetedCmixMessage, p CMIXParams) (
SendManyCMIX(messages []TargetedCmixMessage, p CMIXParams) (
id.Round, []ephemeral.Id, error)
/*===Message Reception====================================================*/
......@@ -117,6 +116,11 @@ type Manager interface {
// Multiple trackTriggers can be registered
TrackTriggers(TriggerTracker)
//Dropped Messages Pickup
RegisterDroppedMessagesPickup(response MessageProcessor)
DenoteReception(msgId uint)
/* In inProcess */
// it is possible to receive a message over cMix before the fingerprints or
// triggers are registered. As a result, when handling fails, messages are
......
......@@ -73,21 +73,21 @@ func (p *handler) handleMessage(ecrMsg format.Message, bundle Bundle) bool {
return true
}
triggers, exists := p.get(identity.Source, ecrMsg.GetIdentityFP(), ecrMsg.GetContents())
triggers, exists := p.get(identity.Source, ecrMsg.GetSIH(), ecrMsg.GetContents())
if exists {
for _, t := range triggers {
go t.Process(ecrMsg, receptionID, round)
}
if len(triggers) == 0 {
jww.ERROR.Printf("empty trigger list for %s",
ecrMsg.GetIdentityFP()) // get preimage
ecrMsg.GetSIH()) // get preimage
}
return true
} else {
// TODO: delete this else block because it should not be needed.
jww.INFO.Printf("checking backup %v", preimage.MakeDefault(identity.Source))
// //if it doesnt exist, check against the default fingerprint for the identity
// forMe = fingerprint2.CheckIdentityFP(ecrMsg.GetIdentityFP(),
// forMe = fingerprint2.CheckIdentityFP(ecrMsg.GetSIH(),
// ecrMsgContents, preimage.MakeDefault(identity.Source))
}
......@@ -97,7 +97,7 @@ func (p *handler) handleMessage(ecrMsg format.Message, bundle Bundle) bool {
jww.TRACE.Printf("Message for %d (%s) failed identity "+
"check: %v (expected-default) vs %v (received)",
identity.EphId,
identity.Source, expectedFP, ecrMsg.GetIdentityFP())
identity.Source, expectedFP, ecrMsg.GetSIH())
}
im := fmt.Sprintf("Garbled/RAW Message: keyFP: %v, round: %d"+
"msgDigest: %s, not determined to be for client",
......
......@@ -8,6 +8,7 @@
package message
import (
"golang.org/x/crypto/blake2b"
"sync"
"github.com/pkg/errors"
......@@ -102,20 +103,35 @@ func (t *TriggersManager) AddTrigger(clientID *id.ID, newTrigger interfaces.Trig
MessageProcessor: response,
}
realTrigger := Generate(newTrigger.Preimage,newTrigger.Type)
cid := *clientID
if _, exists := t.tmap[cid]; !exists {
t.tmap[cid] = make(map[interfaces.Preimage][]trigger)
}
pi := newTrigger.Preimage
if existingTriggers, exists := t.tmap[cid][pi]; exists {
t.tmap[cid][pi] = append(existingTriggers, newEntry)
if existingTriggers, exists := t.tmap[cid][realTrigger]; exists {
t.tmap[cid][realTrigger] = append(existingTriggers, newEntry)
}
t.tmap[cid][pi] = []trigger{newEntry}
t.tmap[cid][realTrigger] = []trigger{newEntry}
t.numTriggers++
t.triggerTriggerTracking()
t.triggerTracking()
}
func Generate(data []byte, t string) []byte {
if t == Default {
return data
}
// Hash fingerprints
h, _ := blake2b.New256(nil)
h.Write(data)
h.Write([]byte(t))
// Base 64 encode hash and truncate
return h.Sum(nil)
}
// DeleteTrigger - If only a single response is associated with the preimage,
......@@ -159,7 +175,7 @@ func (t *TriggersManager) DeleteTrigger(clientID *id.ID, preimage interfaces.Pre
}
}
t.numTriggers--
t.triggerTriggerTracking()
t.triggerTracking()
return nil
}
......@@ -183,8 +199,8 @@ func (t *TriggersManager) TrackTriggers(triggerTracker interfaces.TriggerTracker
t.trackers = append(t.trackers, triggerTracker)
}
//triggerTriggerTracking triggers the tracking of triggers
func (t *TriggersManager) triggerTriggerTracking() {
//triggerTracking triggers the tracking of triggers
func (t *TriggersManager) triggerTracking() {
if len(t.trackers) == 0 {
return
}
......
......@@ -2,6 +2,7 @@ package network
import (
"encoding/json"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/network/historical"
"gitlab.com/elixxir/client/network/message"
"gitlab.com/elixxir/client/network/rounds"
......@@ -97,7 +98,7 @@ type CMIXParams struct {
// an alternate identity preimage to use on send. If not set, the default
// for the sending identity will be used
IdentityPreimage []byte
trigger interfaces.Trigger
// Tag which prints with sending logs to help localize the source
// All internal sends are tagged, so the default tag is "External"
......
......@@ -12,6 +12,7 @@ import (
"github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/event"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/network/gateway"
"gitlab.com/elixxir/client/network/nodes"
"gitlab.com/elixxir/client/stoppable"
......@@ -31,11 +32,48 @@ import (
"time"
)
type StandardSendable struct{
Recipient *id.ID
Payload []byte
Fingerprint format.Fingerprint
Trigger StandardTrigger
}
type StandardTrigger struct{
Preimage
Type string
Source []byte
crystal []byte
}
func (t *trigger)Crystalize()[]byte{
if t.crystal==nil{
t.crystal=t.generate()
}
return copy(t.crystal)
}
type Sendable interface{
GetRecipient()*id.ID
GetPayload()[]byte
GetMac()[]byte
GetFingerprint()format.Fingerprint
GetTriggerPreimage()PreimagePrefix
}
type Trigger interface{
GetPreimage()[]byte
GetSource()format.Fingerprint
GetType()string
Crystalize()[]byte
}
// SendCMIX sends a "raw" CMIX message payload to the provided recipient.
// Returns the round ID of the round the payload was sent or an error
// if it fails.
func (m *manager) SendCMIX(msg format.Message,
recipient *id.ID, cmixParams CMIXParams) (id.Round, ephemeral.Id, error) {
func (m *manager) SendCMIX(message Sendable, cmixParams CMIXParams) (id.Round, ephemeral.Id, error) {
if !m.Monitor.IsHealthy() {
return 0, ephemeral.Id{}, errors.New("Cannot send cmix message when the " +
"network is not healthy")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment