aboutsummaryrefslogtreecommitdiff
path: root/provider.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-01-20 15:21:55 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-01-20 15:21:55 +0100
commit20f2531b9acbe40e9f8ebda4f9127ab65530c789 (patch)
tree87ef39789e5d3eb05cd56e3daa7ff2e969c8da95 /provider.go
parent7b8ae538008c2efc8c75157f75efd1b3a1f8de78 (diff)
Rotate nonces
Diffstat (limited to 'provider.go')
-rw-r--r--provider.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/provider.go b/provider.go
index aecb39c..f154a2f 100644
--- a/provider.go
+++ b/provider.go
@@ -39,8 +39,10 @@ func (p Provider) RoundTrip(req *http.Request) (*http.Response, error) {
if err != nil {
return nil, err
}
- nonce := resp.Header.Get("Replay-Nonce")
- if nonce != "" && len(p.nonces) < cap(p.nonces) {
+ if nonce := resp.Header.Get("Replay-Nonce"); nonce != "" {
+ if len(p.nonces) == cap(p.nonces) {
+ <-p.nonces // drop oldest
+ }
p.nonces <- nonce
}
// not sure if it belongs here