Dont refresh session keys on bootloader requests

This commit is contained in:
Ken-Håvard Lieng 2018-11-08 08:39:47 +01:00
parent f86e0d9283
commit 70b2c4df47
4 changed files with 23 additions and 27 deletions

View file

@ -69,29 +69,25 @@ func (s *Session) Expired() bool {
return time.Since(created) > Expiration
}
func (s *Session) Refresh() (string, bool, error) {
func (s *Session) Refresh() (string, error) {
s.lock.Lock()
created := time.Unix(s.createdAt, 0)
s.lock.Unlock()
if time.Since(created) > Expiration {
return "", true, nil
}
if time.Since(created) > RefreshInterval {
key, err := newSessionKey()
if err != nil {
return "", false, err
return "", err
}
s.lock.Lock()
s.createdAt = time.Now().Unix()
s.key = key
s.lock.Unlock()
return key, false, nil
return key, nil
}
return "", false, nil
return "", nil
}
func newSessionKey() (string, error) {