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

New handler interface WIP

parent 7eb68b7e
No related branches found
No related tags found
4 merge requests!510Release,!207WIP: Client Restructure,!203Symmetric broadcast,!187Xx 3829/triggers
...@@ -161,3 +161,137 @@ func (m *Manager) handleMessage(ecrMsg format.Message, bundle Bundle, edge *edge ...@@ -161,3 +161,137 @@ func (m *Manager) handleMessage(ecrMsg format.Message, bundle Bundle, edge *edge
} }
} }
} }
func (m *Manager) handleMessage2(ecrMsg format.Message, bundle Bundle) {
fingerprint := ecrMsg.GetKeyFP()
msgDigest := ecrMsg.Digest()
identity := bundle.Identity
round := bundle.RoundInfo
newID := // todo use new id systme from ticket
{
ID id.ID
ephID ephemeral.Id
}
// If we have a fingerprint, process it.
messageProc, exists := m.fingerprints.Pop(fingerprint) {
// note scope here is all broken, fix...
m.fingers.Lock()
defer m.fingersUnlock()
mp, ok := m.fingers[fingerprint]
if ok {
mp.MarkFingerprintUsed(fingerprint)
delete(m.fingers, fingerprint)
return mp, true
}
return nil, false
}
if exists {
// in progress is a future project.
// m.inprogress.Add({fingerprint, ecrMsg, newID, round})
go messageProc.Process(ecrMsg, newID, round)
return
}
triggerProc, trigger, exists := m.triggers.Lookup(
ecrMsg.GetIdentityFP(), ecrMsgContents)
if exists {
go triggerProc.Process(ecrMsg, newID, round, trigger)
return
} 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(),
// ecrMsgContents, preimage.MakeDefault(identity.Source))
}
if jww.GetLogThreshold() == jww.LevelTrace {
expectedFP := fingerprint2.IdentityFP(ecrMsgContents,
preimage.MakeDefault(identity.Source))
jww.TRACE.Printf("Message for %d (%s) failed identity "+
"check: %v (expected-default) vs %v (received)",
identity.EphId,
identity.Source, expectedFP, ecrMsg.GetIdentityFP())
}
im := fmt.Sprintf("Garbled/RAW Message: keyFP: %v, round: %d"+
"msgDigest: %s, not determined to be for client", ecrMsg.GetKeyFP(), bundle.Round, ecrMsg.Digest())
m.Internal.Events.Report(1, "MessageReception", "Garbled", im)
m.Session.GetGarbledMessages().Add(ecrMsg)
}
func (m *Manager) handleMessage2(ecrMsg format.Message, bundle Bundle) {
fingerprint := ecrMsg.GetKeyFP()
msgDigest := ecrMsg.Digest()
identity := bundle.Identity
round := bundle.RoundInfo
newID := // todo use new id systme from ticket
{
ID id.ID
ephID ephemeral.Id
}
fpLock := m.getFPLock(fingerprint) {
m.superLock.Lock()
defer m.superLock.Unlock()
fpLock, ok := m.fpLocks[fingerprint]
if !ok {
m.fpLocks[fingerprint] = &sync.Mutex{}
return m.fpLocks[fingerprint]
}
}
fpLock.Lock()
// If we have a fingerprint, process it.
messageProc, exists := m.fingerprints.Lookup(fingerprint)// {
// // note scope here is all broken, fix...
// m.fingers.Lock()
// defer m.fingersUnlock()
// mp, ok := m.fingers[fingerprint]
// if ok {
// mp.MarkFingerprintUsed(fingerprint)
// delete(m.fingers, fingerprint)
// return mp, true
// }
// return nil, false
// }
if exists {
// in progress is a future project.
// m.inprogress.Add({fingerprint, ecrMsg, newID, round})
m.fingerprints.Delete(fingerprint)
messageProc.Process(ecrMsg, newID, round)
messageProc.MarkUsed(fingerprint)
fpLock.Unlock()
// delete from fpLocks as well.
return
}
triggerProc, trigger, exists := m.triggers.Lookup(
ecrMsg.GetIdentityFP(), ecrMsgContents)
if exists {
go triggerProc.Process(ecrMsg, newID, round, trigger)
return
} 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(),
// ecrMsgContents, preimage.MakeDefault(identity.Source))
}
if jww.GetLogThreshold() == jww.LevelTrace {
expectedFP := fingerprint2.IdentityFP(ecrMsgContents,
preimage.MakeDefault(identity.Source))
jww.TRACE.Printf("Message for %d (%s) failed identity "+
"check: %v (expected-default) vs %v (received)",
identity.EphId,
identity.Source, expectedFP, ecrMsg.GetIdentityFP())
}
im := fmt.Sprintf("Garbled/RAW Message: keyFP: %v, round: %d"+
"msgDigest: %s, not determined to be for client", ecrMsg.GetKeyFP(), bundle.Round, ecrMsg.Digest())
m.Internal.Events.Report(1, "MessageReception", "Garbled", im)
m.Session.GetGarbledMessages().Add(ecrMsg)
}
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