aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoni Sawicki <tenox@google.com>2022-06-24 22:02:41 -0700
committerAntoni Sawicki <tenox@google.com>2022-06-24 22:02:41 -0700
commitb607b1282ccddbd4a589ec0693affa9fe9baa939 (patch)
tree0b750615338fa13ad1380d395765c5bbd2f483e8
parent4af21d88936f0dfa519e0889207ac02b052eeada (diff)
downloadwfm-b607b1282ccddbd4a589ec0693affa9fe9baa939.tar.gz
fix no rate limit bug
-rw-r--r--TODO.md3
-rw-r--r--wfm.go4
2 files changed, 6 insertions, 1 deletions
diff --git a/TODO.md b/TODO.md
index 63806a4..bdde170 100644
--- a/TODO.md
+++ b/TODO.md
@@ -21,6 +21,9 @@ https://github.com/crazcalm/go/commit/8b0b644cd02c59fe2461908304c44d64e8be431e
* use certmagic for acme? https://github.com/caddyserver/certmagic
* use lego for acme? https://github.com/go-acme/lego
* qps rate limiter
+ https://github.com/didip/tollbooth
+ https://github.com/uber-go/ratelimit
+ https://github.com/sethvargo/go-limiter
## Layout / UI
* add flag to specify own favicon.ico
diff --git a/wfm.go b/wfm.go
index d305d13..cf9edcd 100644
--- a/wfm.go
+++ b/wfm.go
@@ -159,7 +159,9 @@ func main() {
log.Printf("Setuid UID=%d GID=%d", os.Geteuid(), os.Getgid())
// rate limit setup
- rlBu = ratelimit.NewBucketWithRate(float64(*rateLim<<20), 1<<10)
+ if *rateLim != 0 {
+ rlBu = ratelimit.NewBucketWithRate(float64(*rateLim<<20), 1<<10)
+ }
// http stuff
mux := http.NewServeMux()