1
0
Fork 0
mirror of https://github.com/benbusby/farside.git synced 2025-06-21 16:56:37 +00:00

Update reddit + ig frontends, update rate limiting

Farside ratelimiting has been updated to return a 429 when a user
exceeds 1 request/sec. This should help eliminate a lot of scraping type
behavior that instance maintainers have been dealing with from Farside
lately.

Service changes:
- Teddit removed (not maintained)
- Bibliogram replaced by Proxigram
- Libreddit merged with redlib
This commit is contained in:
Ben Busby 2024-01-08 12:37:17 -07:00
commit 247114d328
No known key found for this signature in database
GPG key ID: B9B7231E01D924A1
5 changed files with 101 additions and 74 deletions

View file

@ -56,23 +56,21 @@ defmodule Farside.Router do
Enum.join(glob, "/")
end
instance = cond do
cond do
conn.assigns[:throttle] != nil ->
Farside.get_service(service_name)
|> Farside.last_instance
|> Farside.amend_instance(service_name, path)
send_resp(conn, :too_many_requests, "Too many requests - max request rate is 1 per second")
true ->
Farside.get_service(service_name)
|> Farside.pick_instance
|> Farside.amend_instance(service_name, path)
end
instance = Farside.get_service(service_name)
|> Farside.pick_instance
|> Farside.amend_instance(service_name, path)
# Redirect to the available instance
conn
|> Plug.Conn.resp(:found, "")
|> Plug.Conn.put_resp_header(
"location",
"#{instance}/#{path}#{get_query_params(conn)}"
)
# Redirect to the available instance
conn
|> Plug.Conn.resp(:found, "")
|> Plug.Conn.put_resp_header(
"location",
"#{instance}/#{path}#{get_query_params(conn)}"
)
end
end
end