From 03fc50fa46c42c3ff7dfd5aee8ef30b740ebd312 Mon Sep 17 00:00:00 2001 From: Hampus Date: Wed, 25 Nov 2026 06:50:24 +0100 Subject: [PATCH] refactor: drop dead code in the media proxy and push --- fluxer_media_proxy/src/http_client/mod.rs | 4 ---- fluxer_media_proxy/src/http_client/retry.rs | 2 -- fluxer_media_proxy/src/media_process/apng.rs | 2 -- .../src/native/nsfw_frame_output.rs | 1 - .../src/native_shim/gif_timing.c | 2 -- .../src/native_shim/nsfw_frame.c | 3 --- .../src/public_net_policy/resolver.rs | 2 -- .../src/server/download_stream.rs | 2 -- fluxer_media_proxy/src/server/external/mod.rs | 5 ----- .../src/server/external/response.rs | 2 -- .../src/server/routes/internal.rs | 16 ---------------- .../src/server/stored/passthrough.rs | 2 -- .../src/server/stored/response.rs | 3 --- .../src/server/transform/execution.rs | 4 ---- fluxer_media_proxy/src/server/transform/mod.rs | 2 -- fluxer_media_proxy/src/storage/s3.rs | 3 --- fluxer_push/src/config.rs | 18 ------------------ 17 files changed, 73 deletions(-) diff --git a/fluxer_media_proxy/src/http_client/mod.rs b/fluxer_media_proxy/src/http_client/mod.rs index 0ed83561d..f9c860840 100644 --- a/fluxer_media_proxy/src/http_client/mod.rs +++ b/fluxer_media_proxy/src/http_client/mod.rs @@ -99,10 +99,6 @@ impl Default for HTTPClientOptions { } pub fn build_raw(options: HTTPClientOptions) -> Result { - // System proxy discovery stays on. HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and NO_PROXY are part - // of the deployment's egress configuration, so an operator who funnels egress through a - // gateway gets storage reads and external fetches routed through it. The healthcheck probe - // is the one client that opts out, because it only ever dials this process on loopback. let mut builder = reqwest::Client::builder() .connect_timeout(Duration::from_millis(options.connect_timeout_ms.get())) .redirect(reqwest::redirect::Policy::none()) diff --git a/fluxer_media_proxy/src/http_client/retry.rs b/fluxer_media_proxy/src/http_client/retry.rs index edaa23ef0..d351c9016 100644 --- a/fluxer_media_proxy/src/http_client/retry.rs +++ b/fluxer_media_proxy/src/http_client/retry.rs @@ -93,8 +93,6 @@ fn retryable_status(status: StatusCode) -> Option { } fn retryable_error(error: &MiddlewareError) -> Option { - // A pinned-resolver rejection is a policy decision, not a transient fault, and retrying it only - // repeats the same lookup against a name the caller supplied. if crate::public_net_policy::is_pinned_dns_failure(error) { return Some(Retryable::Fatal); } diff --git a/fluxer_media_proxy/src/media_process/apng.rs b/fluxer_media_proxy/src/media_process/apng.rs index f88626ef5..e244ec630 100644 --- a/fluxer_media_proxy/src/media_process/apng.rs +++ b/fluxer_media_proxy/src/media_process/apng.rs @@ -461,8 +461,6 @@ pub(super) fn encode_animated_apng( let mut sequence_number = 0u32; let mut encoded_frames = 0usize; for frame_index in 0..frame_count { - // Overrunning the encode deadline shortens the animation instead of failing the request; - // the flush headroom is reserved so the frames already written still reach the client. if ensure_deadline_pending(deadline).is_err() { break; } diff --git a/fluxer_media_proxy/src/native/nsfw_frame_output.rs b/fluxer_media_proxy/src/native/nsfw_frame_output.rs index 6076f7e5a..d0c8a2ae2 100644 --- a/fluxer_media_proxy/src/native/nsfw_frame_output.rs +++ b/fluxer_media_proxy/src/native/nsfw_frame_output.rs @@ -40,7 +40,6 @@ impl NSFWFrameOutput { .try_reserve_exact(self.expected) .map_err(|_| NSFWFrameCopyError::AllocationFailed)?; for slot in self.slots.iter().take(self.expected) { - // a sample the native decoder could not reach leaves its slot empty let Some(data) = NonNull::new(slot.data.cast::()) else { if slot.len != 0 { return Err(NSFWFrameCopyError::InvalidOutput); diff --git a/fluxer_media_proxy/src/native_shim/gif_timing.c b/fluxer_media_proxy/src/native_shim/gif_timing.c index 9d69f1174..2a3fa14d5 100644 --- a/fluxer_media_proxy/src/native_shim/gif_timing.c +++ b/fluxer_media_proxy/src/native_shim/gif_timing.c @@ -228,8 +228,6 @@ int fluxer_read_gif_frame_delays(const uint8_t *bytes, size_t len, } int status = skip_gif_image_block(bytes, len, &offset, &block_count); if (status != FLUXER_NATIVE_STATUS_OK) return status; - /* A frame with no Graphics Control Extension declares no delay, which renders at the - * 100 ms browser default rather than the fast-frame minimum. */ int delay_cs = has_pending_delay ? pending_delay_cs : FLUXER_DEFAULT_ANIMATION_FRAME_DELAY_MS / 10; diff --git a/fluxer_media_proxy/src/native_shim/nsfw_frame.c b/fluxer_media_proxy/src/native_shim/nsfw_frame.c index 998afd9ab..8a72cba1f 100644 --- a/fluxer_media_proxy/src/native_shim/nsfw_frame.c +++ b/fluxer_media_proxy/src/native_shim/nsfw_frame.c @@ -957,9 +957,6 @@ static int fluxer_nsfw_decode_targets( continue; } if (fluxer_nsfw_sample_failure_fatal(status)) return status; - /* A sample the decoder cannot reach falls back to the last frame it did - decode, and otherwise leaves its slot empty, so the samples that did - decode still reach the classifier. */ if (group.next < limit && outputs[group.next].data == NULL) { (void)fluxer_nsfw_emit_candidate(&group); } diff --git a/fluxer_media_proxy/src/public_net_policy/resolver.rs b/fluxer_media_proxy/src/public_net_policy/resolver.rs index bab87f642..5b1ca38d7 100644 --- a/fluxer_media_proxy/src/public_net_policy/resolver.rs +++ b/fluxer_media_proxy/src/public_net_policy/resolver.rs @@ -54,8 +54,6 @@ impl Resolve for PinnedDnsResolver { } } -// reqwest and the hyper connector box this rejection behind errors of their own, so the source -// chain is the only way back to the decision the resolver made. pub fn is_pinned_dns_failure(error: &(dyn std::error::Error + 'static)) -> bool { let mut current = Some(error); while let Some(error) = current { diff --git a/fluxer_media_proxy/src/server/download_stream.rs b/fluxer_media_proxy/src/server/download_stream.rs index 33e1d7a50..658652db7 100644 --- a/fluxer_media_proxy/src/server/download_stream.rs +++ b/fluxer_media_proxy/src/server/download_stream.rs @@ -42,8 +42,6 @@ impl DownloadStreamPolicy { } } - // Only the external route feeds the overrun counter: a stored object that outruns its own - // Content-Length is a store bug, not the misbehaving-origin signal that series tracks. pub(in crate::server) fn for_external( socket_io_timeout_ms: NonZeroU64, overruns: Arc, diff --git a/fluxer_media_proxy/src/server/external/mod.rs b/fluxer_media_proxy/src/server/external/mod.rs index 0c8136df2..f62a1790b 100644 --- a/fluxer_media_proxy/src/server/external/mod.rs +++ b/fluxer_media_proxy/src/server/external/mod.rs @@ -54,8 +54,6 @@ const EXTERNAL_HINT_CACHE_ENTRIES: u64 = 4096; pub(in crate::server) type ExternalHintCache = moka::sync::Cache; -// What the origin last served for a url, so a repeat transform of a hot embed can be -// answered from the transform cache instead of downloading the origin asset again. #[derive(Clone)] pub(in crate::server) struct ExternalHint { url: String, @@ -303,9 +301,6 @@ pub(in crate::server) async fn serve_external( serve_fetched_external(prepared, fetched).await } -// Unlike the object store, a third-party origin answers a GET by sending a body the proxy -// then discards, and an untrusted content type makes the proxy buffer that body in full. -// A metadata-only probe is worth its own upstream HEAD here. async fn external_head_passthrough( app: &AppState, url: &str, diff --git a/fluxer_media_proxy/src/server/external/response.rs b/fluxer_media_proxy/src/server/external/response.rs index 39d12476a..ae201efa9 100644 --- a/fluxer_media_proxy/src/server/external/response.rs +++ b/fluxer_media_proxy/src/server/external/response.rs @@ -23,8 +23,6 @@ pub(super) enum ExternalStreamDecision { Buffer, } -// A passthrough streams on the strength of its content type alone. An upstream that declares no -// length still streams; the declared length only decides whether the response can name one. pub(super) fn external_stream_decision( allow_stream: bool, content_length: Option, diff --git a/fluxer_media_proxy/src/server/routes/internal.rs b/fluxer_media_proxy/src/server/routes/internal.rs index 91e154af2..df9d00da2 100644 --- a/fluxer_media_proxy/src/server/routes/internal.rs +++ b/fluxer_media_proxy/src/server/routes/internal.rs @@ -513,15 +513,6 @@ mod tests { segment } - fn authorized_headers() -> HeaderMap { - let mut headers = HeaderMap::new(); - headers.insert( - header::AUTHORIZATION, - HeaderValue::from_static("Bearer secret"), - ); - headers - } - fn json_request(body: String) -> Request { Request::builder() .method(Method::POST) @@ -539,13 +530,6 @@ mod tests { String::from_utf8(bytes.to_vec()).expect("utf8 body") } - #[test] - fn internal_auth_uses_bearer_secret() { - let headers = authorized_headers(); - assert!(check_internal_auth(&headers, "secret")); - assert!(!check_internal_auth(&headers, "other")); - } - #[tokio::test] async fn sniff_requires_the_internal_bearer_secret() { let (_tmp, app) = local_storage_app(); diff --git a/fluxer_media_proxy/src/server/stored/passthrough.rs b/fluxer_media_proxy/src/server/stored/passthrough.rs index aa2720f6a..de2042ed4 100644 --- a/fluxer_media_proxy/src/server/stored/passthrough.rs +++ b/fluxer_media_proxy/src/server/stored/passthrough.rs @@ -263,8 +263,6 @@ fn svg_rasterize_failed_response(cache_identity: &str) -> Response { ) } -/// Resolves the object's full length, preferring what the store already reported on the streamed -/// reply so the common path never needs a second upstream request. async fn passthrough_total_len( app: &Arc, bucket: &str, diff --git a/fluxer_media_proxy/src/server/stored/response.rs b/fluxer_media_proxy/src/server/stored/response.rs index ca43425ce..9b88521c8 100644 --- a/fluxer_media_proxy/src/server/stored/response.rs +++ b/fluxer_media_proxy/src/server/stored/response.rs @@ -53,9 +53,6 @@ pub(super) fn streaming_media_response(response: StreamingMediaResponse<'_>) -> } else { StatusCode::OK }; - // Advertise the range the store actually satisfied, not one recomputed locally: an origin is - // free to answer a different span than the client asked for, and Content-Range must describe - // the bytes in this body. let effective_byte_range = if status == StatusCode::PARTIAL_CONTENT { object.byte_range } else { diff --git a/fluxer_media_proxy/src/server/transform/execution.rs b/fluxer_media_proxy/src/server/transform/execution.rs index a54486c6d..0261ea80c 100644 --- a/fluxer_media_proxy/src/server/transform/execution.rs +++ b/fluxer_media_proxy/src/server/transform/execution.rs @@ -141,10 +141,6 @@ pub(in crate::server) fn coalesced_work_result(result: anyhow::Result) -> } pub(in crate::server) fn transform_error_is_timeout(error: &anyhow::Error) -> bool { - // A shed admission is reported as a timeout: the old era had one admission semaphore whose - // exhaustion surfaced as TimedSemaphoreError::RequestTimeout, so every caller answered 504 - // with its own timeout reason code. Giving a full queue its own class moves the transform - // routes to 503 and metadata SVG rasterize to 400. let admission = error.downcast_ref::(); error.downcast_ref::() == Some(&MediaError::RequestTimeout) || admission == Some(&TimedSemaphoreError::RequestTimeout) diff --git a/fluxer_media_proxy/src/server/transform/mod.rs b/fluxer_media_proxy/src/server/transform/mod.rs index ad1720e41..2ae0fd9bc 100644 --- a/fluxer_media_proxy/src/server/transform/mod.rs +++ b/fluxer_media_proxy/src/server/transform/mod.rs @@ -748,8 +748,6 @@ pub(in crate::server) struct CachedTransformProbe<'a> { pub(in crate::server) params: &'a HashMap, } -// Answers a repeat transform from the cache without the caller fetching the source -// bytes again, so a hot remote asset costs one upstream fetch per cache lifetime. pub(in crate::server) fn cached_transform_response( runtime: &TransformRuntime, probe: CachedTransformProbe<'_>, diff --git a/fluxer_media_proxy/src/storage/s3.rs b/fluxer_media_proxy/src/storage/s3.rs index a9965a648..59fe01d4f 100644 --- a/fluxer_media_proxy/src/storage/s3.rs +++ b/fluxer_media_proxy/src/storage/s3.rs @@ -79,9 +79,6 @@ impl Store { bucket: &str, key: &str, ) -> Result { - // A HEAD is a read, so it follows the same endpoint and signing policy as a body read. - // Sending it to the write origin instead would bypass the configured read endpoint and - // attach credentials to a read the operator configured as unsigned. let url = self.s3_read_url(bucket, key)?; let headers = self.read_headers(bucket, Method::HEAD, &url, &[])?; let response = self.client.head(&url).headers(headers).send().await?; diff --git a/fluxer_push/src/config.rs b/fluxer_push/src/config.rs index 2bbc51575..68f878c15 100644 --- a/fluxer_push/src/config.rs +++ b/fluxer_push/src/config.rs @@ -757,24 +757,6 @@ mod tests { RelayConfig::load_from_iter(extra.iter().copied()) } - #[test] - fn metrics_port_is_off_when_unset() { - assert_eq!(None, delivery(&[]).expect("config").metrics_port); - assert_eq!( - None, - delivery(&[("FLUXER_PUSH_METRICS_PORT", " ")]) - .expect("config") - .metrics_port - ); - } - - #[test] - fn metrics_port_is_read_in_both_modes() { - let extra = [("FLUXER_PUSH_METRICS_PORT", "8082")]; - assert_eq!(Some(8082), delivery(&extra).expect("config").metrics_port); - assert_eq!(Some(8082), relay(&extra).expect("config").metrics_port); - } - #[test] fn metrics_port_must_be_nonzero_and_differ_from_the_service_port() { for port in ["0", "8126", "not-a-port", "70000"] {