You've already forked AstralRinth
forked from didirus/AstralRinth
See if RateLimit is cors issue (#303)
This commit is contained in:
54
src/main.rs
54
src/main.rs
@@ -246,33 +246,33 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.max_age(3600)
|
.max_age(3600)
|
||||||
.send_wildcard(),
|
.send_wildcard(),
|
||||||
)
|
)
|
||||||
.wrap(
|
// .wrap(
|
||||||
RateLimiter::new(MemoryStoreActor::from(store.clone()).start())
|
// RateLimiter::new(MemoryStoreActor::from(store.clone()).start())
|
||||||
.with_identifier(|req| {
|
// .with_identifier(|req| {
|
||||||
let connection_info = req.connection_info();
|
// let connection_info = req.connection_info();
|
||||||
let ip =
|
// let ip =
|
||||||
String::from(if parse_var("CLOUDFLARE_INTEGRATION").unwrap_or(false) {
|
// String::from(if parse_var("CLOUDFLARE_INTEGRATION").unwrap_or(false) {
|
||||||
if let Some(header) = req.headers().get("CF-Connecting-IP") {
|
// if let Some(header) = req.headers().get("CF-Connecting-IP") {
|
||||||
header.to_str().map_err(|_| ARError::IdentificationError)?
|
// header.to_str().map_err(|_| ARError::IdentificationError)?
|
||||||
} else {
|
// } else {
|
||||||
connection_info
|
// connection_info
|
||||||
.peer_addr()
|
// .peer_addr()
|
||||||
.ok_or(ARError::IdentificationError)?
|
// .ok_or(ARError::IdentificationError)?
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
connection_info
|
// connection_info
|
||||||
.peer_addr()
|
// .peer_addr()
|
||||||
.ok_or(ARError::IdentificationError)?
|
// .ok_or(ARError::IdentificationError)?
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
Ok(ip)
|
// Ok(ip)
|
||||||
})
|
// })
|
||||||
.with_interval(std::time::Duration::from_secs(60))
|
// .with_interval(std::time::Duration::from_secs(60))
|
||||||
.with_max_requests(300)
|
// .with_max_requests(300)
|
||||||
.with_ignore_ips(
|
// .with_ignore_ips(
|
||||||
parse_strings_from_var("RATE_LIMIT_IGNORE_IPS").unwrap_or_default(),
|
// parse_strings_from_var("RATE_LIMIT_IGNORE_IPS").unwrap_or_default(),
|
||||||
),
|
// ),
|
||||||
)
|
// )
|
||||||
.app_data(web::Data::new(pool.clone()))
|
.app_data(web::Data::new(pool.clone()))
|
||||||
.app_data(web::Data::new(file_host.clone()))
|
.app_data(web::Data::new(file_host.clone()))
|
||||||
.app_data(web::Data::new(indexing_queue.clone()))
|
.app_data(web::Data::new(indexing_queue.clone()))
|
||||||
|
|||||||
Reference in New Issue
Block a user