Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/indexd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion cmd/indexd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading