state-res: downgrade info! log messages to debug!
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
62fcc7361b
commit
37ffec73c9
@ -17,7 +17,7 @@ use serde::{
|
|||||||
Deserialize,
|
Deserialize,
|
||||||
};
|
};
|
||||||
use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
|
use serde_json::{from_str as from_json_str, value::RawValue as RawJsonValue};
|
||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, error, warn};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
power_levels::{
|
power_levels::{
|
||||||
@ -127,7 +127,7 @@ pub fn auth_check<E: Event>(
|
|||||||
current_third_party_invite: Option<impl Event>,
|
current_third_party_invite: Option<impl Event>,
|
||||||
fetch_state: impl Fn(&StateEventType, &str) -> Option<E>,
|
fetch_state: impl Fn(&StateEventType, &str) -> Option<E>,
|
||||||
) -> Result<bool> {
|
) -> Result<bool> {
|
||||||
info!(
|
debug!(
|
||||||
"auth_check beginning for {} ({})",
|
"auth_check beginning for {} ({})",
|
||||||
incoming_event.event_id(),
|
incoming_event.event_id(),
|
||||||
incoming_event.event_type()
|
incoming_event.event_type()
|
||||||
@ -153,7 +153,7 @@ pub fn auth_check<E: Event>(
|
|||||||
creator: Option<Raw<IgnoredAny>>,
|
creator: Option<Raw<IgnoredAny>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("start m.room.create check");
|
debug!("start m.room.create check");
|
||||||
|
|
||||||
// If it has any previous events, reject
|
// If it has any previous events, reject
|
||||||
if incoming_event.prev_events().next().is_some() {
|
if incoming_event.prev_events().next().is_some() {
|
||||||
@ -187,7 +187,7 @@ pub fn auth_check<E: Event>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("m.room.create event was allowed");
|
debug!("m.room.create event was allowed");
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ pub fn auth_check<E: Event>(
|
|||||||
if room_version.special_case_aliases_auth {
|
if room_version.special_case_aliases_auth {
|
||||||
// 4. If type is m.room.aliases
|
// 4. If type is m.room.aliases
|
||||||
if *incoming_event.event_type() == TimelineEventType::RoomAliases {
|
if *incoming_event.event_type() == TimelineEventType::RoomAliases {
|
||||||
info!("starting m.room.aliases check");
|
debug!("starting m.room.aliases check");
|
||||||
|
|
||||||
// If sender's domain doesn't matches state_key, reject
|
// If sender's domain doesn't matches state_key, reject
|
||||||
if incoming_event.state_key() != Some(sender.server_name().as_str()) {
|
if incoming_event.state_key() != Some(sender.server_name().as_str()) {
|
||||||
@ -259,7 +259,7 @@ pub fn auth_check<E: Event>(
|
|||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("m.room.aliases event was allowed");
|
debug!("m.room.aliases event was allowed");
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,7 +269,7 @@ pub fn auth_check<E: Event>(
|
|||||||
let sender_member_event = fetch_state(&StateEventType::RoomMember, sender.as_str());
|
let sender_member_event = fetch_state(&StateEventType::RoomMember, sender.as_str());
|
||||||
|
|
||||||
if *incoming_event.event_type() == TimelineEventType::RoomMember {
|
if *incoming_event.event_type() == TimelineEventType::RoomMember {
|
||||||
info!("starting m.room.member check");
|
debug!("starting m.room.member check");
|
||||||
let state_key = match incoming_event.state_key() {
|
let state_key = match incoming_event.state_key() {
|
||||||
None => {
|
None => {
|
||||||
warn!("no statekey in member event");
|
warn!("no statekey in member event");
|
||||||
@ -314,7 +314,7 @@ pub fn auth_check<E: Event>(
|
|||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("m.room.member event was allowed");
|
debug!("m.room.member event was allowed");
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,7 +380,7 @@ pub fn auth_check<E: Event>(
|
|||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("m.room.third_party_invite event was allowed");
|
debug!("m.room.third_party_invite event was allowed");
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,7 +393,7 @@ pub fn auth_check<E: Event>(
|
|||||||
|
|
||||||
// If type is m.room.power_levels
|
// If type is m.room.power_levels
|
||||||
if *incoming_event.event_type() == TimelineEventType::RoomPowerLevels {
|
if *incoming_event.event_type() == TimelineEventType::RoomPowerLevels {
|
||||||
info!("starting m.room.power_levels check");
|
debug!("starting m.room.power_levels check");
|
||||||
|
|
||||||
if let Some(required_pwr_lvl) = check_power_levels(
|
if let Some(required_pwr_lvl) = check_power_levels(
|
||||||
room_version,
|
room_version,
|
||||||
@ -409,7 +409,7 @@ pub fn auth_check<E: Event>(
|
|||||||
warn!("power level was not allowed");
|
warn!("power level was not allowed");
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
info!("power levels event allowed");
|
debug!("power levels event allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Room version 3: Redaction events are always accepted (provided the event is allowed by
|
// Room version 3: Redaction events are always accepted (provided the event is allowed by
|
||||||
@ -434,7 +434,7 @@ pub fn auth_check<E: Event>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("allowing event passed all checks");
|
debug!("allowing event passed all checks");
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -780,7 +780,7 @@ fn check_power_levels(
|
|||||||
deserialize_power_levels(power_event.content().get(), room_version)?;
|
deserialize_power_levels(power_event.content().get(), room_version)?;
|
||||||
|
|
||||||
// Validation of users is done in Ruma, synapse for loops validating user_ids and integers here
|
// Validation of users is done in Ruma, synapse for loops validating user_ids and integers here
|
||||||
info!("validation of power event finished");
|
debug!("validation of power event finished");
|
||||||
|
|
||||||
let current_state = match previous_power_event {
|
let current_state = match previous_power_event {
|
||||||
Some(current_state) => current_state,
|
Some(current_state) => current_state,
|
||||||
@ -912,7 +912,7 @@ fn check_redaction(
|
|||||||
redact_level: Int,
|
redact_level: Int,
|
||||||
) -> Result<bool> {
|
) -> Result<bool> {
|
||||||
if user_level >= redact_level {
|
if user_level >= redact_level {
|
||||||
info!("redaction allowed via power levels");
|
debug!("redaction allowed via power levels");
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,7 +921,7 @@ fn check_redaction(
|
|||||||
if redaction_event.event_id().borrow().server_name()
|
if redaction_event.event_id().borrow().server_name()
|
||||||
== redaction_event.redacts().as_ref().and_then(|&id| id.borrow().server_name())
|
== redaction_event.redacts().as_ref().and_then(|&id| id.borrow().server_name())
|
||||||
{
|
{
|
||||||
info!("redaction event allowed via room version 1 rules");
|
debug!("redaction event allowed via room version 1 rules");
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ use ruma_events::{
|
|||||||
StateEventType, TimelineEventType,
|
StateEventType, TimelineEventType,
|
||||||
};
|
};
|
||||||
use serde_json::from_str as from_json_str;
|
use serde_json::from_str as from_json_str;
|
||||||
use tracing::{debug, info, trace, warn};
|
use tracing::{debug, trace, warn};
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
pub mod event_auth;
|
pub mod event_auth;
|
||||||
@ -63,20 +63,20 @@ where
|
|||||||
E::Id: 'a,
|
E::Id: 'a,
|
||||||
SetIter: Iterator<Item = &'a StateMap<E::Id>> + Clone,
|
SetIter: Iterator<Item = &'a StateMap<E::Id>> + Clone,
|
||||||
{
|
{
|
||||||
info!("State resolution starting");
|
debug!("State resolution starting");
|
||||||
|
|
||||||
// Split non-conflicting and conflicting state
|
// Split non-conflicting and conflicting state
|
||||||
let (clean, conflicting) = separate(state_sets.into_iter());
|
let (clean, conflicting) = separate(state_sets.into_iter());
|
||||||
|
|
||||||
info!("non conflicting events: {}", clean.len());
|
debug!("non conflicting events: {}", clean.len());
|
||||||
trace!("{clean:?}");
|
trace!("{clean:?}");
|
||||||
|
|
||||||
if conflicting.is_empty() {
|
if conflicting.is_empty() {
|
||||||
info!("no conflicting state found");
|
debug!("no conflicting state found");
|
||||||
return Ok(clean);
|
return Ok(clean);
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("conflicting events: {}", conflicting.len());
|
debug!("conflicting events: {}", conflicting.len());
|
||||||
debug!("{conflicting:?}");
|
debug!("{conflicting:?}");
|
||||||
|
|
||||||
// `all_conflicted` contains unique items
|
// `all_conflicted` contains unique items
|
||||||
@ -87,7 +87,7 @@ where
|
|||||||
.filter(|id| fetch_event(id.borrow()).is_some())
|
.filter(|id| fetch_event(id.borrow()).is_some())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
info!("full conflicted set: {}", all_conflicted.len());
|
debug!("full conflicted set: {}", all_conflicted.len());
|
||||||
debug!("{all_conflicted:?}");
|
debug!("{all_conflicted:?}");
|
||||||
|
|
||||||
// We used to check that all events are events from the correct room
|
// We used to check that all events are events from the correct room
|
||||||
@ -229,7 +229,7 @@ fn reverse_topological_power_sort<E: Event>(
|
|||||||
let mut event_to_pl = HashMap::new();
|
let mut event_to_pl = HashMap::new();
|
||||||
for event_id in graph.keys() {
|
for event_id in graph.keys() {
|
||||||
let pl = get_power_level_for_sender(event_id.borrow(), &fetch_event)?;
|
let pl = get_power_level_for_sender(event_id.borrow(), &fetch_event)?;
|
||||||
info!("{event_id} power level {pl}");
|
debug!("{event_id} power level {pl}");
|
||||||
|
|
||||||
event_to_pl.insert(event_id.clone(), pl);
|
event_to_pl.insert(event_id.clone(), pl);
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ where
|
|||||||
event_id: &'a Id,
|
event_id: &'a Id,
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("starting lexicographical topological sort");
|
debug!("starting lexicographical topological sort");
|
||||||
// NOTE: an event that has no incoming edges happened most recently,
|
// NOTE: an event that has no incoming edges happened most recently,
|
||||||
// and an event that has no outgoing edges happened least recently.
|
// and an event that has no outgoing edges happened least recently.
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ fn get_power_level_for_sender<E: Event>(
|
|||||||
event_id: &EventId,
|
event_id: &EventId,
|
||||||
fetch_event: impl Fn(&EventId) -> Option<E>,
|
fetch_event: impl Fn(&EventId) -> Option<E>,
|
||||||
) -> serde_json::Result<Int> {
|
) -> serde_json::Result<Int> {
|
||||||
info!("fetch event ({event_id}) senders power level");
|
debug!("fetch event ({event_id}) senders power level");
|
||||||
|
|
||||||
let event = fetch_event(event_id);
|
let event = fetch_event(event_id);
|
||||||
let mut pl = None;
|
let mut pl = None;
|
||||||
@ -387,7 +387,7 @@ fn iterative_auth_check<E: Event + Clone>(
|
|||||||
unconflicted_state: StateMap<E::Id>,
|
unconflicted_state: StateMap<E::Id>,
|
||||||
fetch_event: impl Fn(&EventId) -> Option<E>,
|
fetch_event: impl Fn(&EventId) -> Option<E>,
|
||||||
) -> Result<StateMap<E::Id>> {
|
) -> Result<StateMap<E::Id>> {
|
||||||
info!("starting iterative auth check");
|
debug!("starting iterative auth check");
|
||||||
|
|
||||||
debug!("performing auth checks on {events_to_check:?}");
|
debug!("performing auth checks on {events_to_check:?}");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user