diff options
author | Vladimir Shushlin <v.shushlin@gmail.com> | 2021-12-10 15:14:15 +0300 |
---|---|---|
committer | Vladimir Shushlin <v.shushlin@gmail.com> | 2022-01-11 12:21:44 +0300 |
commit | f62bc0dd08e3a9e14b6bf6c35b04dd6bdcec4491 (patch) | |
tree | 24274bdcd200d7490569415479996c9904a5739e /internal/config | |
parent | 2abb995aeb613f184ee0adebfcbd5597ee210169 (diff) |
feat: add domain rate-limiter
Changelog: added
Diffstat (limited to 'internal/config')
-rw-r--r-- | internal/config/config.go | 4 | ||||
-rw-r--r-- | internal/config/flags.go | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index c6f91db0..c29fa65d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -68,6 +68,8 @@ type General struct { type RateLimit struct { SourceIPLimitPerSecond float64 SourceIPBurst int + DomainLimitPerSecond float64 + DomainBurst int } // ArtifactsServer groups settings related to configuring Artifacts @@ -196,6 +198,8 @@ func loadConfig() (*Config, error) { RateLimit: RateLimit{ SourceIPLimitPerSecond: *rateLimitSourceIP, SourceIPBurst: *rateLimitSourceIPBurst, + DomainLimitPerSecond: *rateLimitDomain, + DomainBurst: *rateLimitDomainBurst, }, GitLab: GitLab{ ClientHTTPTimeout: *gitlabClientHTTPTimeout, diff --git a/internal/config/flags.go b/internal/config/flags.go index 6c9bd4a6..93228827 100644 --- a/internal/config/flags.go +++ b/internal/config/flags.go @@ -17,6 +17,8 @@ var ( pagesDomain = flag.String("pages-domain", "gitlab-example.com", "The domain to serve static pages") rateLimitSourceIP = flag.Float64("rate-limit-source-ip", 0.0, "Rate limit per source IP in number of requests per second, 0 means is disabled") rateLimitSourceIPBurst = flag.Int("rate-limit-source-ip-burst", 100, "Rate limit per source IP maximum burst allowed per second") + rateLimitDomain = flag.Float64("rate-limit-domain", 0.0, "Rate limit per domain in number of requests per second, 0 means is disabled") + rateLimitDomainBurst = flag.Int("rate-limit-domain-burst", 100, "Rate limit per domain maximum burst allowed per second") artifactsServer = flag.String("artifacts-server", "", "API URL to proxy artifact requests to, e.g.: 'https://gitlab.com/api/v4'") artifactsServerTimeout = flag.Int("artifacts-server-timeout", 10, "Timeout (in seconds) for a proxied request to the artifacts server") pagesStatus = flag.String("pages-status", "", "The url path for a status page, e.g., /@status") |