mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
Move federation config to separate config section
This renames: allow_federation -> federation.enable trusted_servers -> federation.trusted_servers max_fetch_prev_events -> federation.max_fetch_prev_events max_concurrent_requests -> federation.max_concurrent_requests
This commit is contained in:
parent
e0e7d8fd91
commit
5a6e4fac73
4 changed files with 29 additions and 25 deletions
|
|
@ -32,6 +32,8 @@ pub(crate) struct Config {
|
||||||
|
|
||||||
pub(crate) server_name: OwnedServerName,
|
pub(crate) server_name: OwnedServerName,
|
||||||
pub(crate) database: DatabaseConfig,
|
pub(crate) database: DatabaseConfig,
|
||||||
|
#[serde(default)]
|
||||||
|
pub(crate) federation: FederationConfig,
|
||||||
|
|
||||||
#[serde(default = "default_cache_capacity_modifier")]
|
#[serde(default = "default_cache_capacity_modifier")]
|
||||||
pub(crate) cache_capacity_modifier: f64,
|
pub(crate) cache_capacity_modifier: f64,
|
||||||
|
|
@ -41,18 +43,12 @@ pub(crate) struct Config {
|
||||||
pub(crate) cleanup_second_interval: u32,
|
pub(crate) cleanup_second_interval: u32,
|
||||||
#[serde(default = "default_max_request_size")]
|
#[serde(default = "default_max_request_size")]
|
||||||
pub(crate) max_request_size: u32,
|
pub(crate) max_request_size: u32,
|
||||||
#[serde(default = "default_max_concurrent_requests")]
|
|
||||||
pub(crate) max_concurrent_requests: u16,
|
|
||||||
#[serde(default = "default_max_fetch_prev_events")]
|
|
||||||
pub(crate) max_fetch_prev_events: u16,
|
|
||||||
#[serde(default = "false_fn")]
|
#[serde(default = "false_fn")]
|
||||||
pub(crate) allow_registration: bool,
|
pub(crate) allow_registration: bool,
|
||||||
pub(crate) registration_token: Option<String>,
|
pub(crate) registration_token: Option<String>,
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub(crate) allow_encryption: bool,
|
pub(crate) allow_encryption: bool,
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub(crate) allow_federation: bool,
|
|
||||||
#[serde(default = "true_fn")]
|
|
||||||
pub(crate) allow_room_creation: bool,
|
pub(crate) allow_room_creation: bool,
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub(crate) allow_unstable_room_versions: bool,
|
pub(crate) allow_unstable_room_versions: bool,
|
||||||
|
|
@ -61,8 +57,6 @@ pub(crate) struct Config {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub(crate) proxy: ProxyConfig,
|
pub(crate) proxy: ProxyConfig,
|
||||||
pub(crate) jwt_secret: Option<String>,
|
pub(crate) jwt_secret: Option<String>,
|
||||||
#[serde(default = "default_trusted_servers")]
|
|
||||||
pub(crate) trusted_servers: Vec<OwnedServerName>,
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub(crate) observability: ObservabilityConfig,
|
pub(crate) observability: ObservabilityConfig,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
|
@ -249,6 +243,28 @@ pub(crate) struct ObservabilityConfig {
|
||||||
pub(crate) logs: LogConfig,
|
pub(crate) logs: LogConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub(crate) struct FederationConfig {
|
||||||
|
pub(crate) enable: bool,
|
||||||
|
pub(crate) trusted_servers: Vec<OwnedServerName>,
|
||||||
|
pub(crate) max_fetch_prev_events: u16,
|
||||||
|
pub(crate) max_concurrent_requests: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for FederationConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
enable: true,
|
||||||
|
trusted_servers: vec![
|
||||||
|
OwnedServerName::try_from("matrix.org").unwrap()
|
||||||
|
],
|
||||||
|
max_fetch_prev_events: 100,
|
||||||
|
max_concurrent_requests: 100,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn false_fn() -> bool {
|
fn false_fn() -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
@ -300,18 +316,6 @@ fn default_max_request_size() -> u32 {
|
||||||
20 * 1024 * 1024
|
20 * 1024 * 1024
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_max_concurrent_requests() -> u16 {
|
|
||||||
100
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_max_fetch_prev_events() -> u16 {
|
|
||||||
100_u16
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_trusted_servers() -> Vec<OwnedServerName> {
|
|
||||||
vec![OwnedServerName::try_from("matrix.org").unwrap()]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_tracing_filter() -> EnvFilterClone {
|
fn default_tracing_filter() -> EnvFilterClone {
|
||||||
"info,ruma_state_res=warn"
|
"info,ruma_state_res=warn"
|
||||||
.parse()
|
.parse()
|
||||||
|
|
|
||||||
|
|
@ -463,7 +463,7 @@ fn routes(config: &Config) -> Router {
|
||||||
.route("/", get(it_works))
|
.route("/", get(it_works))
|
||||||
.fallback(not_found);
|
.fallback(not_found);
|
||||||
|
|
||||||
if config.allow_federation {
|
if config.federation.enable {
|
||||||
router
|
router
|
||||||
.ruma_route(s2s::get_server_version_route)
|
.ruma_route(s2s::get_server_version_route)
|
||||||
.route("/_matrix/key/v2/server", get(s2s::get_server_keys_route))
|
.route("/_matrix/key/v2/server", get(s2s::get_server_keys_route))
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn max_fetch_prev_events(&self) -> u16 {
|
pub(crate) fn max_fetch_prev_events(&self) -> u16 {
|
||||||
self.config.max_fetch_prev_events
|
self.config.federation.max_fetch_prev_events
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn allow_registration(&self) -> bool {
|
pub(crate) fn allow_registration(&self) -> bool {
|
||||||
|
|
@ -336,7 +336,7 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn allow_federation(&self) -> bool {
|
pub(crate) fn allow_federation(&self) -> bool {
|
||||||
self.config.allow_federation
|
self.config.federation.enable
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn allow_room_creation(&self) -> bool {
|
pub(crate) fn allow_room_creation(&self) -> bool {
|
||||||
|
|
@ -352,7 +352,7 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn trusted_servers(&self) -> &[OwnedServerName] {
|
pub(crate) fn trusted_servers(&self) -> &[OwnedServerName] {
|
||||||
&self.config.trusted_servers
|
&self.config.federation.trusted_servers
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn dns_resolver(&self) -> &TokioAsyncResolver {
|
pub(crate) fn dns_resolver(&self) -> &TokioAsyncResolver {
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ impl Service {
|
||||||
sender,
|
sender,
|
||||||
receiver: Mutex::new(receiver),
|
receiver: Mutex::new(receiver),
|
||||||
maximum_requests: Arc::new(Semaphore::new(
|
maximum_requests: Arc::new(Semaphore::new(
|
||||||
config.max_concurrent_requests.into(),
|
config.federation.max_concurrent_requests.into(),
|
||||||
)),
|
)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue