feat: Use info level logs for residency check failures

This commit is contained in:
timedout 2026-01-27 23:26:14 +00:00 committed by Ellis Git
parent 76fe8c4cdc
commit 082ed5b70c
14 changed files with 88 additions and 25 deletions

View file

@ -2,7 +2,7 @@ use std::cmp;
use axum::extract::State;
use conduwuit::{
Err, Event, PduCount, Result, debug_warn,
Err, Event, PduCount, Result, info,
result::LogErr,
utils::{IterStream, ReadyExt, stream::TryTools},
};
@ -40,7 +40,7 @@ pub(crate) async fn get_backfill_route(
.server_in_room(services.globals.server_name(), &body.room_id)
.await
{
debug_warn!(
info!(
origin = body.origin().as_str(),
"Refusing to serve backfill for room we aren't participating in"
);

View file

@ -1,5 +1,5 @@
use axum::extract::State;
use conduwuit::{Result, err};
use conduwuit::{Err, Result, err, info};
use ruma::{MilliSecondsSinceUnixEpoch, RoomId, api::federation::event::get_event};
use super::AccessCheck;
@ -38,6 +38,19 @@ pub(crate) async fn get_event_route(
.check()
.await?;
if !services
.rooms
.state_cache
.server_in_room(services.globals.server_name(), room_id)
.await
{
info!(
origin = body.origin().as_str(),
"Refusing to serve state for room we aren't participating in"
);
return Err!(Request(NotFound("This server is not participating in that room.")));
}
Ok(get_event::v1::Response {
origin: services.globals.server_name().to_owned(),
origin_server_ts: MilliSecondsSinceUnixEpoch::now(),

View file

@ -1,7 +1,7 @@
use std::{borrow::Borrow, iter::once};
use axum::extract::State;
use conduwuit::{Error, Result, utils::stream::ReadyExt};
use conduwuit::{Err, Error, Result, info, utils::stream::ReadyExt};
use futures::StreamExt;
use ruma::{
RoomId,
@ -29,6 +29,19 @@ pub(crate) async fn get_event_authorization_route(
.check()
.await?;
if !services
.rooms
.state_cache
.server_in_room(services.globals.server_name(), &body.room_id)
.await
{
info!(
origin = body.origin().as_str(),
"Refusing to serve state for room we aren't participating in"
);
return Err!(Request(NotFound("This server is not participating in that room.")));
}
let event = services
.rooms
.timeline

View file

@ -1,5 +1,5 @@
use axum::extract::State;
use conduwuit::{Result, debug, debug_error, utils::to_canonical_object};
use conduwuit::{Err, Result, debug, debug_error, info, utils::to_canonical_object};
use ruma::api::federation::event::get_missing_events;
use super::AccessCheck;
@ -26,6 +26,19 @@ pub(crate) async fn get_missing_events_route(
.check()
.await?;
if !services
.rooms
.state_cache
.server_in_room(services.globals.server_name(), &body.room_id)
.await
{
info!(
origin = body.origin().as_str(),
"Refusing to serve state for room we aren't participating in"
);
return Err!(Request(NotFound("This server is not participating in that room.")));
}
let limit = body
.limit
.try_into()

View file

@ -1,6 +1,6 @@
use axum::extract::State;
use conduwuit::{
Err, Result,
Err, Result, info,
utils::stream::{BroadbandExt, IterStream},
};
use conduwuit_service::rooms::spaces::{
@ -23,6 +23,19 @@ pub(crate) async fn get_hierarchy_route(
return Err!(Request(NotFound("Room does not exist.")));
}
if !services
.rooms
.state_cache
.server_in_room(services.globals.server_name(), &body.room_id)
.await
{
info!(
origin = body.origin().as_str(),
"Refusing to serve state for room we aren't participating in"
);
return Err!(Request(NotFound("This server is not participating in that room.")));
}
let room_id = &body.room_id;
let suggested_only = body.suggested_only;
let ref identifier = Identifier::ServerName(body.origin());

View file

@ -1,9 +1,7 @@
use std::borrow::ToOwned;
use axum::extract::State;
use conduwuit::{
Err, Error, Result, debug, debug_info, debug_warn, info, matrix::pdu::PduBuilder, warn,
};
use conduwuit::{Err, Error, Result, debug, debug_info, info, matrix::pdu::PduBuilder, warn};
use conduwuit_service::Services;
use futures::StreamExt;
use ruma::{
@ -38,7 +36,7 @@ pub(crate) async fn create_join_event_template_route(
.server_in_room(services.globals.server_name(), &body.room_id)
.await
{
debug_warn!(
info!(
origin = body.origin().as_str(),
"Refusing to serve make_join for room we aren't participating in"
);

View file

@ -1,6 +1,6 @@
use RoomVersionId::*;
use axum::extract::State;
use conduwuit::{Err, Error, Result, debug_warn, matrix::pdu::PduBuilder, warn};
use conduwuit::{Err, Error, Result, debug_warn, info, matrix::pdu::PduBuilder, warn};
use ruma::{
RoomVersionId,
api::{client::error::ErrorKind, federation::knock::create_knock_event_template},
@ -26,7 +26,7 @@ pub(crate) async fn create_knock_event_template_route(
.server_in_room(services.globals.server_name(), &body.room_id)
.await
{
debug_warn!(
info!(
origin = body.origin().as_str(),
"Refusing to serve make_knock for room we aren't participating in"
);

View file

@ -1,5 +1,5 @@
use axum::extract::State;
use conduwuit::{Err, Result, debug_warn, matrix::pdu::PduBuilder};
use conduwuit::{Err, Result, info, matrix::pdu::PduBuilder};
use ruma::{
api::federation::membership::prepare_leave_event,
events::room::member::{MembershipState, RoomMemberEventContent},
@ -26,7 +26,7 @@ pub(crate) async fn create_leave_event_template_route(
.server_in_room(services.globals.server_name(), &body.room_id)
.await
{
debug_warn!(
info!(
origin = body.origin().as_str(),
"Refusing to serve make_leave for room we aren't participating in"
);

View file

@ -4,7 +4,7 @@ use std::{borrow::Borrow, time::Instant, vec};
use axum::extract::State;
use conduwuit::{
Err, Event, Result, at, debug, debug_warn, err, info,
Err, Event, Result, at, debug, err, info,
matrix::event::gen_event_id_canonical_json,
trace,
utils::stream::{BroadbandExt, IterStream, TryBroadbandExt},
@ -42,7 +42,7 @@ async fn create_join_event(
.server_in_room(services.globals.server_name(), room_id)
.await
{
debug_warn!(
info!(
origin = origin.as_str(),
"Refusing to serve send_join for room we aren't participating in"
);

View file

@ -1,6 +1,6 @@
use axum::extract::State;
use conduwuit::{
Err, Result, debug_warn, err,
Err, Result, err, info,
matrix::{event::gen_event_id_canonical_json, pdu::PduEvent},
warn,
};
@ -60,7 +60,7 @@ pub(crate) async fn create_knock_event_v1_route(
.server_in_room(services.globals.server_name(), &body.room_id)
.await
{
debug_warn!(
info!(
origin = body.origin().as_str(),
"Refusing to serve send_knock for room we aren't participating in"
);

View file

@ -1,7 +1,7 @@
#![allow(deprecated)]
use axum::extract::State;
use conduwuit::{Err, Result, debug_warn, err, matrix::event::gen_event_id_canonical_json};
use conduwuit::{Err, Result, err, info, matrix::event::gen_event_id_canonical_json};
use conduwuit_service::Services;
use futures::FutureExt;
use ruma::{
@ -56,7 +56,7 @@ async fn create_leave_event(
.server_in_room(services.globals.server_name(), room_id)
.await
{
debug_warn!(
info!(
origin = origin.as_str(),
"Refusing to serve backfill for room we aren't participating in"
);

View file

@ -1,7 +1,7 @@
use std::{borrow::Borrow, iter::once};
use axum::extract::State;
use conduwuit::{Err, Result, at, debug_warn, err, utils::IterStream};
use conduwuit::{Err, Result, at, err, info, utils::IterStream};
use futures::{FutureExt, StreamExt, TryStreamExt};
use ruma::{OwnedEventId, api::federation::event::get_room_state};
@ -30,7 +30,7 @@ pub(crate) async fn get_room_state_route(
.server_in_room(services.globals.server_name(), &body.room_id)
.await
{
debug_warn!(
info!(
origin = body.origin().as_str(),
"Refusing to serve state for room we aren't participating in"
);

View file

@ -1,7 +1,7 @@
use std::{borrow::Borrow, iter::once};
use axum::extract::State;
use conduwuit::{Result, at, err};
use conduwuit::{Err, Result, at, err, info};
use futures::{StreamExt, TryStreamExt};
use ruma::{OwnedEventId, api::federation::event::get_room_state_ids};
@ -25,6 +25,19 @@ pub(crate) async fn get_room_state_ids_route(
.check()
.await?;
if !services
.rooms
.state_cache
.server_in_room(services.globals.server_name(), &body.room_id)
.await
{
info!(
origin = body.origin().as_str(),
"Refusing to serve state for room we aren't participating in"
);
return Err!(Request(NotFound("This server is not participating in that room.")));
}
let shortstatehash = services
.rooms
.state_accessor

View file

@ -4,7 +4,7 @@ use std::{
};
use conduwuit::{
Err, Event, Result, debug::INFO_SPAN_LEVEL, debug_warn, defer, err, implement,
Err, Event, Result, debug::INFO_SPAN_LEVEL, defer, err, implement, info,
utils::stream::IterStream, warn,
};
use futures::{
@ -120,7 +120,7 @@ pub async fn handle_incoming_pdu<'a>(
.server_in_room(self.services.globals.server_name(), room_id)
.await
{
debug_warn!(
info!(
%origin,
"Dropping inbound PDU for room we aren't participating in"
);