diff --git a/src/main.rs b/src/main.rs index da01aa8..388a586 100644 --- a/src/main.rs +++ b/src/main.rs @@ -161,6 +161,14 @@ async fn main() -> anyhow::Result<()> { Ok(()) } +fn get_banned_users() -> Vec { + let mut banned_users = vec![]; + for line in std::fs::read_to_string("banned_users.txt").unwrap().lines() { + banned_users.push(line.to_string()); + } + banned_users +} + #[axum::debug_handler] async fn github_auth(Extension(state): Extension) -> Result { let redirect_url = format!( @@ -254,6 +262,10 @@ async fn onchain_handler( headers: HeaderMap, Json(payload): Json, ) -> Result, AppError> { + if get_banned_users().contains(&user.username) { + return Err(AppError::new("You are banned")); + } + // Extract the X-Forwarded-For header let x_forwarded_for = headers .get("x-forwarded-for") @@ -284,6 +296,10 @@ async fn lightning_handler( headers: HeaderMap, Json(payload): Json, ) -> Result, AppError> { + if get_banned_users().contains(&user.username) { + return Err(AppError::new("You are banned")); + } + // Extract the X-Forwarded-For header let x_forwarded_for = headers .get("x-forwarded-for") @@ -366,6 +382,10 @@ async fn channel_handler( headers: HeaderMap, Json(payload): Json, ) -> Result, AppError> { + if get_banned_users().contains(&user.username) { + return Err(AppError::new("You are banned")); + } + // Extract the X-Forwarded-For header let x_forwarded_for = headers .get("x-forwarded-for")