You've already forked AstralRinth
forked from didirus/AstralRinth
Rate limiting + version fixes (#90)
* Rate limiting + version fixes * Move patch to proper place * More fixes * Fix commit hash pin
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::file_hosting::S3Host;
|
||||
use actix_cors::Cors;
|
||||
use actix_ratelimit::{MemoryStore, MemoryStoreActor, RateLimiter};
|
||||
use actix_web::middleware::Logger;
|
||||
use actix_web::{http, web, App, HttpServer};
|
||||
use env_logger::Env;
|
||||
@@ -205,6 +206,8 @@ async fn main() -> std::io::Result<()> {
|
||||
.and_then(|s| serde_json::from_str::<Vec<String>>(&s).ok())
|
||||
.unwrap_or_else(|| vec![String::from("http://localhost")]);
|
||||
|
||||
let store = MemoryStore::new();
|
||||
|
||||
info!("Starting Actix HTTP server!");
|
||||
|
||||
// Init App
|
||||
@@ -222,6 +225,11 @@ async fn main() -> std::io::Result<()> {
|
||||
.wrap(cors.finish())
|
||||
.wrap(Logger::default())
|
||||
.wrap(Logger::new("%a %{User-Agent}i"))
|
||||
.wrap(
|
||||
RateLimiter::new(MemoryStoreActor::from(store.clone()).start())
|
||||
.with_interval(std::time::Duration::from_secs(60))
|
||||
.with_max_requests(100),
|
||||
)
|
||||
.data(pool.clone())
|
||||
.data(file_host.clone())
|
||||
.data(indexing_queue.clone())
|
||||
|
||||
Reference in New Issue
Block a user