Skip to content

Commit 595ecdf

Browse files
authored
Stricter rate-limits for many endpoints (#1043)
This PR assigns "unique" rate-limit settings to many game and API endpoints, making certain endpoints have stricter limits than others. Most of these settings are stored in their own classes so multiple endpoint classes could share them, and to organize them more clearly. Not all rate-limit settings are in their own classes yet. The global rate-limit is also slightly stricter for now. Not all settings are properly tested yet. Some may, in reality, be too strict or too loose; they are experimental.
2 parents 7f1b0e5 + e632277 commit 595ecdf

72 files changed

Lines changed: 757 additions & 44 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Refresh.Core.RateLimits.Activity;
2+
3+
public static class ActivityPageEndpointLimits
4+
{
5+
public const int TimeoutDuration = 300;
6+
public const int GameRequestAmount = 25;
7+
public const int ApiRequestAmount = 35;
8+
public const int BlockDuration = 240;
9+
public const string GameRequestBucket = "activity-game";
10+
public const string ApiRequestBucket = "activity-api";
11+
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Refresh.Core.RateLimits.Challenges;
2+
3+
public static class ChallengeListEndpointLimits
4+
{
5+
public const int TimeoutDuration = 420;
6+
public const int RequestAmount = 20;
7+
public const int BlockDuration = 300;
8+
public const string RequestBucket = "challenge-list";
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Refresh.Core.RateLimits.Challenges;
2+
3+
public static class ChallengeScoreListEndpointLimits
4+
{
5+
public const int TimeoutDuration = 420;
6+
public const int RequestAmount = 25;
7+
public const int BlockDuration = 300;
8+
public const string RequestBucket = "challenge-score-list";
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Refresh.Core.RateLimits.Challenges;
2+
3+
public static class ChallengeScoreUploadEndpointLimits
4+
{
5+
public const int TimeoutDuration = 420;
6+
public const int RequestAmount = 12;
7+
public const int BlockDuration = 300;
8+
public const string RequestBucket = "challenge-score-upload";
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Refresh.Core.RateLimits.Challenges;
2+
3+
public static class ChallengeSingleScoreEndpointLimits
4+
{
5+
public const int TimeoutDuration = 300;
6+
public const int RequestAmount = 16;
7+
public const int BlockDuration = 240;
8+
public const string RequestBucket = "challenge-single-score";
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Refresh.Core.RateLimits.Challenges;
2+
3+
public static class ChallengeUploadEndpointLimits
4+
{
5+
public const int TimeoutDuration = 420;
6+
public const int RequestAmount = 10;
7+
public const int BlockDuration = 300;
8+
public const string RequestBucket = "challenge-upload";
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Refresh.Core.RateLimits.Comments;
2+
3+
public static class CommentListEndpointLimits
4+
{
5+
public const int TimeoutDuration = 420;
6+
public const int RequestAmount = 40;
7+
public const int BlockDuration = 300;
8+
public const string RequestBucket = "comment-list";
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Refresh.Core.RateLimits.Comments;
2+
3+
public static class CommentUploadEndpointLimits
4+
{
5+
public const int TimeoutDuration = 420;
6+
public const int RequestAmount = 18;
7+
public const int BlockDuration = 300;
8+
public const string RequestBucket = "comment-upload";
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Refresh.Core.RateLimits.Comments;
2+
3+
public static class SingleCommentEndpointLimits
4+
{
5+
public const int TimeoutDuration = 420;
6+
public const int RequestAmount = 12;
7+
public const int BlockDuration = 300;
8+
public const string RequestBucket = "single-comment";
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Refresh.Core.RateLimits.Contests;
2+
3+
// treat getting one and getting a list as the same for now
4+
public static class ContestGetEndpointLimits
5+
{
6+
public const int TimeoutDuration = 420;
7+
public const int RequestAmount = 15;
8+
public const int BlockDuration = 300;
9+
public const string RequestBucket = "contests";
10+
}

0 commit comments

Comments
 (0)