misc changes
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
c915f3dec5
commit
dc35d06c0a
4 changed files with 31 additions and 10 deletions
|
@ -34,12 +34,17 @@
|
||||||
# Defaults to `matrix.org`
|
# Defaults to `matrix.org`
|
||||||
# trusted_servers = ["matrix.org"]
|
# trusted_servers = ["matrix.org"]
|
||||||
|
|
||||||
# Sentry.io crash/panic reporting, performance monitoring/metrics, etc.
|
# Sentry.io crash/panic reporting, performance monitoring/metrics, etc. This is NOT enabled by default.
|
||||||
# Conduwuit's Sentry reporting endpoint is o4506996327251968.ingest.us.sentry.io
|
# conduwuit's default Sentry reporting endpoint is o4506996327251968.ingest.us.sentry.io
|
||||||
#
|
#
|
||||||
# Defaults to false
|
# Defaults to *false*
|
||||||
#sentry = 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
|
# Report your Conduwuit server_name in Sentry.io crash reports and metrics
|
||||||
#
|
#
|
||||||
# Defaults to false
|
# Defaults to false
|
||||||
|
|
|
@ -9,6 +9,10 @@ pub(crate) fn check(config: &Config) -> Result<(), Error> {
|
||||||
config.warn_deprecated();
|
config.warn_deprecated();
|
||||||
config.warn_unknown_key();
|
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") {
|
if cfg!(feature = "hardened_malloc") && cfg!(feature = "jemalloc") {
|
||||||
warn!(
|
warn!(
|
||||||
"hardened_malloc and jemalloc were built together, this causes neither to be used. Conduwuit will still \
|
"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 (\"\")"));
|
return Err(Error::bad_config("Registration token was specified but is empty (\"\")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.max_request_size < 16384 {
|
if config.max_request_size < 5120000 {
|
||||||
return Err(Error::bad_config("Max request size is less than 16KB. Please increase it."));
|
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
|
// check if user specified valid IP CIDR ranges on startup
|
||||||
|
|
|
@ -320,6 +320,8 @@ pub(crate) struct Config {
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub(crate) sentry: bool,
|
pub(crate) sentry: bool,
|
||||||
|
#[serde(default = "default_sentry_endpoint")]
|
||||||
|
pub(crate) sentry_endpoint: Option<Url>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub(crate) sentry_send_server_name: bool,
|
pub(crate) sentry_send_server_name: bool,
|
||||||
#[serde(default = "default_sentry_traces_sample_rate")]
|
#[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_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_sentry_traces_sample_rate() -> f32 { 0.15 }
|
||||||
|
|
||||||
fn default_startup_netburst_keep() -> i64 { 50 }
|
fn default_startup_netburst_keep() -> i64 { 50 }
|
||||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -397,7 +397,7 @@ fn request_result_log(method: &Method, uri: &Uri, result: &axum::response::Respo
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cors_layer(_server: &Server) -> CorsLayer {
|
fn cors_layer(_server: &Server) -> CorsLayer {
|
||||||
let methods = [
|
const METHODS: [Method; 6] = [
|
||||||
Method::GET,
|
Method::GET,
|
||||||
Method::HEAD,
|
Method::HEAD,
|
||||||
Method::POST,
|
Method::POST,
|
||||||
|
@ -406,9 +406,9 @@ fn cors_layer(_server: &Server) -> CorsLayer {
|
||||||
Method::OPTIONS,
|
Method::OPTIONS,
|
||||||
];
|
];
|
||||||
|
|
||||||
let headers = [
|
let headers: [HeaderName; 5] = [
|
||||||
header::ORIGIN,
|
header::ORIGIN,
|
||||||
HeaderName::from_static("x-requested-with"),
|
HeaderName::from_lowercase(b"x-requested-with").unwrap(),
|
||||||
header::CONTENT_TYPE,
|
header::CONTENT_TYPE,
|
||||||
header::ACCEPT,
|
header::ACCEPT,
|
||||||
header::AUTHORIZATION,
|
header::AUTHORIZATION,
|
||||||
|
@ -416,7 +416,7 @@ fn cors_layer(_server: &Server) -> CorsLayer {
|
||||||
|
|
||||||
CorsLayer::new()
|
CorsLayer::new()
|
||||||
.allow_origin(cors::Any)
|
.allow_origin(cors::Any)
|
||||||
.allow_methods(methods)
|
.allow_methods(METHODS)
|
||||||
.allow_headers(headers)
|
.allow_headers(headers)
|
||||||
.max_age(Duration::from_secs(86400))
|
.max_age(Duration::from_secs(86400))
|
||||||
}
|
}
|
||||||
|
@ -529,7 +529,11 @@ fn init(args: clap::Args) -> Result<Server, Error> {
|
||||||
#[cfg(feature = "sentry_telemetry")]
|
#[cfg(feature = "sentry_telemetry")]
|
||||||
fn init_sentry(config: &Config) -> sentry::ClientInitGuard {
|
fn init_sentry(config: &Config) -> sentry::ClientInitGuard {
|
||||||
sentry::init((
|
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 {
|
sentry::ClientOptions {
|
||||||
release: sentry::release_name!(),
|
release: sentry::release_name!(),
|
||||||
traces_sample_rate: config.sentry_traces_sample_rate,
|
traces_sample_rate: config.sentry_traces_sample_rate,
|
||||||
|
|
Loading…
Add table
Reference in a new issue