Skip to content
Snippets Groups Projects
Commit b6703ca8 authored by David Stainton's avatar David Stainton
Browse files

Fix client channel id registration

parent 4baadef6
No related branches found
No related tags found
6 merge requests!510Release,!419rewrote the health tracker to both consider if there are waiting rounds and...,!371[Channel RSAtoPrivate] Implement Reverse Asymmetric in Client/Broadcast,!354Channels impl,!340Project/channels,!338Xx 4055/channel identity tracking
...@@ -59,6 +59,7 @@ func saveRegistrationDisk(kv *versioned.KV, reg registrationDisk) error { ...@@ -59,6 +59,7 @@ func saveRegistrationDisk(kv *versioned.KV, reg registrationDisk) error {
type registrationDisk struct { type registrationDisk struct {
rwmutex sync.RWMutex rwmutex sync.RWMutex
Registered bool
PublicKey ed25519.PublicKey PublicKey ed25519.PublicKey
PrivateKey ed25519.PrivateKey PrivateKey ed25519.PrivateKey
Lease int64 Lease int64
...@@ -76,12 +77,20 @@ func newRegistrationDisk(publicKey ed25519.PublicKey, privateKey ed25519.Private ...@@ -76,12 +77,20 @@ func newRegistrationDisk(publicKey ed25519.PublicKey, privateKey ed25519.Private
} }
} }
func (r registrationDisk) IsRegistered() bool {
r.rwmutex.RLock()
defer r.rwmutex.RUnlock()
return r.Registered
}
// Update updates the registrationDisk that is currently // Update updates the registrationDisk that is currently
// stored on the kv with a new lease and lease signature. // stored on the kv with a new lease and lease signature.
func (r registrationDisk) Update(lease int64, signature []byte) { func (r registrationDisk) Update(lease int64, signature []byte) {
r.rwmutex.Lock() r.rwmutex.Lock()
defer r.rwmutex.Unlock() defer r.rwmutex.Unlock()
r.Registered = true
r.Lease = lease r.Lease = lease
r.Signature = signature r.Signature = signature
} }
...@@ -182,12 +191,15 @@ func newclientIDTracker(comms channelLeaseComms, host *connect.Host, username st ...@@ -182,12 +191,15 @@ func newclientIDTracker(comms channelLeaseComms, host *connect.Host, username st
if err != nil { if err != nil {
jww.FATAL.Panic(err) jww.FATAL.Panic(err)
} }
} else if err != nil {
jww.FATAL.Panic(err)
}
if !reg.IsRegistered() {
err = c.register() err = c.register()
if err != nil { if err != nil {
jww.FATAL.Panic(err) jww.FATAL.Panic(err)
} }
} else if err != nil {
jww.FATAL.Panic(err)
} }
c := &clientIDTracker{ c := &clientIDTracker{
......
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