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

Add stringer interface for message processors. SendUnsafe and precan E2E are now working

parent 3b99642b
No related branches found
No related tags found
3 merge requests!510Release,!207WIP: Client Restructure,!203Symmetric broadcast
...@@ -3,6 +3,7 @@ package auth ...@@ -3,6 +3,7 @@ package auth
import ( import (
"encoding/base64" "encoding/base64"
"fmt" "fmt"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/auth/store" "gitlab.com/elixxir/client/auth/store"
"gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/identity/receptionID"
...@@ -109,3 +110,9 @@ func (rcs *receivedConfirmService) Process(msg format.Message, ...@@ -109,3 +110,9 @@ func (rcs *receivedConfirmService) Process(msg format.Message,
} }
state.callbacks.Confirm(c, receptionID, round) state.callbacks.Confirm(c, receptionID, round)
} }
func (rcs *receivedConfirmService) String() string {
return fmt.Sprintf("authConfirm(%s, %s, %s)",
rcs.s.e2e.GetReceptionID(), rcs.GetPartner(),
rcs.GetFingerprint())
}
...@@ -3,6 +3,8 @@ package auth ...@@ -3,6 +3,8 @@ package auth
import ( import (
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"strings"
"github.com/cloudflare/circl/dh/sidh" "github.com/cloudflare/circl/dh/sidh"
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
...@@ -15,7 +17,6 @@ import ( ...@@ -15,7 +17,6 @@ import (
"gitlab.com/elixxir/primitives/fact" "gitlab.com/elixxir/primitives/fact"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"strings"
) )
const dummyerr = "dummy error so we dont delete the request" const dummyerr = "dummy error so we dont delete the request"
...@@ -248,6 +249,11 @@ func (rrs *receivedRequestService) Process(message format.Message, ...@@ -248,6 +249,11 @@ func (rrs *receivedRequestService) Process(message format.Message,
} }
} }
func (rrs *receivedRequestService) String() string {
return fmt.Sprintf("authRequest(%s)",
rrs.s.e2e.GetReceptionID())
}
func processDecryptedMessage(b []byte) (*id.ID, *sidh.PublicKey, fact.FactList, func processDecryptedMessage(b []byte) (*id.ID, *sidh.PublicKey, fact.FactList,
[]byte, error) { []byte, error) {
//decode the ecr format //decode the ecr format
......
...@@ -74,7 +74,7 @@ func (a *authCallbacks) Reset(requestor contact.Contact, ...@@ -74,7 +74,7 @@ func (a *authCallbacks) Reset(requestor contact.Contact,
func registerMessageListener(client *api.Client) chan receive.Message { func registerMessageListener(client *api.Client) chan receive.Message {
recvCh := make(chan receive.Message, 10000) recvCh := make(chan receive.Message, 10000)
listenerID := client.RegisterListenerChannel("DefaultCLIReceiver", listenerID := client.RegisterListenerChannel("DefaultCLIReceiver",
receive.AnyUser(), catalog.XxMessage, recvCh) receive.AnyUser(), catalog.NoType, recvCh)
jww.INFO.Printf("Message ListenerID: %v", listenerID) jww.INFO.Printf("Message ListenerID: %v", listenerID)
return recvCh return recvCh
} }
...@@ -211,6 +211,7 @@ var rootCmd = &cobra.Command{ ...@@ -211,6 +211,7 @@ var rootCmd = &cobra.Command{
recipientContact = user.GetContact() recipientContact = user.GetContact()
} }
client.GetE2EHandler().EnableUnsafeReception()
recvCh := registerMessageListener(client) recvCh := registerMessageListener(client)
err := client.StartNetworkFollower(5 * time.Second) err := client.StartNetworkFollower(5 * time.Second)
......
...@@ -9,11 +9,12 @@ package message ...@@ -9,11 +9,12 @@ package message
import ( import (
"fmt" "fmt"
"sync"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/stoppable" "gitlab.com/elixxir/client/stoppable"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
"gitlab.com/xx_network/primitives/netTime" "gitlab.com/xx_network/primitives/netTime"
"sync"
) )
func (p *handler) handleMessages(stop *stoppable.Single) { func (p *handler) handleMessages(stop *stoppable.Single) {
...@@ -28,6 +29,8 @@ func (p *handler) handleMessages(stop *stoppable.Single) { ...@@ -28,6 +29,8 @@ func (p *handler) handleMessages(stop *stoppable.Single) {
wg.Add(len(bundle.Messages)) wg.Add(len(bundle.Messages))
for i := range bundle.Messages { for i := range bundle.Messages {
msg := bundle.Messages[i] msg := bundle.Messages[i]
jww.TRACE.Printf("handle IterMsgs: %s",
msg.Digest())
go func() { go func() {
count, ts := p.inProcess.Add( count, ts := p.inProcess.Add(
...@@ -68,8 +71,12 @@ func (p *handler) handleMessage(ecrMsg format.Message, bundle Bundle) bool { ...@@ -68,8 +71,12 @@ func (p *handler) handleMessage(ecrMsg format.Message, bundle Bundle) bool {
identity := bundle.Identity identity := bundle.Identity
round := bundle.RoundInfo round := bundle.RoundInfo
jww.INFO.Printf("handleMessage(%s)", ecrMsg.Digest())
// If we have a fingerprint, process it // If we have a fingerprint, process it
if proc, exists := p.pop(identity.Source, fingerprint); exists { if proc, exists := p.pop(identity.Source, fingerprint); exists {
jww.DEBUG.Printf("handleMessage found fingerprint: %s",
ecrMsg.Digest())
proc.Process(ecrMsg, identity, round) proc.Process(ecrMsg, identity, round)
return true return true
} }
...@@ -78,6 +85,8 @@ func (p *handler) handleMessage(ecrMsg format.Message, bundle Bundle) bool { ...@@ -78,6 +85,8 @@ func (p *handler) handleMessage(ecrMsg format.Message, bundle Bundle) bool {
identity.Source, ecrMsg.GetSIH(), ecrMsg.GetContents()) identity.Source, ecrMsg.GetSIH(), ecrMsg.GetContents())
if exists { if exists {
for _, t := range services { for _, t := range services {
jww.DEBUG.Printf("handleMessage service found: %s, %s",
ecrMsg.Digest(), t)
go t.Process(ecrMsg, identity, round) go t.Process(ecrMsg, identity, round)
} }
if len(services) == 0 { if len(services) == 0 {
......
package message package message
import ( import (
"gitlab.com/elixxir/client/cmix/rounds" "fmt"
"gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
) )
...@@ -16,4 +18,7 @@ type Processor interface { ...@@ -16,4 +18,7 @@ type Processor interface {
// and can lead to compromise of message contents and integrity. // and can lead to compromise of message contents and integrity.
Process(message format.Message, receptionID receptionID.EphemeralIdentity, Process(message format.Message, receptionID receptionID.EphemeralIdentity,
round rounds.Round) round rounds.Round)
// Implement the stringer interface String() string for debugging
fmt.Stringer
} }
...@@ -78,25 +78,32 @@ func (sm *ServicesManager) get(clientID *id.ID, receivedSIH, ...@@ -78,25 +78,32 @@ func (sm *ServicesManager) get(clientID *id.ID, receivedSIH,
if !exists { if !exists {
return nil, false return nil, false
} }
// NOTE: We exit on the first service match
for _, s := range services { for _, s := range services {
// Check if the SIH matches this service // Check if the SIH matches this service
if s.ForMe(ecrMsgContents, receivedSIH) { if s.ForMe(ecrMsgContents, receivedSIH) {
if s.defaultList == nil && s.Tag != sih.Default { if s.defaultList == nil && s.Tag != sih.Default {
//skip if the processor is nil //skip if the processor is nil
if s.Processor != nil { if s.Processor == nil {
jww.ERROR.Printf("<nil> processor: %s",
s.Tag)
return []Processor{}, true return []Processor{}, true
} }
// Return this service directly if not the default service // Return this service directly if not
// the default service
return []Processor{s}, true return []Processor{s}, true
} else if s.defaultList != nil { } else if s.defaultList != nil {
// If it is default and the default list is not empty, then // If it is default and the default
// return the default list // list is not empty, then return the
// default list
return s.defaultList, true return s.defaultList, true
} }
// Return false if it is for me, but I have nothing registered to // Return false if it is for me, but I have
// respond to default queries // nothing registered to respond to default
// queries
return []Processor{}, false return []Processor{}, false
} }
} }
...@@ -198,3 +205,7 @@ func (sm *ServicesManager) DeleteClientService(clientID *id.ID) { ...@@ -198,3 +205,7 @@ func (sm *ServicesManager) DeleteClientService(clientID *id.ID) {
delete(sm.tmap, *clientID) delete(sm.tmap, *clientID)
} }
func (s service) String() string {
return s.Service.String()
}
package e2e package e2e
import ( import (
"fmt"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/e2e/ratchet/partner/session" "gitlab.com/elixxir/client/e2e/ratchet/partner/session"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
) )
...@@ -37,3 +39,8 @@ func (p *processor) Process(ecrMsg format.Message, ...@@ -37,3 +39,8 @@ func (p *processor) Process(ecrMsg format.Message,
p.m.Switchboard.Speak(message) p.m.Switchboard.Speak(message)
} }
} }
func (p *processor) String() string {
return fmt.Sprintf("E2E(%s): %s",
p.m.myID, p.cy.GetSession())
}
...@@ -62,6 +62,9 @@ func (m *manager) sendUnsafe(mt catalog.MessageType, recipient *id.ID, ...@@ -62,6 +62,9 @@ func (m *manager) sendUnsafe(mt catalog.MessageType, recipient *id.ID,
unencryptedMAC, fp := e2e.SetUnencrypted(payload, unencryptedMAC, fp := e2e.SetUnencrypted(payload,
m.myID) m.myID)
jww.TRACE.Printf("sendUnsafe contents: %v, fp: %v, mac: %v",
payload, fp, unencryptedMAC)
var err error var err error
roundIds[i], _, err = m.net.Send(recipient, fp, roundIds[i], _, err = m.net.Send(recipient, fp,
srvc, payload, unencryptedMAC, srvc, payload, unencryptedMAC,
......
package e2e package e2e
import ( import (
"fmt"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/crypto/e2e" "gitlab.com/elixxir/crypto/e2e"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
) )
...@@ -17,7 +19,14 @@ func (up *UnsafeProcessor) Process(ecrMsg format.Message, ...@@ -17,7 +19,14 @@ func (up *UnsafeProcessor) Process(ecrMsg format.Message,
receptionID receptionID.EphemeralIdentity, receptionID receptionID.EphemeralIdentity,
round rounds.Round) { round rounds.Round) {
//check if the message is unencrypted //check if the message is unencrypted
jww.INFO.Printf("Unsafe PRocessed received: contents: %v, fp: %v, mac: %v, sih: %v",
ecrMsg.GetContents(), ecrMsg.GetKeyFP(), ecrMsg.GetMac(), ecrMsg.GetSIH())
unencrypted, sender := e2e.IsUnencrypted(ecrMsg) unencrypted, sender := e2e.IsUnencrypted(ecrMsg)
if !unencrypted && sender == nil {
jww.ERROR.Printf("unencrypted message failed MAC check: %v",
ecrMsg)
return
}
if !unencrypted { if !unencrypted {
jww.ERROR.Printf("Received a non unencrypted message in e2e "+ jww.ERROR.Printf("Received a non unencrypted message in e2e "+
"service %s, A message might have dropped!", up.tag) "service %s, A message might have dropped!", up.tag)
...@@ -35,3 +44,7 @@ func (up *UnsafeProcessor) Process(ecrMsg format.Message, ...@@ -35,3 +44,7 @@ func (up *UnsafeProcessor) Process(ecrMsg format.Message,
up.m.Switchboard.Speak(message) up.m.Switchboard.Speak(message)
} }
} }
func (up *UnsafeProcessor) String() string {
return fmt.Sprintf("Unsafe(%s)", up.m.myID)
}
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
package fileTransfer package fileTransfer
import ( import (
"fmt"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/rounds" "gitlab.com/elixxir/client/cmix/rounds"
...@@ -62,3 +64,7 @@ func (p *processor) Process(msg format.Message, ...@@ -62,3 +64,7 @@ func (p *processor) Process(msg format.Message,
// Call callback with updates // Call callback with updates
p.callbacks.Call(p.TransferID(), nil) p.callbacks.Call(p.TransferID(), nil)
} }
func (p *processor) String() string {
return fmt.Sprintf("FileTransfer(%s)", p.myID)
}
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
package groupChat package groupChat
import ( import (
"fmt"
"time"
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/identity/receptionID"
...@@ -16,7 +19,6 @@ import ( ...@@ -16,7 +19,6 @@ import (
"gitlab.com/elixxir/crypto/group" "gitlab.com/elixxir/crypto/group"
"gitlab.com/elixxir/primitives/format" "gitlab.com/elixxir/primitives/format"
"gitlab.com/elixxir/primitives/states" "gitlab.com/elixxir/primitives/states"
"time"
) )
// Error messages. // Error messages.
...@@ -77,6 +79,10 @@ func (p *receptionProcessor) Process(message format.Message, receptionID recepti ...@@ -77,6 +79,10 @@ func (p *receptionProcessor) Process(message format.Message, receptionID recepti
p.m.receiveFunc(result) p.m.receiveFunc(result)
} }
func (p *receptionProcessor) String() string {
return fmt.Sprintf("GroupChatReception(%s)", p.m.receptionId)
}
// decryptMessage decrypts the group message payload and returns its message ID, // decryptMessage decrypts the group message payload and returns its message ID,
// timestamp, sender ID, and message contents. // timestamp, sender ID, and message contents.
func decryptMessage(g gs.Group, fingerprint format.Fingerprint, key group.CryptKey, payload []byte) ( func decryptMessage(g gs.Group, fingerprint format.Fingerprint, key group.CryptKey, payload []byte) (
......
package single package single
import ( import (
"fmt"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix" "gitlab.com/elixxir/client/cmix"
"gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/identity/receptionID"
...@@ -119,3 +121,7 @@ func (l *listener) Stop() { ...@@ -119,3 +121,7 @@ func (l *listener) Stop() {
} }
l.net.DeleteService(l.myId, svc, l) l.net.DeleteService(l.myId, svc, l)
} }
func (l *listener) String() string {
return fmt.Sprintf("SingleUse(%s)", l.myId)
}
package single package single
import ( import (
"fmt"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/identity/receptionID"
"gitlab.com/elixxir/client/cmix/rounds" "gitlab.com/elixxir/client/cmix/rounds"
...@@ -48,3 +50,8 @@ func (rsp *responseProcessor) Process(ecrMsg format.Message, ...@@ -48,3 +50,8 @@ func (rsp *responseProcessor) Process(ecrMsg format.Message,
rsp.callback(payload, receptionID, round, nil) rsp.callback(payload, receptionID, round, nil)
} }
} }
func (rsp *responseProcessor) String() string {
return fmt.Sprintf("SingleUseFP(%s, %s)",
rsp.sendingID, rsp.recipient.ID)
}
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