refactor(api): drop Bunny for pluggable cache purge adapters (#2742)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-13 20:28:56 +02:00
1 parent 84dcf6b8a8
commit ca7ddd9272
45 files changed
+929 -977

No files matched your search

+3 -22
View File
@@ -8,10 +8,10 @@ use crate::constants;
use crate::secret::{SecretBytes, SecretString};
use parse::{
EnvMap, decode_upload_relay_secret, default_native_transform_concurrency, non_empty,
parse_bool, parse_bucket_style, parse_f32, parse_ip_list_env, parse_mode_env,
parse_storage_backend, parse_u16, parse_u64, parse_usize, validate_read_endpoint,
parse_bool, parse_bucket_style, parse_f32, parse_mode_env, parse_storage_backend, parse_u16,
parse_u64, parse_usize, validate_read_endpoint,
};
use std::{env, net::IpAddr, path::PathBuf};
use std::{env, path::PathBuf};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum StorageBackend {
@@ -92,9 +92,6 @@ pub struct Config {
pub storage: StorageConfig,
pub media: MediaServingConfig,
pub upload_relay: UploadRelayConfig,
pub bunny_ip_gate_enabled: bool,
pub bunny_ip_gate_trusted_proxies: Vec<IpAddr>,
pub bunny_ip_gate_refresh_secs: u64,
}
impl Config {
@@ -170,22 +167,6 @@ impl Config {
storage: StorageConfig::load(&env)?,
media: MediaServingConfig::load(&env)?,
upload_relay: UploadRelayConfig::load(&env, mode)?,
bunny_ip_gate_enabled: parse_bool(
"FLUXER_MEDIA_PROXY_BUNNY_IP_GATE_ENABLED",
env.get("FLUXER_MEDIA_PROXY_BUNNY_IP_GATE_ENABLED"),
)?
.unwrap_or(false),
bunny_ip_gate_trusted_proxies: parse_ip_list_env(
"FLUXER_MEDIA_PROXY_BUNNY_IP_GATE_TRUSTED_PROXIES",
env.get("FLUXER_MEDIA_PROXY_BUNNY_IP_GATE_TRUSTED_PROXIES"),
)?,
bunny_ip_gate_refresh_secs: parse_u64(
"FLUXER_MEDIA_PROXY_BUNNY_IP_GATE_REFRESH_SECS",
env.get("FLUXER_MEDIA_PROXY_BUNNY_IP_GATE_REFRESH_SECS"),
3_600,
60,
24 * 60 * 60,
)?,
})
}
}
-19
View File
@@ -3,7 +3,6 @@
use super::{BucketStyle, DeploymentMode, StorageBackend};
use crate::secret::SecretBytes;
use base64::{Engine as _, engine::general_purpose};
use std::net::IpAddr;
#[derive(Debug, Default)]
pub(super) struct EnvMap(Vec<(String, String)>);
@@ -213,24 +212,6 @@ where
Ok(parsed)
}
pub(super) fn parse_ip_list_env(var_name: &str, raw: Option<&str>) -> anyhow::Result<Vec<IpAddr>> {
let Some(raw) = raw.map(str::trim).filter(|s| !s.is_empty()) else {
return Ok(Vec::new());
};
let mut out = Vec::new();
for entry in raw.split(',') {
let entry = entry.trim();
if entry.is_empty() {
continue;
}
let ip = entry
.parse::<IpAddr>()
.map_err(|_| anyhow::anyhow!("{var_name} contains invalid IP: {entry}"))?;
out.push(ip);
}
Ok(out)
}
pub(super) fn default_native_transform_concurrency() -> usize {
std::thread::available_parallelism()
.map(usize::from)
+1 -32
View File
@@ -410,7 +410,7 @@ fn every_deployment_mode_and_storage_backend_variant_parses() {
}
#[test]
fn upload_relay_spool_and_bunny_ip_gate_keys_apply() {
fn upload_relay_spool_keys_apply() {
let cfg = Config::load_from_iter([
("FLUXER_MEDIA_PROXY_SECRET_KEY", "secret"),
(
@@ -425,12 +425,6 @@ fn upload_relay_spool_and_bunny_ip_gate_keys_apply() {
"FLUXER_MEDIA_PROXY_UPLOAD_RELAY_SPOOL_MAX_TOTAL_BYTES",
"1073741824",
),
("FLUXER_MEDIA_PROXY_BUNNY_IP_GATE_ENABLED", "yes"),
(
"FLUXER_MEDIA_PROXY_BUNNY_IP_GATE_TRUSTED_PROXIES",
"10.0.0.1, 2001:db8::1 ,",
),
("FLUXER_MEDIA_PROXY_BUNNY_IP_GATE_REFRESH_SECS", "900"),
])
.unwrap();
@@ -440,31 +434,6 @@ fn upload_relay_spool_and_bunny_ip_gate_keys_apply() {
);
assert_eq!(2 << 20, cfg.upload_relay.spool_chunk_bytes);
assert_eq!(1 << 30, cfg.upload_relay.spool_max_total_bytes);
assert!(cfg.bunny_ip_gate_enabled);
assert_eq!(
vec![
"10.0.0.1".parse::<IpAddr>().unwrap(),
"2001:db8::1".parse::<IpAddr>().unwrap(),
],
cfg.bunny_ip_gate_trusted_proxies
);
assert_eq!(900, cfg.bunny_ip_gate_refresh_secs);
}
#[test]
fn rejects_invalid_bunny_ip_gate_trusted_proxies() {
let err = Config::load_from_iter([
("FLUXER_MEDIA_PROXY_SECRET_KEY", "secret"),
(
"FLUXER_MEDIA_PROXY_BUNNY_IP_GATE_TRUSTED_PROXIES",
"10.0.0.1,not-an-ip",
),
])
.unwrap_err();
assert!(
err.to_string()
.contains("FLUXER_MEDIA_PROXY_BUNNY_IP_GATE_TRUSTED_PROXIES")
);
}
#[test]