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

added guard mechanisism on session partenr IDs in order

to get more information on an error we saw where ids got merged after
a hard crash. Also convereted a spammy print to debug and added
prints of core user information
parent 243ef5d7
No related branches found
No related tags found
No related merge requests found
......@@ -205,11 +205,14 @@ func Login(storageDir string, password []byte, parameters params.Network) (*Clie
//Open the client
c, err := OpenClient(storageDir, password, parameters)
if err != nil {
return nil, err
}
u := c.storage.GetUser()
jww.INFO.Printf("Client Logged in: \n\tTransmisstionID: %s " +
"\n\tReceptionID: %s", u.TransmissionID, u.ReceptionID)
//Attach the services interface
c.services = newServiceProcessiesList(c.runner)
......@@ -388,7 +391,9 @@ func (c *Client) initPermissioning(def *ndf.NetworkDefinition) error {
// - Auth Callback (/auth/callback.go)
// Handles both auth confirm and requests
func (c *Client) StartNetworkFollower() (<-chan interfaces.ClientError, error) {
jww.INFO.Printf("StartNetworkFollower()")
u := c.GetUser()
jww.INFO.Printf("StartNetworkFollower() \n\tTransmisstionID: %s " +
"\n\tReceptionID: %s", u.TransmissionID, u.ReceptionID)
c.clientErrorChannel = make(chan interfaces.ClientError, 1000)
......
......@@ -262,7 +262,7 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source,
_, changed := identity.ER.Set(earliestRemaining)
if changed{
jww.TRACE.Printf("External returns of RangeUnchecked: %d, %v, %v", earliestRemaining, roundsWithMessages, roundsUnknown)
jww.INFO.Printf("New Earliest Remaining: %d", earliestRemaining)
jww.DEBUG.Printf("New Earliest Remaining: %d", earliestRemaining)
}
roundsWithMessages2 := identity.UR.Iterate(func(rid id.Round)bool{
......
......@@ -159,8 +159,7 @@ func (m *Manager) GetKeyForSending(st params.SendType) (*Key, error) {
// GetPartnerID returns a copy of the ID of the partner.
func (m *Manager) GetPartnerID() *id.ID {
p := m.partner
return p
return m.partner.DeepCopy()
}
// GetSendSession gets the Send session of the passed ID. Returns nil if no
......
......@@ -37,6 +37,8 @@ type Session struct {
//params
e2eParams params.E2ESessionParams
partner *id.ID
//type
t RelationshipType
......@@ -92,6 +94,8 @@ type SessionDisk struct {
// Number of keys usable before rekey
RekeyThreshold uint32
Partner []byte
}
/*CONSTRUCTORS*/
......@@ -115,6 +119,7 @@ func newSession(ship *relationship, t RelationshipType, myPrivKey, partnerPubKey
relationshipFingerprint: relationshipFingerprint,
negotiationStatus: negotiationStatus,
partnerSource: trigger,
partner: ship.manager.partner.DeepCopy(),
}
session.kv = session.generate(ship.kv)
......@@ -168,6 +173,11 @@ func loadSession(ship *relationship, kv *versioned.KV,
}
session.relationshipFingerprint = relationshipFingerprint
if !session.partner.Cmp(ship.manager.partner){
return nil, errors.Errorf("Stored partner (%s) did not match " +
"relationship partner (%s)", session.partner, ship.manager.partner)
}
return &session, nil
}
......@@ -262,7 +272,7 @@ func (s *Session) GetID() SessionID {
// returns the ID of the partner for this session
func (s *Session) GetPartner() *id.ID {
if s.relationship != nil {
return s.relationship.manager.partner
return s.relationship.manager.partner.DeepCopy()
} else {
return nil
}
......@@ -279,6 +289,7 @@ func (s *Session) marshal() ([]byte, error) {
sd.PartnerPubKey = s.partnerPubKey.Bytes()
sd.Trigger = s.partnerSource[:]
sd.RelationshipFingerprint = s.relationshipFingerprint
sd.Partner = s.partner.Bytes()
// assume in progress confirmations and session creations have failed on
// reset, therefore do not store their pending progress
......@@ -315,6 +326,7 @@ func (s *Session) unmarshal(b []byte) error {
s.negotiationStatus = Negotiation(sd.Confirmation)
s.rekeyThreshold = sd.RekeyThreshold
s.relationshipFingerprint = sd.RelationshipFingerprint
s.partner, _ = id.Unmarshal(sd.Partner)
copy(s.partnerSource[:], sd.Trigger)
s.keyState, err = loadStateVector(s.kv, "")
......
......@@ -630,6 +630,7 @@ func makeTestSession() (*Session, *context) {
manager: &Manager{
ctx: ctx,
kv: kv,
partner: &id.ID{},
},
kv: kv,
},
......@@ -637,6 +638,7 @@ func makeTestSession() (*Session, *context) {
t: Receive,
negotiationStatus: Confirmed,
rekeyThreshold: 5,
partner: &id.ID{},
}
var err error
s.keyState, err = newStateVector(s.kv,
......
......@@ -258,6 +258,12 @@ func (s *Store) unmarshal(b []byte) error {
&partnerID, err.Error())
}
if !manager.GetPartnerID().Cmp(&partnerID){
jww.FATAL.Panicf("Loaded a manager with the wrong partner " +
"ID: \n\t loaded: %s \n\t present: %s",
&partnerID, manager.GetPartnerID())
}
s.managers[partnerID] = manager
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment