Rename proxy_url config parameter to federation.proxy_url

This commit is contained in:
silverpill 2023-02-22 22:14:42 +00:00
parent 0245eb59a2
commit 21ea50279e
6 changed files with 29 additions and 7 deletions

View file

@ -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

View file

@ -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: []

View file

@ -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<usize>, // deprecated
proxy_url: Option<String>,
#[serde(default)]
pub limits: Limits,
#[serde(default)]
pub retention: RetentionConfig,
pub(super) proxy_url: Option<String>,
#[serde(default)]
pub(super) federation: FederationConfig,
#[serde(default)]
pub blocked_instances: Vec<String>,
@ -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),
}
}

View file

@ -0,0 +1,6 @@
use serde::Deserialize;
#[derive(Clone, Default, Deserialize)]
pub struct FederationConfig {
pub proxy_url: Option<String>,
}

View file

@ -1,6 +1,7 @@
mod blockchain;
mod config;
mod environment;
mod federation;
mod limits;
mod loader;
mod retention;

View file

@ -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));