mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-26 07:34:25 +00:00
daily logging improvements
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
0b33eec1c2
commit
a124122dd4
|
@ -10,10 +10,11 @@ use ruma::api::client::{
|
||||||
get_media_preview,
|
get_media_preview,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, error, warn};
|
||||||
use webpage::HTML;
|
use webpage::HTML;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
debug_warn,
|
||||||
service::media::{FileMeta, UrlPreviewData},
|
service::media::{FileMeta, UrlPreviewData},
|
||||||
services, utils, Error, Result, Ruma, RumaResponse,
|
services, utils, Error, Result, Ruma, RumaResponse,
|
||||||
};
|
};
|
||||||
|
@ -324,17 +325,14 @@ pub(crate) async fn get_content_thumbnail_route(
|
||||||
cache_control: Some(CACHE_CONTROL_IMMUTABLE.into()),
|
cache_control: Some(CACHE_CONTROL_IMMUTABLE.into()),
|
||||||
})
|
})
|
||||||
} else if &*body.server_name != services().globals.server_name() && body.allow_remote {
|
} else if &*body.server_name != services().globals.server_name() && body.allow_remote {
|
||||||
// we'll lie to the client and say the blocked server's media was not found and
|
|
||||||
// log. the client has no way of telling anyways so this is a security bonus.
|
|
||||||
if services()
|
if services()
|
||||||
.globals
|
.globals
|
||||||
.prevent_media_downloads_from()
|
.prevent_media_downloads_from()
|
||||||
.contains(&body.server_name.clone())
|
.contains(&body.server_name.clone())
|
||||||
{
|
{
|
||||||
info!(
|
// we'll lie to the client and say the blocked server's media was not found and
|
||||||
"Received request for remote media `{}` but server is in our media server blocklist. Returning 404.",
|
// log. the client has no way of telling anyways so this is a security bonus.
|
||||||
mxc
|
debug_warn!("Received request for media `{}` on blocklisted server", mxc);
|
||||||
);
|
|
||||||
return Err(Error::BadRequest(ErrorKind::NotFound, "Media not found."));
|
return Err(Error::BadRequest(ErrorKind::NotFound, "Media not found."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,17 +400,14 @@ pub(crate) async fn get_content_thumbnail_v1_route(
|
||||||
async fn get_remote_content(
|
async fn get_remote_content(
|
||||||
mxc: &str, server_name: &ruma::ServerName, media_id: String, allow_redirect: bool, timeout_ms: Duration,
|
mxc: &str, server_name: &ruma::ServerName, media_id: String, allow_redirect: bool, timeout_ms: Duration,
|
||||||
) -> Result<get_content::v3::Response, Error> {
|
) -> Result<get_content::v3::Response, Error> {
|
||||||
// we'll lie to the client and say the blocked server's media was not found and
|
|
||||||
// log. the client has no way of telling anyways so this is a security bonus.
|
|
||||||
if services()
|
if services()
|
||||||
.globals
|
.globals
|
||||||
.prevent_media_downloads_from()
|
.prevent_media_downloads_from()
|
||||||
.contains(&server_name.to_owned())
|
.contains(&server_name.to_owned())
|
||||||
{
|
{
|
||||||
info!(
|
// we'll lie to the client and say the blocked server's media was not found and
|
||||||
"Received request for remote media `{}` but server is in our media server blocklist. Returning 404.",
|
// log. the client has no way of telling anyways so this is a security bonus.
|
||||||
mxc
|
debug_warn!("Received request for media `{}` on blocklisted server", mxc);
|
||||||
);
|
|
||||||
return Err(Error::BadRequest(ErrorKind::NotFound, "Media not found."));
|
return Err(Error::BadRequest(ErrorKind::NotFound, "Media not found."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ use tracing::{debug, error, info, trace, warn};
|
||||||
|
|
||||||
use super::state_compressor::CompressedStateEvent;
|
use super::state_compressor::CompressedStateEvent;
|
||||||
use crate::{
|
use crate::{
|
||||||
debug_info,
|
debug_error, debug_info,
|
||||||
service::{pdu, Arc, BTreeMap, HashMap, Result},
|
service::{pdu, Arc, BTreeMap, HashMap, Result},
|
||||||
services, Error, PduEvent,
|
services, Error, PduEvent,
|
||||||
};
|
};
|
||||||
|
@ -1103,7 +1103,7 @@ impl Service {
|
||||||
events_all.insert(next_id);
|
events_all.insert(next_id);
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
warn!("Failed to fetch event {next_id}: {e}");
|
debug_error!("Failed to fetch event {next_id}: {e}");
|
||||||
back_off((*next_id).to_owned()).await;
|
back_off((*next_id).to_owned()).await;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ use ErrorKind::{
|
||||||
TooLarge, Unauthorized, Unknown, UnknownToken, Unrecognized, UserDeactivated, WrongRoomKeysVersion,
|
TooLarge, Unauthorized, Unknown, UnknownToken, Unrecognized, UserDeactivated, WrongRoomKeysVersion,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{debug_info, RumaResponse};
|
use crate::RumaResponse;
|
||||||
|
|
||||||
pub(crate) type Result<T, E = Error> = std::result::Result<T, E>;
|
pub(crate) type Result<T, E = Error> = std::result::Result<T, E>;
|
||||||
|
|
||||||
|
@ -139,7 +139,6 @@ impl Error {
|
||||||
_ => (Unknown, StatusCode::INTERNAL_SERVER_ERROR),
|
_ => (Unknown, StatusCode::INTERNAL_SERVER_ERROR),
|
||||||
};
|
};
|
||||||
|
|
||||||
debug_info!("Returning an error: {status_code}: {message}");
|
|
||||||
RumaResponse(UiaaResponse::MatrixError(RumaError {
|
RumaResponse(UiaaResponse::MatrixError(RumaError {
|
||||||
body: ErrorBody::Standard {
|
body: ErrorBody::Standard {
|
||||||
kind,
|
kind,
|
||||||
|
|
Loading…
Reference in a new issue