watchtower: add forceNext to NextSessionKeyIndex

This commit adds a forceNext boolean parameter to NextSessionKeyIndex.
Setting this param to true will force the index to cycle over 1000 key
indices before returning the new key.
This commit is contained in:
Elle Mouton committed 2023-03-31 12:04:57 +02:00
1 parent 204585c620
commit 24016c35c7
5 files changed
+81 -39

No files matched your search

+2 -2
View File
@@ -49,8 +49,8 @@ type DB interface {
// (tower, blob type) pair until CreateClientSession is invoked for that
// tower and index, at which point a new index for that tower can be
// reserved. Multiple calls to this method before CreateClientSession is
// invoked should return the same index.
NextSessionKeyIndex(wtdb.TowerID, blob.Type) (uint32, error)
// invoked should return the same index unless forceNext is true.
NextSessionKeyIndex(wtdb.TowerID, blob.Type, bool) (uint32, error)
// CreateClientSession saves a newly negotiated client session to the
// client's database. This enables the session to be used across
+1 -1
View File
@@ -306,7 +306,7 @@ retryWithBackoff:
// with this specific tower. If one is already reserved, the
// existing index will be returned.
keyIndex, err := n.cfg.DB.NextSessionKeyIndex(
tower.ID, n.cfg.Policy.BlobType,
tower.ID, n.cfg.Policy.BlobType, false,
)
if err != nil {
n.log.Debugf("Unable to reserve session key index "+