aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-01-17 19:56:15 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-01-17 19:56:15 +0100
commite8b957b1de8a148d8b4ab8dfbf76722ba757e0aa (patch)
treed5a70cf748e681b064cad97a84c007e88a363b09
parentb55706fa1fc947ab798016dcbedf09d3c063e5cb (diff)
Limit nonces
-rw-r--r--provider.go10
1 files changed, 3 insertions, 7 deletions
diff --git a/provider.go b/provider.go
index ef7d85a..413b828 100644
--- a/provider.go
+++ b/provider.go
@@ -37,20 +37,16 @@ func (p Provider) Nonce() (string, error) {
}
func (p Provider) nonce(resp *http.Response) {
- if rn := resp.Header.Get("Replay-Nonce"); rn != "" {
+ rn := resp.Header.Get("Replay-Nonce")
+ if rn != "" && len(p.nonces) < cap(p.nonces) {
p.nonces <- rn
}
- log.Println("# nonces", len(p.nonces))
- for len(p.nonces) > 10 {
- <-p.nonces
- }
- log.Println("# nonces", len(p.nonces))
}
// NewProvider fetches directory and initializes nonce
func NewProvider(directory string) (*Provider, error) {
p := &Provider{
- nonces: make(chan string, 100),
+ nonces: make(chan string, 10),
Client: http.Client{
Timeout: time.Duration(5 * time.Second),
},