misc changes

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-04-24 02:19:50 -04:00 committed by June
parent c915f3dec5
commit dc35d06c0a
4 changed files with 31 additions and 10 deletions

View file

@ -34,12 +34,17 @@
# Defaults to `matrix.org`
# trusted_servers = ["matrix.org"]
# Sentry.io crash/panic reporting, performance monitoring/metrics, etc.
# Conduwuit's Sentry reporting endpoint is o4506996327251968.ingest.us.sentry.io
# Sentry.io crash/panic reporting, performance monitoring/metrics, etc. This is NOT enabled by default.
# conduwuit's default Sentry reporting endpoint is o4506996327251968.ingest.us.sentry.io
#
# Defaults to false
# Defaults to *false*
#sentry = false
# Sentry reporting URL if a custom one is desired
#
# Defaults to conduwuit's default Sentry endpoint: "https://fe2eb4536aa04949e28eff3128d64757@o4506996327251968.ingest.us.sentry.io/4506996334657536"
#sentry_endpoint = ""
# Report your Conduwuit server_name in Sentry.io crash reports and metrics
#
# Defaults to false

View file

@ -9,6 +9,10 @@ pub(crate) fn check(config: &Config) -> Result<(), Error> {
config.warn_deprecated();
config.warn_unknown_key();
if config.sentry && config.sentry_endpoint.is_none() {
return Err(Error::bad_config("Sentry cannot be enabled without an endpoint set"));
}
if cfg!(feature = "hardened_malloc") && cfg!(feature = "jemalloc") {
warn!(
"hardened_malloc and jemalloc were built together, this causes neither to be used. Conduwuit will still \
@ -87,8 +91,8 @@ pub(crate) fn check(config: &Config) -> Result<(), Error> {
return Err(Error::bad_config("Registration token was specified but is empty (\"\")"));
}
if config.max_request_size < 16384 {
return Err(Error::bad_config("Max request size is less than 16KB. Please increase it."));
if config.max_request_size < 5120000 {
return Err(Error::bad_config("Max request size is less than 5MB. Please increase it."));
}
// check if user specified valid IP CIDR ranges on startup

View file

@ -320,6 +320,8 @@ pub(crate) struct Config {
#[serde(default)]
pub(crate) sentry: bool,
#[serde(default = "default_sentry_endpoint")]
pub(crate) sentry_endpoint: Option<Url>,
#[serde(default)]
pub(crate) sentry_send_server_name: bool,
#[serde(default = "default_sentry_traces_sample_rate")]
@ -998,6 +1000,12 @@ fn default_url_preview_max_spider_size() -> usize {
fn default_new_user_displayname_suffix() -> String { "🏳️‍⚧️".to_owned() }
fn default_sentry_endpoint() -> Option<Url> {
Url::parse("https://fe2eb4536aa04949e28eff3128d64757@o4506996327251968.ingest.us.sentry.io/4506996334657536")
.unwrap()
.into()
}
fn default_sentry_traces_sample_rate() -> f32 { 0.15 }
fn default_startup_netburst_keep() -> i64 { 50 }

View file

@ -397,7 +397,7 @@ fn request_result_log(method: &Method, uri: &Uri, result: &axum::response::Respo
}
fn cors_layer(_server: &Server) -> CorsLayer {
let methods = [
const METHODS: [Method; 6] = [
Method::GET,
Method::HEAD,
Method::POST,
@ -406,9 +406,9 @@ fn cors_layer(_server: &Server) -> CorsLayer {
Method::OPTIONS,
];
let headers = [
let headers: [HeaderName; 5] = [
header::ORIGIN,
HeaderName::from_static("x-requested-with"),
HeaderName::from_lowercase(b"x-requested-with").unwrap(),
header::CONTENT_TYPE,
header::ACCEPT,
header::AUTHORIZATION,
@ -416,7 +416,7 @@ fn cors_layer(_server: &Server) -> CorsLayer {
CorsLayer::new()
.allow_origin(cors::Any)
.allow_methods(methods)
.allow_methods(METHODS)
.allow_headers(headers)
.max_age(Duration::from_secs(86400))
}
@ -529,7 +529,11 @@ fn init(args: clap::Args) -> Result<Server, Error> {
#[cfg(feature = "sentry_telemetry")]
fn init_sentry(config: &Config) -> sentry::ClientInitGuard {
sentry::init((
"https://fe2eb4536aa04949e28eff3128d64757@o4506996327251968.ingest.us.sentry.io/4506996334657536",
config
.sentry_endpoint
.as_ref()
.expect("init_sentry should only be called if sentry is enabled and this is not None")
.as_str(),
sentry::ClientOptions {
release: sentry::release_name!(),
traces_sample_rate: config.sentry_traces_sample_rate,