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

Put auth processing inside a for loop

parent 2b6804b6
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/interfaces/contact"
"gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/stoppable"
"gitlab.com/elixxir/client/storage/auth"
"gitlab.com/elixxir/crypto/cyclic"
......@@ -25,47 +26,54 @@ import (
func (m *Manager) StartProcessies() stoppable.Stoppable {
stop := stoppable.NewSingle("Auth")
authStore := m.storage.Auth()
grp := m.storage.E2e().GetGroup()
go func() {
for {
select {
case <-stop.Quit():
return
case msg := <-m.rawMessages:
m.processAuthMessage(msg)
}
}
}()
return stop
}
func (m *Manager) processAuthMessage(msg message.Receive) {
authStore := m.storage.Auth()
//lookup the message, check if it is an auth request
cmixMsg := format.Unmarshal(msg.Payload)
fp := cmixMsg.GetKeyFP()
jww.INFO.Printf("RAW AUTH FP: %v", fp)
// this takes the request lock if it is a specific fp,
// all exits after this need to call fail or delete if it is
// this takes the request lock if it is a specific fp, all
// exits after this need to call fail or delete if it is
// specific
fpType, sr, myHistoricalPrivKey, err := authStore.GetFingerprint(fp)
if err != nil {
jww.TRACE.Printf("FINGERPRINT FAILURE: %s", err.Error())
// if the lookup fails, ignore the message. It is likely
// garbled or for a different protocol
break
// if the lookup fails, ignore the message. It is
// likely garbled or for a different protocol
return
}
//denote that the message is not garbled
m.storage.GetGarbledMessages().Remove(cmixMsg)
grp := m.storage.E2e().GetGroup()
switch fpType {
// if it is general, that means a new request has been received
case auth.General:
// if it is general, that means a new request has
// been received
m.handleRequest(cmixMsg, myHistoricalPrivKey, grp)
case auth.Specific:
// if it is specific, that means the original request was sent
// by this users and a confirmation has been received
case auth.Specific:
jww.INFO.Printf("Received AutConfirm from %s,"+
" msgDigest: %s", sr.GetPartner(), cmixMsg.Digest())
jww.INFO.Printf("Received AutConfirm from %s, msgDigest: %s",
sr.GetPartner(), cmixMsg.Digest())
m.handleConfirm(cmixMsg, sr, grp)
}
}
}()
return stop
}
func (m *Manager) handleRequest(cmixMsg format.Message,
myHistoricalPrivKey *cyclic.Int, grp *cyclic.Group) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment