From 3a9446bb9c5f6bb20efab858fd66cbe9e4b22eb8 Mon Sep 17 00:00:00 2001 From: dasha_uwu Date: Fri, 16 Jan 2026 22:12:20 +0500 Subject: [PATCH] Remove dead code These check the origin which is already checked in router auth --- src/api/server/invite.rs | 15 --------------- src/api/server/make_join.rs | 17 +---------------- src/api/server/make_knock.rs | 17 +---------------- src/api/server/send_join.rs | 23 ----------------------- src/api/server/send_knock.rs | 14 -------------- 5 files changed, 2 insertions(+), 84 deletions(-) diff --git a/src/api/server/invite.rs b/src/api/server/invite.rs index c12685e1..253dcef4 100644 --- a/src/api/server/invite.rs +++ b/src/api/server/invite.rs @@ -21,7 +21,6 @@ use tuwunel_core::{ matrix::{Event, PduCount, PduEvent, event::gen_event_id}, utils, utils::hash::sha256, - warn, }; use crate::Ruma; @@ -60,20 +59,6 @@ pub(crate) async fn create_invite_route( return Err!(Request(Forbidden("Server is banned on this homeserver."))); } - if services - .config - .forbidden_remote_server_names - .is_match(body.origin().host()) - { - warn!( - "Received federated/remote invite from banned server {} for room ID {}. Rejecting.", - body.origin(), - body.room_id - ); - - return Err!(Request(Forbidden("Server is banned on this homeserver."))); - } - let mut signed_event = utils::to_canonical_object(&body.event) .map_err(|_| err!(Request(InvalidParam("Invite event is invalid."))))?; diff --git a/src/api/server/make_join.rs b/src/api/server/make_join.rs index bf186fbf..07544c9b 100644 --- a/src/api/server/make_join.rs +++ b/src/api/server/make_join.rs @@ -12,7 +12,7 @@ use ruma::{ }, }; use tuwunel_core::{ - Err, Error, Result, at, debug_info, matrix::pdu::PduBuilder, utils::IterStream, warn, + Err, Error, Result, at, debug_info, matrix::pdu::PduBuilder, utils::IterStream, }; use tuwunel_service::Services; @@ -39,21 +39,6 @@ pub(crate) async fn create_join_event_template_route( .acl_check(body.origin(), &body.room_id) .await?; - if services - .config - .forbidden_remote_server_names - .is_match(body.origin().host()) - { - warn!( - "Server {} for remote user {} tried joining room ID {} which has a server name that \ - is globally forbidden. Rejecting.", - body.origin(), - &body.user_id, - &body.room_id, - ); - return Err!(Request(Forbidden("Server is banned on this homeserver."))); - } - if let Some(server) = body.room_id.server_name() && services .config diff --git a/src/api/server/make_knock.rs b/src/api/server/make_knock.rs index 60e2bfbc..a24b12f0 100644 --- a/src/api/server/make_knock.rs +++ b/src/api/server/make_knock.rs @@ -6,7 +6,7 @@ use ruma::{ api::{client::error::ErrorKind, federation::membership::prepare_knock_event}, events::room::member::{MembershipState, RoomMemberEventContent}, }; -use tuwunel_core::{Err, Error, Result, at, debug_warn, matrix::pdu::PduBuilder, warn}; +use tuwunel_core::{Err, Error, Result, at, debug_warn, matrix::pdu::PduBuilder}; use crate::Ruma; @@ -31,21 +31,6 @@ pub(crate) async fn create_knock_event_template_route( .acl_check(body.origin(), &body.room_id) .await?; - if services - .config - .forbidden_remote_server_names - .is_match(body.origin().host()) - { - warn!( - "Server {} for remote user {} tried knocking room ID {} which has a server name \ - that is globally forbidden. Rejecting.", - body.origin(), - &body.user_id, - &body.room_id, - ); - return Err!(Request(Forbidden("Server is banned on this homeserver."))); - } - if let Some(server) = body.room_id.server_name() && services .config diff --git a/src/api/server/send_join.rs b/src/api/server/send_join.rs index f1959abb..d3127974 100644 --- a/src/api/server/send_join.rs +++ b/src/api/server/send_join.rs @@ -270,21 +270,6 @@ pub(crate) async fn create_join_event_v1_route( State(services): State, body: Ruma, ) -> Result { - if services - .config - .forbidden_remote_server_names - .is_match(body.origin().host()) - { - warn!( - "Server {} tried joining room ID {} through us who has a server name that is \ - globally forbidden. Rejecting.", - body.origin(), - &body.room_id, - ); - - return Err!(Request(Forbidden("Server is banned on this homeserver."))); - } - if let Some(server) = body.room_id.server_name() && services .config @@ -317,14 +302,6 @@ pub(crate) async fn create_join_event_v2_route( State(services): State, body: Ruma, ) -> Result { - if services - .config - .forbidden_remote_server_names - .is_match(body.origin().host()) - { - return Err!(Request(Forbidden("Server is banned on this homeserver."))); - } - if let Some(server) = body.room_id.server_name() && services .config diff --git a/src/api/server/send_knock.rs b/src/api/server/send_knock.rs index c69059aa..0d1f169e 100644 --- a/src/api/server/send_knock.rs +++ b/src/api/server/send_knock.rs @@ -25,20 +25,6 @@ pub(crate) async fn create_knock_event_v1_route( State(services): State, body: Ruma, ) -> Result { - if services - .config - .forbidden_remote_server_names - .is_match(body.origin().host()) - { - warn!( - "Server {} tried knocking room ID {} who has a server name that is globally \ - forbidden. Rejecting.", - body.origin(), - &body.room_id, - ); - return Err!(Request(Forbidden("Server is banned on this homeserver."))); - } - if let Some(server) = body.room_id.server_name() && services .config