diff --git a/cmd/indexd/main.go b/cmd/indexd/main.go index dc182c13e..2f98cd015 100644 --- a/cmd/indexd/main.go +++ b/cmd/indexd/main.go @@ -37,7 +37,8 @@ var cfg = config.Config{ Address: "127.0.0.1:9980", }, ApplicationAPI: config.ApplicationAPI{ - Address: ":9982", + Address: ":9982", + RateLimit: true, }, Syncer: config.Syncer{ Address: ":9981", diff --git a/cmd/indexd/run.go b/cmd/indexd/run.go index 029ecd1ee..9da013ed1 100644 --- a/cmd/indexd/run.go +++ b/cmd/indexd/run.go @@ -315,8 +315,10 @@ func runRootCmd(ctx context.Context, cfg config.Config, walletKey types.PrivateK appAPIOpts := []app.Option{ app.WithLogger(log.Named("api.application")), + } + if cfg.ApplicationAPI.RateLimit { // rate limit /auth/connect to 1 req/min with burst of 10, pruned after 10 minutes - app.WithRateLimiter(api.NewIPRateLimiter(time.Minute, 10, 10*time.Minute)), + appAPIOpts = append(appAPIOpts, app.WithRateLimiter(api.NewIPRateLimiter(time.Minute, 10, 10*time.Minute))) } advertiseURL := cfg.ApplicationAPI.AdvertiseURL diff --git a/config/config.go b/config/config.go index 36c2a50d5..4d50d6efe 100644 --- a/config/config.go +++ b/config/config.go @@ -27,6 +27,9 @@ type ( // the hostname that is valid for signed // requests. AdvertiseURL string `yaml:"advertiseURL"` + // RateLimit enables or disables the per-IP rate limiter + // on the /auth/connect endpoint. + RateLimit bool `yaml:"rateLimit"` } // Syncer contains the configuration for the p2p syncer.