mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
fix: Apply validation to make_join process
This commit is contained in:
@@ -15,6 +15,7 @@ use conduwuit::{
|
|||||||
utils::{
|
utils::{
|
||||||
self, shuffle,
|
self, shuffle,
|
||||||
stream::{IterStream, ReadyExt},
|
stream::{IterStream, ReadyExt},
|
||||||
|
to_canonical_object,
|
||||||
},
|
},
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
@@ -1012,7 +1013,23 @@ async fn make_join_request(
|
|||||||
trace!("make_join response: {:?}", make_join_response);
|
trace!("make_join response: {:?}", make_join_response);
|
||||||
make_join_counter = make_join_counter.saturating_add(1);
|
make_join_counter = make_join_counter.saturating_add(1);
|
||||||
|
|
||||||
if let Err(ref e) = make_join_response {
|
match make_join_response {
|
||||||
|
| Ok(response) => {
|
||||||
|
info!("Received make_join response from {remote_server}");
|
||||||
|
if let Err(e) = validate_remote_member_event_stub(
|
||||||
|
&MembershipState::Join,
|
||||||
|
sender_user,
|
||||||
|
room_id,
|
||||||
|
&to_canonical_object(&response.event)?,
|
||||||
|
) {
|
||||||
|
warn!("make_join response from {remote_server} failed validation: {e}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
make_join_response_and_server = Ok((response, remote_server.clone()));
|
||||||
|
break;
|
||||||
|
},
|
||||||
|
| Err(e) => {
|
||||||
|
info!("make_join request to {remote_server} failed: {e}");
|
||||||
if matches!(
|
if matches!(
|
||||||
e.kind(),
|
e.kind(),
|
||||||
ErrorKind::IncompatibleRoomVersion { .. } | ErrorKind::UnsupportedRoomVersion
|
ErrorKind::IncompatibleRoomVersion { .. } | ErrorKind::UnsupportedRoomVersion
|
||||||
@@ -1024,8 +1041,8 @@ async fn make_join_request(
|
|||||||
if incompatible_room_version_count > 15 {
|
if incompatible_room_version_count > 15 {
|
||||||
info!(
|
info!(
|
||||||
"15 servers have responded with M_INCOMPATIBLE_ROOM_VERSION or \
|
"15 servers have responded with M_INCOMPATIBLE_ROOM_VERSION or \
|
||||||
M_UNSUPPORTED_ROOM_VERSION, assuming that conduwuit does not support the \
|
M_UNSUPPORTED_ROOM_VERSION, assuming that conduwuit does not support \
|
||||||
room version {room_id}: {e}"
|
the room version {room_id}: {e}"
|
||||||
);
|
);
|
||||||
make_join_response_and_server =
|
make_join_response_and_server =
|
||||||
Err!(BadServerResponse("Room version is not supported by Conduwuit"));
|
Err!(BadServerResponse("Room version is not supported by Conduwuit"));
|
||||||
@@ -1034,18 +1051,17 @@ async fn make_join_request(
|
|||||||
|
|
||||||
if make_join_counter > 40 {
|
if make_join_counter > 40 {
|
||||||
warn!(
|
warn!(
|
||||||
"40 servers failed to provide valid make_join response, assuming no server \
|
"40 servers failed to provide valid make_join response, assuming no \
|
||||||
can assist in joining."
|
server can assist in joining."
|
||||||
);
|
);
|
||||||
make_join_response_and_server =
|
make_join_response_and_server =
|
||||||
Err!(BadServerResponse("No server available to assist in joining."));
|
Err!(BadServerResponse("No server available to assist in joining."));
|
||||||
|
|
||||||
return make_join_response_and_server;
|
return make_join_response_and_server;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
make_join_response_and_server = make_join_response.map(|r| (r, remote_server.clone()));
|
|
||||||
|
|
||||||
if make_join_response_and_server.is_ok() {
|
if make_join_response_and_server.is_ok() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user