Commit message (Collapse) | Author | Age | Files | Lines | |
---|---|---|---|---|---|
* | ratelimiter: use a fake clock in tests and style cleanups | David Crawshaw | 2020-03-30 | 1 | -46/+53 |
| | | | | | | | | | | | | | | | | | | | | | | The existing test would occasionally flake out with: --- FAIL: TestRatelimiter (0.12s) ratelimiter_test.go:99: Test failed for 127.0.0.1 , on: 7 ( not having refilled enough ) expected: false got: true FAIL FAIL golang.zx2c4.com/wireguard/ratelimiter 0.171s The fake clock also means the tests run much faster, so testing this package with -count=1000 now takes < 100ms. While here, several style cleanups. The most significant one is unembeding the sync.Mutex fields in the rate limiter objects. Embedded as they were, the lock methods were accessible outside the ratelimiter package. As they aren't needed externally, keep them internal to make them easier to reason about. Passes `go test -race -count=10000 ./ratelimiter` Signed-off-by: David Crawshaw <crawshaw@tailscale.com> | ||||
* | device, ratelimiter: replace uses of time.Now().Sub() with time.Since() | Matt Layher | 2019-06-03 | 1 | -2/+2 |
| | | | | | | | | | | | | | | | | | | | | | | | Simplification found by staticcheck: $ staticcheck ./... | grep S1012 device/cookie.go:90:5: should use time.Since instead of time.Now().Sub (S1012) device/cookie.go:127:5: should use time.Since instead of time.Now().Sub (S1012) device/cookie.go:242:5: should use time.Since instead of time.Now().Sub (S1012) device/noise-protocol.go:304:13: should use time.Since instead of time.Now().Sub (S1012) device/receive.go:82:46: should use time.Since instead of time.Now().Sub (S1012) device/send.go:132:5: should use time.Since instead of time.Now().Sub (S1012) device/send.go:139:5: should use time.Since instead of time.Now().Sub (S1012) device/send.go:235:59: should use time.Since instead of time.Now().Sub (S1012) device/send.go:393:9: should use time.Since instead of time.Now().Sub (S1012) ratelimiter/ratelimiter.go:79:10: should use time.Since instead of time.Now().Sub (S1012) ratelimiter/ratelimiter.go:87:10: should use time.Since instead of time.Now().Sub (S1012) Change applied using: $ find . -type f -name "*.go" -exec sed -i "s/Now().Sub(/Since(/g" {} \; Signed-off-by: Matt Layher <mdlayher@gmail.com> | ||||
* | Extend structs rather than embed, when possible | Jason A. Donenfeld | 2019-02-05 | 1 | -19/+19 |
| | |||||
* | Update copyright | Jason A. Donenfeld | 2019-02-05 | 1 | -2/+2 |
| | |||||
* | global: fix up copyright headers | Jason A. Donenfeld | 2018-09-16 | 1 | -1/+1 |
| | |||||
* | ratelimiter: do not run GC with nothing to do | Jason A. Donenfeld | 2018-05-21 | 1 | -8/+23 |
| | |||||
* | Cleanup ratelimiter | Jason A. Donenfeld | 2018-05-13 | 1 | -12/+12 |
| | |||||
* | global: Add SPDX tags and copyright header | Jason A. Donenfeld | 2018-05-03 | 1 | -4/+5 |
| | | | | Mathias should probably add his copyright headers to each file too. | ||||
* | Use relative imports | Jason A. Donenfeld | 2018-02-12 | 1 | -0/+149 |