Skip to content

Commit

Permalink
add throttle_media_proxy
Browse files Browse the repository at this point in the history
thottle to 250 medias in 10 minutes, not just 30
  • Loading branch information
f2k1de committed Dec 20, 2024
1 parent 4b5a447 commit f0ecc31
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rec {
./mastodon/status_length_validator.patch
./mastodon/troet.patch
./mastodon/signup_message.patch
./mastodon/throttle_media_proxy.patch
];
};

Expand Down
13 changes: 13 additions & 0 deletions packages/mastodon/throttle_media_proxy.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb
index 8125b335f..00f533610 100644
--- a/config/initializers/rack_attack.rb
+++ b/config/initializers/rack_attack.rb
@@ -82,7 +82,7 @@ class Rack::Attack
req.authenticated_user_id if req.post? && req.path.match?(%r{\A/api/v\d+/media\z}i)
end

- throttle('throttle_media_proxy', limit: 30, period: 10.minutes) do |req|
+ throttle('throttle_media_proxy', limit: 250, period: 10.minutes) do |req|
req.throttleable_remote_ip if req.path.start_with?('/media_proxy')
end

0 comments on commit f0ecc31

Please sign in to comment.