Remove federation settings, rely on sensible defaults instead (#2574)
This affects federation_strict_allowlist and federation_http_fetch_retry_limit
This commit is contained in:
parent
65041a20bb
commit
872c60a013
9 changed files with 12 additions and 37 deletions
|
@ -145,8 +145,6 @@ pub struct CreateSite {
|
||||||
pub rate_limit_search_per_second: Option<i32>,
|
pub rate_limit_search_per_second: Option<i32>,
|
||||||
pub federation_enabled: Option<bool>,
|
pub federation_enabled: Option<bool>,
|
||||||
pub federation_debug: Option<bool>,
|
pub federation_debug: Option<bool>,
|
||||||
pub federation_strict_allowlist: Option<bool>,
|
|
||||||
pub federation_http_fetch_retry_limit: Option<i32>,
|
|
||||||
pub federation_worker_count: Option<i32>,
|
pub federation_worker_count: Option<i32>,
|
||||||
pub captcha_enabled: Option<bool>,
|
pub captcha_enabled: Option<bool>,
|
||||||
pub captcha_difficulty: Option<String>,
|
pub captcha_difficulty: Option<String>,
|
||||||
|
@ -192,8 +190,6 @@ pub struct EditSite {
|
||||||
pub rate_limit_search_per_second: Option<i32>,
|
pub rate_limit_search_per_second: Option<i32>,
|
||||||
pub federation_enabled: Option<bool>,
|
pub federation_enabled: Option<bool>,
|
||||||
pub federation_debug: Option<bool>,
|
pub federation_debug: Option<bool>,
|
||||||
pub federation_strict_allowlist: Option<bool>,
|
|
||||||
pub federation_http_fetch_retry_limit: Option<i32>,
|
|
||||||
pub federation_worker_count: Option<i32>,
|
pub federation_worker_count: Option<i32>,
|
||||||
pub captcha_enabled: Option<bool>,
|
pub captcha_enabled: Option<bool>,
|
||||||
pub captcha_difficulty: Option<String>,
|
pub captcha_difficulty: Option<String>,
|
||||||
|
|
|
@ -112,8 +112,6 @@ impl PerformCrud for CreateSite {
|
||||||
.actor_name_max_length(data.actor_name_max_length)
|
.actor_name_max_length(data.actor_name_max_length)
|
||||||
.federation_enabled(data.federation_enabled)
|
.federation_enabled(data.federation_enabled)
|
||||||
.federation_debug(data.federation_debug)
|
.federation_debug(data.federation_debug)
|
||||||
.federation_strict_allowlist(data.federation_strict_allowlist)
|
|
||||||
.federation_http_fetch_retry_limit(data.federation_http_fetch_retry_limit)
|
|
||||||
.federation_worker_count(data.federation_worker_count)
|
.federation_worker_count(data.federation_worker_count)
|
||||||
.captcha_enabled(data.captcha_enabled)
|
.captcha_enabled(data.captcha_enabled)
|
||||||
.captcha_difficulty(data.captcha_difficulty.clone())
|
.captcha_difficulty(data.captcha_difficulty.clone())
|
||||||
|
|
|
@ -115,8 +115,6 @@ impl PerformCrud for EditSite {
|
||||||
.actor_name_max_length(data.actor_name_max_length)
|
.actor_name_max_length(data.actor_name_max_length)
|
||||||
.federation_enabled(data.federation_enabled)
|
.federation_enabled(data.federation_enabled)
|
||||||
.federation_debug(data.federation_debug)
|
.federation_debug(data.federation_debug)
|
||||||
.federation_strict_allowlist(data.federation_strict_allowlist)
|
|
||||||
.federation_http_fetch_retry_limit(data.federation_http_fetch_retry_limit)
|
|
||||||
.federation_worker_count(data.federation_worker_count)
|
.federation_worker_count(data.federation_worker_count)
|
||||||
.captcha_enabled(data.captcha_enabled)
|
.captcha_enabled(data.captcha_enabled)
|
||||||
.captcha_difficulty(data.captcha_difficulty.clone())
|
.captcha_difficulty(data.captcha_difficulty.clone())
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::{local_instance, ActorType};
|
use crate::{local_instance, ActorType, FEDERATION_HTTP_FETCH_LIMIT};
|
||||||
use activitypub_federation::{core::object_id::ObjectId, traits::ApubObject};
|
use activitypub_federation::{core::object_id::ObjectId, traits::ApubObject};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use lemmy_db_schema::{newtypes::DbUrl, source::local_site::LocalSite};
|
use lemmy_db_schema::newtypes::DbUrl;
|
||||||
use lemmy_utils::error::LemmyError;
|
use lemmy_utils::error::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -47,14 +47,8 @@ where
|
||||||
);
|
);
|
||||||
debug!("Fetching webfinger url: {}", &fetch_url);
|
debug!("Fetching webfinger url: {}", &fetch_url);
|
||||||
|
|
||||||
let local_site = LocalSite::read(context.pool()).await;
|
|
||||||
let http_fetch_retry_limit = local_site
|
|
||||||
.as_ref()
|
|
||||||
.map(|l| l.federation_http_fetch_retry_limit)
|
|
||||||
.unwrap_or(25);
|
|
||||||
|
|
||||||
*request_counter += 1;
|
*request_counter += 1;
|
||||||
if *request_counter > http_fetch_retry_limit {
|
if *request_counter > FEDERATION_HTTP_FETCH_LIMIT {
|
||||||
return Err(LemmyError::from_message("Request retry limit reached"));
|
return Err(LemmyError::from_message("Request retry limit reached"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ pub(crate) mod mentions;
|
||||||
pub mod objects;
|
pub mod objects;
|
||||||
pub mod protocol;
|
pub mod protocol;
|
||||||
|
|
||||||
|
const FEDERATION_HTTP_FETCH_LIMIT: i32 = 25;
|
||||||
|
|
||||||
static CONTEXT: Lazy<Vec<serde_json::Value>> = Lazy::new(|| {
|
static CONTEXT: Lazy<Vec<serde_json::Value>> = Lazy::new(|| {
|
||||||
serde_json::from_str(include_str!("../assets/lemmy/context.json")).expect("parse context")
|
serde_json::from_str(include_str!("../assets/lemmy/context.json")).expect("parse context")
|
||||||
});
|
});
|
||||||
|
@ -44,17 +46,13 @@ async fn local_instance(context: &LemmyContext) -> &'static LocalInstance {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|l| l.federation_worker_count)
|
.map(|l| l.federation_worker_count)
|
||||||
.unwrap_or(64) as u64;
|
.unwrap_or(64) as u64;
|
||||||
let http_fetch_retry_limit = local_site
|
|
||||||
.as_ref()
|
|
||||||
.map(|l| l.federation_http_fetch_retry_limit)
|
|
||||||
.unwrap_or(25);
|
|
||||||
let federation_debug = local_site
|
let federation_debug = local_site
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|l| l.federation_debug)
|
.map(|l| l.federation_debug)
|
||||||
.unwrap_or(true);
|
.unwrap_or(true);
|
||||||
|
|
||||||
let settings = InstanceSettings::builder()
|
let settings = InstanceSettings::builder()
|
||||||
.http_fetch_retry_limit(http_fetch_retry_limit)
|
.http_fetch_retry_limit(FEDERATION_HTTP_FETCH_LIMIT)
|
||||||
.worker_count(worker_count)
|
.worker_count(worker_count)
|
||||||
.debug(federation_debug)
|
.debug(federation_debug)
|
||||||
.http_signature_compat(true)
|
.http_signature_compat(true)
|
||||||
|
@ -178,13 +176,8 @@ pub(crate) fn check_apub_id_valid_with_strictness(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(allowed) = local_site_data.allowed_instances.as_ref() {
|
if let Some(allowed) = local_site_data.allowed_instances.as_ref() {
|
||||||
// Only check allowlist if this is a community, or strict allowlist is enabled.
|
// Only check allowlist if this is a community
|
||||||
let strict_allowlist = local_site_data
|
if is_strict {
|
||||||
.local_site
|
|
||||||
.as_ref()
|
|
||||||
.map(|l| l.federation_strict_allowlist)
|
|
||||||
.unwrap_or(true);
|
|
||||||
if is_strict || strict_allowlist {
|
|
||||||
// need to allow this explicitly because apub receive might contain objects from our local
|
// need to allow this explicitly because apub receive might contain objects from our local
|
||||||
// instance.
|
// instance.
|
||||||
let mut allowed_and_local = allowed.clone();
|
let mut allowed_and_local = allowed.clone();
|
||||||
|
|
|
@ -690,8 +690,6 @@ table! {
|
||||||
actor_name_max_length -> Int4,
|
actor_name_max_length -> Int4,
|
||||||
federation_enabled -> Bool,
|
federation_enabled -> Bool,
|
||||||
federation_debug -> Bool,
|
federation_debug -> Bool,
|
||||||
federation_strict_allowlist -> Bool,
|
|
||||||
federation_http_fetch_retry_limit -> Int4,
|
|
||||||
federation_worker_count -> Int4,
|
federation_worker_count -> Int4,
|
||||||
captcha_enabled -> Bool,
|
captcha_enabled -> Bool,
|
||||||
captcha_difficulty -> Text,
|
captcha_difficulty -> Text,
|
||||||
|
|
|
@ -29,8 +29,6 @@ pub struct LocalSite {
|
||||||
pub actor_name_max_length: i32,
|
pub actor_name_max_length: i32,
|
||||||
pub federation_enabled: bool,
|
pub federation_enabled: bool,
|
||||||
pub federation_debug: bool,
|
pub federation_debug: bool,
|
||||||
pub federation_strict_allowlist: bool,
|
|
||||||
pub federation_http_fetch_retry_limit: i32,
|
|
||||||
pub federation_worker_count: i32,
|
pub federation_worker_count: i32,
|
||||||
pub captcha_enabled: bool,
|
pub captcha_enabled: bool,
|
||||||
pub captcha_difficulty: String,
|
pub captcha_difficulty: String,
|
||||||
|
@ -63,8 +61,6 @@ pub struct LocalSiteInsertForm {
|
||||||
pub actor_name_max_length: Option<i32>,
|
pub actor_name_max_length: Option<i32>,
|
||||||
pub federation_enabled: Option<bool>,
|
pub federation_enabled: Option<bool>,
|
||||||
pub federation_debug: Option<bool>,
|
pub federation_debug: Option<bool>,
|
||||||
pub federation_strict_allowlist: Option<bool>,
|
|
||||||
pub federation_http_fetch_retry_limit: Option<i32>,
|
|
||||||
pub federation_worker_count: Option<i32>,
|
pub federation_worker_count: Option<i32>,
|
||||||
pub captcha_enabled: Option<bool>,
|
pub captcha_enabled: Option<bool>,
|
||||||
pub captcha_difficulty: Option<String>,
|
pub captcha_difficulty: Option<String>,
|
||||||
|
@ -93,8 +89,6 @@ pub struct LocalSiteUpdateForm {
|
||||||
pub actor_name_max_length: Option<i32>,
|
pub actor_name_max_length: Option<i32>,
|
||||||
pub federation_enabled: Option<bool>,
|
pub federation_enabled: Option<bool>,
|
||||||
pub federation_debug: Option<bool>,
|
pub federation_debug: Option<bool>,
|
||||||
pub federation_strict_allowlist: Option<bool>,
|
|
||||||
pub federation_http_fetch_retry_limit: Option<i32>,
|
|
||||||
pub federation_worker_count: Option<i32>,
|
pub federation_worker_count: Option<i32>,
|
||||||
pub captcha_enabled: Option<bool>,
|
pub captcha_enabled: Option<bool>,
|
||||||
pub captcha_difficulty: Option<String>,
|
pub captcha_difficulty: Option<String>,
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
alter table local_site add column federation_strict_allowlist bool default true not null;
|
||||||
|
alter table local_site add column federation_http_fetch_retry_limit int not null default 25;
|
|
@ -0,0 +1,2 @@
|
||||||
|
alter table local_site drop column federation_strict_allowlist;
|
||||||
|
alter table local_site drop column federation_http_fetch_retry_limit;
|
Loading…
Reference in a new issue