diff options
| author | Tom DNetto <tom@tailscale.com> | 2022-09-15 11:49:23 -0700 |
|---|---|---|
| committer | Tom DNetto <tom@tailscale.com> | 2022-09-16 09:53:36 -0700 |
| commit | ea6c4d4fe17320c393e0f6a9c71ccae3b83ea28f (patch) | |
| tree | 61391d4f5fc070a2c4a0e761e48e99e9bdf96eed /cmd | |
| parent | cf61070e26b5756581be50275247f9d950bd0d0f (diff) | |
| download | tailscale-tom/iptables.tar.xz tailscale-tom/iptables.zip | |
cmd/derper,derp: implement per-client rate limitstom/iptables
Signed-off-by: Tom DNetto <tom@tailscale.com>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/derper/derper.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd/derper/derper.go b/cmd/derper/derper.go index f98b45375..07a38af9f 100644 --- a/cmd/derper/derper.go +++ b/cmd/derper/derper.go @@ -57,6 +57,11 @@ var ( acceptConnLimit = flag.Float64("accept-connection-limit", math.Inf(+1), "rate limit for accepting new connection") acceptConnBurst = flag.Int("accept-connection-burst", math.MaxInt, "burst limit for accepting new connection") + + egressInterface = flag.String("egress-interface", "", "the interface to monitor for automatic ratelimit tuning") + egressDataLimit = flag.Int("egress-data-limit", 100*1024*1024/8, "the bandwidth in bytes/s the server will try to stay under, only applies if egress-interface is set") + clientDataMin = flag.Int("client-data-min-limit", 1024*1024/8, "minimum bandwidth in bytes/s for a single client, only applies if egress-interface is set") + clientDataBurst = flag.Int("client-data-burst", 3*1024*1024, "burst limit in bytes for forwarded data from a single client, only applies if egress-interface is set") ) var ( @@ -154,6 +159,12 @@ func main() { s := derp.NewServer(cfg.PrivateKey, log.Printf) s.SetVerifyClient(*verifyClients) + if *egressInterface != "" && *egressDataLimit > 0 { + if err := s.StartEgressRateLimiter(*egressInterface, *egressDataLimit, *clientDataMin, *clientDataBurst); err != nil { + log.Fatalf("failed to start egress rate limiter: %v", err) + } + } + if *meshPSKFile != "" { b, err := ioutil.ReadFile(*meshPSKFile) if err != nil { |
