From 21ea50279ebf70c00b540c5cb9ee20f546d2ec0a Mon Sep 17 00:00:00 2001 From: silverpill Date: Wed, 22 Feb 2023 22:14:42 +0000 Subject: [PATCH] Rename proxy_url config parameter to federation.proxy_url --- CHANGELOG.md | 5 +++++ contrib/mitra_config.yaml | 8 +++++--- mitra-config/src/config.rs | 10 +++++++--- mitra-config/src/federation.rs | 6 ++++++ mitra-config/src/lib.rs | 1 + mitra-config/src/loader.rs | 6 +++++- 6 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 mitra-config/src/federation.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 480e1dc..4f54a7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Set fetcher timeout to 3 minutes. - Set deliverer timeout to 30 seconds. +- Added `federation` parameter group to configuration. + +### Deprecated + +- Deprecated `proxy_url` configuration paramter (replaced by `federation.proxy_url`). ## [1.14.0] - 2023-02-22 diff --git a/contrib/mitra_config.yaml b/contrib/mitra_config.yaml index d144112..534796e 100644 --- a/contrib/mitra_config.yaml +++ b/contrib/mitra_config.yaml @@ -29,9 +29,6 @@ registration: # EIP-4361 login message #login_message: 'Do not sign this message on other sites!' -# Proxy for outgoing requests -#proxy_url: 'socks5h://127.0.0.1:9050' - # Limits #limits: # media: @@ -44,6 +41,11 @@ retention: extraneous_posts: 50 empty_profiles: 150 +# Federation parameters +#federation: +# # Proxy for outgoing requests +# #proxy_url: 'socks5h://127.0.0.1:9050' + # List of blocked domains #blocked_instances: [] diff --git a/mitra-config/src/config.rs b/mitra-config/src/config.rs index 5fac64c..7163fc6 100644 --- a/mitra-config/src/config.rs +++ b/mitra-config/src/config.rs @@ -13,6 +13,7 @@ use mitra_utils::urls::normalize_url; use super::blockchain::BlockchainConfig; use super::environment::Environment; +use super::federation::FederationConfig; use super::limits::Limits; use super::retention::RetentionConfig; use super::MITRA_VERSION; @@ -99,14 +100,17 @@ pub struct Config { pub(super) post_character_limit: Option, // deprecated - proxy_url: Option, - #[serde(default)] pub limits: Limits, #[serde(default)] pub retention: RetentionConfig, + pub(super) proxy_url: Option, + + #[serde(default)] + pub(super) federation: FederationConfig, + #[serde(default)] pub blocked_instances: Vec, @@ -130,7 +134,7 @@ impl Config { Instance { _url: self.try_instance_url().unwrap(), actor_key: self.instance_rsa_key.clone().unwrap(), - proxy_url: self.proxy_url.clone(), + proxy_url: self.federation.proxy_url.clone(), is_private: matches!(self.environment, Environment::Development), } } diff --git a/mitra-config/src/federation.rs b/mitra-config/src/federation.rs new file mode 100644 index 0000000..da4316b --- /dev/null +++ b/mitra-config/src/federation.rs @@ -0,0 +1,6 @@ +use serde::Deserialize; + +#[derive(Clone, Default, Deserialize)] +pub struct FederationConfig { + pub proxy_url: Option, +} diff --git a/mitra-config/src/lib.rs b/mitra-config/src/lib.rs index 6f539c7..58a3778 100644 --- a/mitra-config/src/lib.rs +++ b/mitra-config/src/lib.rs @@ -1,6 +1,7 @@ mod blockchain; mod config; mod environment; +mod federation; mod limits; mod loader; mod retention; diff --git a/mitra-config/src/loader.rs b/mitra-config/src/loader.rs index e8cc46c..ed89128 100644 --- a/mitra-config/src/loader.rs +++ b/mitra-config/src/loader.rs @@ -113,6 +113,7 @@ pub fn parse_config() -> (Config, Vec<&'static str>) { panic!("both ipfs_api_url and ipfs_gateway_url must be set"); }; + // Migrations if let Some(registrations_open) = config.registrations_open { // Change type if 'registrations_open' parameter is used warnings.push("'registrations_open' setting is deprecated, use 'registration.type' instead"); @@ -122,11 +123,14 @@ pub fn parse_config() -> (Config, Vec<&'static str>) { config.registration.registration_type = RegistrationType::Invite; }; }; - if let Some(post_character_limit) = config.post_character_limit { warnings.push("'post_character_limit' setting is deprecated, use 'limits.posts.character_limit' instead"); config.limits.posts.character_limit = post_character_limit; }; + if let Some(ref proxy_url) = config.proxy_url { + warnings.push("'proxy_url' setting is deprecated, use 'federation.proxy_url' instead"); + config.federation.proxy_url = Some(proxy_url.to_string()); + }; // Insert instance RSA key config.instance_rsa_key = Some(read_instance_rsa_key(&config.storage_dir));