From 85f438ef65b7793b45936f3b5de95a1209a88ec9 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 24 May 2024 00:37:06 +0000 Subject: [PATCH] fix image search still being accessible when disabled --- src/engines/mod.rs | 6 +++++- src/web/image_proxy.rs | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/engines/mod.rs b/src/engines/mod.rs index 83814f1..3d42621 100644 --- a/src/engines/mod.rs +++ b/src/engines/mod.rs @@ -8,6 +8,7 @@ use std::{ time::{Duration, Instant}, }; +use eyre::bail; use futures::future::join_all; use maud::PreEscaped; use once_cell::sync::Lazy; @@ -536,10 +537,13 @@ pub async fn search( SearchTab::All => { make_requests(query, progress_tx, start_time, &send_engine_progress_update).await? } - SearchTab::Images => { + SearchTab::Images if query.config.image_search.enabled.unwrap() => { make_image_requests(query, progress_tx, start_time, &send_engine_progress_update) .await? } + _ => { + bail!("unknown tab"); + } } Ok(()) diff --git a/src/web/image_proxy.rs b/src/web/image_proxy.rs index f82f1e8..fae3f08 100644 --- a/src/web/image_proxy.rs +++ b/src/web/image_proxy.rs @@ -13,8 +13,9 @@ pub async fn route( Query(params): Query>, State(config): State>, ) -> Response { - let proxy_config = &config.image_search.proxy; - if !proxy_config.enabled.unwrap() { + let image_search_config = &config.image_search; + let proxy_config = &image_search_config.proxy; + if !image_search_config.enabled.unwrap() || !proxy_config.enabled.unwrap() { return (StatusCode::FORBIDDEN, "Image proxy is disabled").into_response(); }; let url = params.get("url").cloned().unwrap_or_default();