From 2a4dd077520c897dc490e1d47905f5eb48698c80 Mon Sep 17 00:00:00 2001 From: Kekma <136650032+KekmaTime@users.noreply.github.com> Date: Mon, 30 Sep 2024 17:52:25 +0530 Subject: [PATCH 01/17] =?UTF-8?q?=E2=9C=A8=20feat:=20config=20option=20to?= =?UTF-8?q?=20configure=20the=20number=20of=20connections=20to=20have=20in?= =?UTF-8?q?=20the=20`reqwest`=20pool=20(#552)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🔧 Config: Updated `number_of_https_connections` for the HTTPS connection pool. * (feat) : added the max idle pool per host option * :memo: docs(config): add documentation back to the `http_adaptive_window_size` option (#532) --------- Co-authored-by: neon_arch Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- src/cache/cacher.rs | 6 +++--- src/config/parser.rs | 5 ++++- src/models/aggregation_models.rs | 14 ++++++++------ src/models/parser_models.rs | 2 +- src/results/aggregator.rs | 3 ++- src/server/routes/search.rs | 2 +- src/templates/partials/search_bar.rs | 2 +- src/templates/partials/settings_tabs/engines.rs | 2 +- .../partials/settings_tabs/user_interface.rs | 4 ++-- websurfx/config.lua | 2 ++ 10 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/cache/cacher.rs b/src/cache/cacher.rs index 604d527..5eac473 100644 --- a/src/cache/cacher.rs +++ b/src/cache/cacher.rs @@ -546,7 +546,7 @@ impl SharedCache { /// # Arguments /// /// * `url` - It takes the search url as an argument which will be used as the key to fetch the - /// cached results from the cache. + /// cached results from the cache. /// /// # Error /// @@ -563,9 +563,9 @@ impl SharedCache { /// # Arguments /// /// * `search_results` - It takes the `SearchResults` as an argument which are results that - /// needs to be cached. + /// needs to be cached. /// * `url` - It takes the search url as an argument which will be used as the key for storing - /// results in the cache. + /// results in the cache. /// /// # Error /// diff --git a/src/config/parser.rs b/src/config/parser.rs index 8bed460..5ff9444 100644 --- a/src/config/parser.rs +++ b/src/config/parser.rs @@ -48,6 +48,8 @@ pub struct Config { pub tcp_connection_keep_alive: u8, /// It stores the pool idle connection timeout in seconds. pub pool_idle_connection_timeout: u8, + /// It stores the number of https connections to keep in the pool. + pub number_of_https_connections: u8, } impl Config { @@ -57,7 +59,7 @@ impl Config { /// # Arguments /// /// * `logging_initialized` - It takes a boolean which ensures that the logging doesn't get - /// initialized twice. Pass false if the logger has not yet been initialized. + /// initialized twice. Pass false if the logger has not yet been initialized. /// /// # Error /// @@ -139,6 +141,7 @@ impl Config { request_timeout: globals.get::<_, u8>("request_timeout")?, tcp_connection_keep_alive: globals.get::<_, u8>("tcp_connection_keep_alive")?, pool_idle_connection_timeout: globals.get::<_, u8>("pool_idle_connection_timeout")?, + number_of_https_connections: globals.get::<_, u8>("number_of_https_connections")?, threads, client_connection_keep_alive: globals.get::<_, u8>("client_connection_keep_alive")?, rate_limiter: RateLimiter { diff --git a/src/models/aggregation_models.rs b/src/models/aggregation_models.rs index 01c67a6..53aa25b 100644 --- a/src/models/aggregation_models.rs +++ b/src/models/aggregation_models.rs @@ -11,7 +11,9 @@ use thesaurus::synonyms; /// A named struct to store the raw scraped search results scraped search results from the /// upstream search engines before aggregating it.It derives the Clone trait which is needed /// to write idiomatic rust using `Iterators`. -/// (href url in html in simple words). +/// +/// (href url in html in simple words). +/// #[derive(Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct SearchResult { @@ -34,7 +36,7 @@ impl SearchResult { /// /// * `title` - The title of the search result. /// * `url` - The url which is accessed when clicked on it - /// (href url in html in simple words). + /// (href url in html in simple words). /// * `description` - The description of the search result. /// * `engine` - The names of the upstream engines from which this results were provided. pub fn new(title: &str, url: &str, description: &str, engine: &[&str]) -> Self { @@ -124,7 +126,7 @@ impl EngineErrorInfo { /// # Arguments /// /// * `error` - It takes the error type which occured while fetching the result from a particular - /// search engine. + /// search engine. /// * `engine` - It takes the name of the engine that failed to provide the requested search results. pub fn new(error: &EngineError, engine: &str) -> Self { Self { @@ -177,11 +179,11 @@ impl SearchResults { /// # Arguments /// /// * `results` - Takes an argument of individual serializable `SearchResult` struct - /// and stores it into a vector of `SearchResult` structs. + /// and stores it into a vector of `SearchResult` structs. /// * `page_query` - Takes an argument of current page`s search query `q` provided in - /// the search url. + /// the search url. /// * `engine_errors_info` - Takes an array of structs which contains information regarding - /// which engines failed with their names, reason and their severity color name. + /// which engines failed with their names, reason and their severity color name. pub fn new(results: Box<[SearchResult]>, engine_errors_info: Box<[EngineErrorInfo]>) -> Self { Self { results, diff --git a/src/models/parser_models.rs b/src/models/parser_models.rs index 24b3fd8..5f578a5 100644 --- a/src/models/parser_models.rs +++ b/src/models/parser_models.rs @@ -29,7 +29,7 @@ impl Style { /// /// * `theme` - It takes the parsed theme option used to set a theme for the website. /// * `colorscheme` - It takes the parsed colorscheme option used to set a colorscheme - /// for the theme being used. + /// for the theme being used. pub fn new(theme: String, colorscheme: String, animation: Option) -> Self { Style { theme, diff --git a/src/results/aggregator.rs b/src/results/aggregator.rs index 009111b..65d5a5e 100644 --- a/src/results/aggregator.rs +++ b/src/results/aggregator.rs @@ -60,7 +60,7 @@ type FutureVec = /// * `debug` - Accepts a boolean value to enable or disable debug mode option. /// * `upstream_search_engines` - Accepts a vector of search engine names which was selected by the /// * `request_timeout` - Accepts a time (secs) as a value which controls the server request timeout. -/// user through the UI or the config file. +/// user through the UI or the config file. /// /// # Error /// @@ -81,6 +81,7 @@ pub async fn aggregate( config.pool_idle_connection_timeout as u64, )) .tcp_keepalive(Duration::from_secs(config.tcp_connection_keep_alive as u64)) + .pool_max_idle_per_host(config.number_of_https_connections as usize) .connect_timeout(Duration::from_secs(config.request_timeout as u64)) // Add timeout to request to avoid DDOSing the server .https_only(true) .gzip(true) diff --git a/src/server/routes/search.rs b/src/server/routes/search.rs index d43ddec..9fa6877 100644 --- a/src/server/routes/search.rs +++ b/src/server/routes/search.rs @@ -146,7 +146,7 @@ pub async fn search( /// # Arguments /// /// * `url` - It takes the url of the current page that requested the search results for a -/// particular search query. +/// particular search query. /// * `config` - It takes a parsed config struct. /// * `query` - It takes the page number as u32 value. /// * `req` - It takes the `HttpRequest` struct as a value. diff --git a/src/templates/partials/search_bar.rs b/src/templates/partials/search_bar.rs index c40244c..9c6ea9c 100644 --- a/src/templates/partials/search_bar.rs +++ b/src/templates/partials/search_bar.rs @@ -12,7 +12,7 @@ const SAFE_SEARCH_LEVELS_NAME: [&str; 3] = ["None", "Low", "Moderate"]; /// # Arguments /// /// * `engine_errors_info` - It takes the engine errors list containing errors for each upstream -/// search engine which failed to provide results as an argument. +/// search engine which failed to provide results as an argument. /// * `safe_search_level` - It takes the safe search level with values from 0-2 as an argument. /// * `query` - It takes the current search query provided by user as an argument. /// diff --git a/src/templates/partials/settings_tabs/engines.rs b/src/templates/partials/settings_tabs/engines.rs index de67ac7..ad67f80 100644 --- a/src/templates/partials/settings_tabs/engines.rs +++ b/src/templates/partials/settings_tabs/engines.rs @@ -9,7 +9,7 @@ use maud::{html, Markup}; /// # Arguments /// /// * `engine_names` - It takes the key value pair list of all available engine names and there corresponding -/// selected (enabled/disabled) value as an argument. +/// selected (enabled/disabled) value as an argument. /// /// # Returns /// diff --git a/src/templates/partials/settings_tabs/user_interface.rs b/src/templates/partials/settings_tabs/user_interface.rs index 8f685be..87b0fb3 100644 --- a/src/templates/partials/settings_tabs/user_interface.rs +++ b/src/templates/partials/settings_tabs/user_interface.rs @@ -11,9 +11,9 @@ use std::fs::read_dir; /// # Arguments /// /// * `style_type` - It takes the style type of the values `theme` and `colorscheme` as an -/// argument. +/// argument. /// * `selected_style` - It takes the currently selected style value provided via the config file -/// as an argument. +/// as an argument. /// /// # Error /// diff --git a/websurfx/config.lua b/websurfx/config.lua index f346c1f..16c6146 100644 --- a/websurfx/config.lua +++ b/websurfx/config.lua @@ -18,6 +18,8 @@ rate_limiter = { } -- Set whether the server will use an adaptive/dynamic HTTPS window size, see https://httpwg.org/specs/rfc9113.html#fc-principles https_adaptive_window_size = false + +number_of_https_connections = 10 -- the number of https connections that should be available in the connection pool. -- Set keep-alive timer in seconds; keeps clients connected to the HTTP server, different from the connection to upstream search engines client_connection_keep_alive = 120 From e7efca4a4eade11ed527d94ea72588857263114d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 02:04:26 +0000 Subject: [PATCH 02/17] build(deps): bump redis from 0.25.4 to 0.27.2 (#613) --- Cargo.lock | 24 ++++++++++++++++++++++-- Cargo.toml | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index de9a820..310150f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2411,12 +2411,31 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21" +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -3127,9 +3146,9 @@ dependencies = [ [[package]] name = "redis" -version = "0.25.4" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0d7a6955c7511f60f3ba9e86c6d02b3c3f144f8c24b288d1f4e18074ab8bbec" +checksum = "a7e86f5670bd8b028edfb240f0616cad620705b31ec389d55e4f3da2c38dcd48" dependencies = [ "arc-swap", "async-trait", @@ -3138,6 +3157,7 @@ dependencies = [ "futures 0.3.30", "futures-util", "itoa 1.0.11", + "num-bigint", "percent-encoding 2.3.1", "pin-project-lite", "ryu", diff --git a/Cargo.toml b/Cargo.toml index d4dd298..ed21976 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ mlua = { version = "0.9.9", features = [ "luajit", "vendored", ], default-features = false } -redis = { version = "0.25.4", features = [ +redis = { version = "0.27.2", features = [ "tokio-comp", "connection-manager", "tcp_nodelay" From d75693ce4e65de7a4491a9dcdc179ca64864e804 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 02:09:30 +0000 Subject: [PATCH 03/17] build(deps): bump regex from 1.10.6 to 1.11.0 (#610) --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 310150f..e6e6d9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3184,9 +3184,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick 1.1.3", "memchr", @@ -3196,9 +3196,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick 1.1.3", "memchr", @@ -3213,9 +3213,9 @@ checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" diff --git a/Cargo.toml b/Cargo.toml index ed21976..375f4c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,7 @@ error-stack = { version = "0.4.0", default-features = false, features = [ "std", ] } async-trait = { version = "0.1.80", default-features = false } -regex = { version = "1.9.4", features = ["perf"], default-features = false } +regex = { version = "1.11.0", features = ["perf"], default-features = false } futures = { version = "0.3.30", default-features = false, features = ["alloc"] } dhat = { version = "0.3.2", optional = true, default-features = false } mimalloc = { version = "0.1.43", default-features = false } From ecc6875a21198f09861f6371df884a9d747a99e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 04:45:58 +0000 Subject: [PATCH 04/17] build(deps): bump actix-governor from 0.5.0 to 0.6.0 (#609) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6e6d9b..7160907 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,9 +59,9 @@ dependencies = [ [[package]] name = "actix-governor" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2e7b88f3804e01bd4191fdb08650430bbfcb43d3d9b2890064df3551ec7d25b" +checksum = "0954b0f27aabd8f56bb03f2a77b412ddf3f8c034a3c27b2086c1fc75415760df" dependencies = [ "actix-http", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index 375f4c5..e3863c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,7 @@ futures = { version = "0.3.30", default-features = false, features = ["alloc"] } dhat = { version = "0.3.2", optional = true, default-features = false } mimalloc = { version = "0.1.43", default-features = false } async-once-cell = { version = "0.5.3", default-features = false } -actix-governor = { version = "0.5.0", default-features = false } +actix-governor = { version = "0.6.0", default-features = false } moka = { version = "0.12.8", optional = true, default-features = false, features = [ "future", ] } From 5d59a2c7be9074084052a693894ecddcfe3d3a0f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 04:50:58 +0000 Subject: [PATCH 05/17] build(deps): bump error-stack from 0.4.1 to 0.5.0 (#611) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7160907..8d44cd1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1180,9 +1180,9 @@ dependencies = [ [[package]] name = "error-stack" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27a72baa257b5e0e2de241967bc5ee8f855d6072351042688621081d66b2a76b" +checksum = "fe413319145d1063f080f27556fd30b1d70b01e2ba10c2a6e40d4be982ffc5d1" dependencies = [ "anyhow", "rustc_version 0.4.1", diff --git a/Cargo.toml b/Cargo.toml index e3863c6..f2f3c6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ redis = { version = "0.27.2", features = [ "tcp_nodelay" ], default-features = false, optional = true } blake3 = { version = "1.5.4", default-features = false } -error-stack = { version = "0.4.0", default-features = false, features = [ +error-stack = { version = "0.5.0", default-features = false, features = [ "std", ] } async-trait = { version = "0.1.80", default-features = false } From 913ca1b07538f8aa3aa4af276627a7fedecb397e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 08:24:27 +0000 Subject: [PATCH 06/17] build(deps): bump tempfile from 3.12.0 to 3.13.0 (#612) --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8d44cd1..fa9e96c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3355,9 +3355,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.36" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -3851,9 +3851,9 @@ checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if 1.0.0", "fastrand", diff --git a/Cargo.toml b/Cargo.toml index f2f3c6a..ecad1cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,7 +91,7 @@ itertools = {version = "0.13.0", default-features = false} [dev-dependencies] rusty-hook = { version = "^0.11.2", default-features = false } criterion = { version = "0.5.1", default-features = false } -tempfile = { version = "3.10.1", default-features = false } +tempfile = { version = "3.13.0", default-features = false } [build-dependencies] lightningcss = { version = "1.0.0-alpha.57", default-features = false, features = [ From c796ae8bb74e66fd13b303a918d45f2f45ff6462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Maria=C5=84ski?= <13919176+m00nwtchr@users.noreply.github.com> Date: Sat, 5 Oct 2024 03:47:36 +0000 Subject: [PATCH 07/17] =?UTF-8?q?=E2=9C=A8=20Option=20to=20use=20a=20proxy?= =?UTF-8?q?=20for=20outgoing=20`upstream=20search=20engine`=20requests=20(?= =?UTF-8?q?#573)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add option to use a proxy for outgoing (search engine) requests. * Enable socks feature in reqwest * Fix formatting * add proxy feature * Update src/config/parser.rs Co-authored-by: neon_arch * Update websurfx/config.lua Co-authored-by: neon_arch * Update Cargo.toml Co-authored-by: neon_arch * fix * Update Cargo.toml Co-authored-by: neon_arch --------- Co-authored-by: neon_arch --- Cargo.toml | 3 ++- src/config/parser.rs | 12 ++++++++++++ src/results/aggregator.rs | 14 ++++++++++---- websurfx/config.lua | 2 ++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ecad1cc..2365cbb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,8 @@ reqwest = { version = "0.12.5", default-features = false, features = [ "rustls-tls", "brotli", "gzip", - "http2" + "http2", + "socks", ] } tokio = { version = "1.32.0", features = [ "rt-multi-thread", diff --git a/src/config/parser.rs b/src/config/parser.rs index 5ff9444..5d821c3 100644 --- a/src/config/parser.rs +++ b/src/config/parser.rs @@ -6,6 +6,7 @@ use crate::handler::{file_path, FileType}; use crate::models::parser_models::{AggregatorConfig, RateLimiter, Style}; use log::LevelFilter; use mlua::Lua; +use reqwest::Proxy; use std::{collections::HashMap, fs, thread::available_parallelism}; /// A named struct which stores the parsed config file options. @@ -48,6 +49,8 @@ pub struct Config { pub tcp_connection_keep_alive: u8, /// It stores the pool idle connection timeout in seconds. pub pool_idle_connection_timeout: u8, + /// Url of the proxy to use for outgoing requests. + pub proxy: Option, /// It stores the number of https connections to keep in the pool. pub number_of_https_connections: u8, } @@ -120,6 +123,14 @@ impl Config { _ => parsed_cet, }; + let proxy_opt = globals.get::<_, Option>("proxy")?; + let proxy = proxy_opt.and_then(|proxy_str| { + Proxy::all(proxy_str).ok().and_then(|_| { + log::error!("Invalid proxy url, defaulting to no proxy."); + None + }) + }); + Ok(Config { port: globals.get::<_, u16>("port")?, binding_ip: globals.get::<_, String>("binding_ip")?, @@ -151,6 +162,7 @@ impl Config { safe_search, #[cfg(any(feature = "redis-cache", feature = "memory-cache"))] cache_expiry_time, + proxy, }) } } diff --git a/src/results/aggregator.rs b/src/results/aggregator.rs index 65d5a5e..a6b34a4 100644 --- a/src/results/aggregator.rs +++ b/src/results/aggregator.rs @@ -75,7 +75,7 @@ pub async fn aggregate( safe_search: u8, ) -> Result> { let client = CLIENT.get_or_init(|| { - ClientBuilder::new() + let mut cb = ClientBuilder::new() .timeout(Duration::from_secs(config.request_timeout as u64)) // Add timeout to request to avoid DDOSing the server .pool_idle_timeout(Duration::from_secs( config.pool_idle_connection_timeout as u64, @@ -86,9 +86,13 @@ pub async fn aggregate( .https_only(true) .gzip(true) .brotli(true) - .http2_adaptive_window(config.adaptive_window) - .build() - .unwrap() + .http2_adaptive_window(config.adaptive_window); + + if config.proxy.is_some() { + cb = cb.proxy(config.proxy.clone().unwrap()); + } + + cb.build().unwrap() }); let user_agent: &str = random_user_agent(); @@ -242,6 +246,7 @@ pub async fn filter_with_lists( Ok(()) } + /// Sorts SearchResults by relevance score. ///
sort_unstable is used as its faster,stability is not an issue on our side. /// For reasons why, check out [`this`](https://rust-lang.github.io/rfcs/1884-unstable-sort.html) @@ -257,6 +262,7 @@ fn sort_search_results(results: &mut [SearchResult]) { .unwrap_or(Ordering::Less) }) } + #[cfg(test)] mod tests { use super::*; diff --git a/websurfx/config.lua b/websurfx/config.lua index 16c6146..8dd7a40 100644 --- a/websurfx/config.lua +++ b/websurfx/config.lua @@ -75,3 +75,5 @@ upstream_search_engines = { Mojeek = false, Bing = false, } -- select the upstream search engines from which the results should be fetched. + +proxy = nil -- Proxy to send outgoing requests through. Set to nil to disable. \ No newline at end of file From 959d0c52b15baaf07072bb48d3cc67cc0a419ae6 Mon Sep 17 00:00:00 2001 From: Jurijs Bibicevs <60851943+jurijsb@users.noreply.github.com> Date: Sun, 6 Oct 2024 18:30:11 +0200 Subject: [PATCH 08/17] :recycle: refactor: replace deprecated `per_second` with `seconds_per_request` in rate-limiting middleware code (#616) --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b7f0d71..3e4ae2c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -91,7 +91,7 @@ pub fn run( .wrap(cors) .wrap(Governor::new( &GovernorConfigBuilder::default() - .per_second(config.rate_limiter.time_limit as u64) + .seconds_per_request(config.rate_limiter.time_limit as u64) .burst_size(config.rate_limiter.number_of_requests as u32) .finish() .unwrap(), From 42c30aaaba9e9b4623a50438825c8f80584bbcc5 Mon Sep 17 00:00:00 2001 From: Zacherina <136650032+KekmaTime@users.noreply.github.com> Date: Mon, 7 Oct 2024 05:28:06 +0530 Subject: [PATCH 09/17] :bug: fix(search): Resolve random delay condition during search for `individual/non-production` self-hosted server (#617) --- src/server/routes/search.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/routes/search.rs b/src/server/routes/search.rs index 9fa6877..e4f40de 100644 --- a/src/server/routes/search.rs +++ b/src/server/routes/search.rs @@ -85,7 +85,7 @@ pub async fn search( let next_page = page + 1; // Add a random delay before making the request. - if config.aggregator.random_delay || !config.debug { + if config.aggregator.random_delay || config.debug { let nanos = SystemTime::now().duration_since(UNIX_EPOCH)?.subsec_nanos() as f32; let delay = ((nanos / 1_0000_0000 as f32).floor() as u64) + 1; tokio::time::sleep(Duration::from_secs(delay)).await; From d52da3aeb4c5ef8fa3f40193560a181fe2a44501 Mon Sep 17 00:00:00 2001 From: neon_arch Date: Tue, 8 Oct 2024 15:09:41 +0300 Subject: [PATCH 10/17] :sparkles: Clear button for the search bar (#608) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(icons): add a new icon for clear button on the search bar (#394) * :sparkles: feat: add clear button near the search bar input field (#394) * :sparkles: feat: add a function to clear search input text on click event (#394) * :sparkles: feat: disable unstable webkit search and clear button (#394) * :bookmark: chore(release): bump the app version (#394) * 🩹 fix: rename the pseudo css selector according to the `mdn` docs (#394) Co-authored-by: Jann Marc Villablanca <31008330+jfvillablanca@users.noreply.github.com> --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Jann Marc Villablanca <31008330+jfvillablanca@users.noreply.github.com> --- Cargo.lock | 302 ++++++++++++++------------------ Cargo.toml | 2 +- public/images/close.svg | 1 + public/static/index.js | 7 + public/static/themes/simple.css | 5 + src/templates/partials/bar.rs | 3 + 6 files changed, 151 insertions(+), 169 deletions(-) create mode 100644 public/images/close.svg diff --git a/Cargo.lock b/Cargo.lock index fa9e96c..c273074 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" dependencies = [ "bitflags 2.6.0", - "bytes 1.7.1", + "bytes 1.7.2", "futures-core", "futures-sink", "memchr", @@ -45,7 +45,7 @@ dependencies = [ "actix-utils", "actix-web", "bitflags 2.6.0", - "bytes 1.7.1", + "bytes 1.7.2", "derive_more", "futures-core", "http-range", @@ -83,7 +83,7 @@ dependencies = [ "base64 0.22.1", "bitflags 2.6.0", "brotli", - "bytes 1.7.1", + "bytes 1.7.2", "bytestring", "derive_more", "encoding_rs", @@ -112,7 +112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -195,7 +195,7 @@ dependencies = [ "actix-utils", "actix-web-codegen", "ahash", - "bytes 1.7.1", + "bytes 1.7.2", "bytestring", "cfg-if 1.0.0", "cookie 0.16.2", @@ -229,24 +229,18 @@ dependencies = [ "actix-router", "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "adler2" version = "2.0.0" @@ -329,9 +323,9 @@ checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "arc-swap" @@ -341,9 +335,9 @@ checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" [[package]] name = "arrayref" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" @@ -384,13 +378,13 @@ checksum = "9338790e78aa95a416786ec8389546c4b6a1dfc3dc36071ed9518a9413a542eb" [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -405,28 +399,28 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" dependencies = [ - "autocfg 1.3.0", + "autocfg 1.4.0", ] [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if 1.0.0", "libc", - "miniz_oxide 0.7.4", + "miniz_oxide", "object", "rustc-demangle", + "windows-targets", ] [[package]] @@ -564,9 +558,9 @@ dependencies = [ [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "bytestring" @@ -574,7 +568,7 @@ version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74d80203ea6b29df88012294f62733de21cfeab47f17b41af3a38bc30a03ee72" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", ] [[package]] @@ -585,9 +579,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.16" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d013ecb737093c0e86b151a7b837993cf9ec6c502946cfb44bedc392421e0b" +checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" dependencies = [ "shlex", ] @@ -677,18 +671,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstyle", "clap_lex", @@ -715,7 +709,7 @@ version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-core", "memchr", "pin-project-lite", @@ -830,9 +824,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -916,7 +910,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ - "autocfg 1.3.0", + "autocfg 1.4.0", "cfg-if 0.1.10", "crossbeam-utils 0.7.2", "lazy_static", @@ -951,7 +945,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg 1.3.0", + "autocfg 1.4.0", "cfg-if 0.1.10", "lazy_static", ] @@ -1021,7 +1015,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1062,7 +1056,7 @@ dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", "rustc_version 0.4.1", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1250,12 +1244,12 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", + "miniz_oxide", ] [[package]] @@ -1398,7 +1392,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1478,9 +1472,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "governor" @@ -1527,7 +1521,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", - "bytes 1.7.1", + "bytes 1.7.2", "fnv", "futures-core", "futures-sink", @@ -1617,7 +1611,7 @@ dependencies = [ "markup5ever 0.12.1", "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1637,7 +1631,7 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "fnv", "itoa 1.0.11", ] @@ -1648,7 +1642,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "fnv", "itoa 1.0.11", ] @@ -1671,7 +1665,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "http 1.1.0", ] @@ -1681,7 +1675,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-util", "http 1.1.0", "http-body 1.0.1", @@ -1742,7 +1736,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-channel", "futures-util", "h2 0.4.6", @@ -1789,11 +1783,11 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-channel", "futures-util", "http 1.1.0", @@ -1802,7 +1796,6 @@ dependencies = [ "pin-project-lite", "socket2 0.5.7", "tokio 1.40.0", - "tower", "tower-service", "tracing", ] @@ -1851,7 +1844,7 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ - "autocfg 1.3.0", + "autocfg 1.4.0", "hashbrown 0.12.3", ] @@ -1895,9 +1888,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "is-terminal" @@ -1984,9 +1977,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libflate" @@ -2020,9 +2013,9 @@ dependencies = [ [[package]] name = "lightningcss" -version = "1.0.0-alpha.58" +version = "1.0.0-alpha.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec380ca49dc7f6a1cafbdd2de5e587958eac0f67ab26b1e56727fcc60a0c3d4d" +checksum = "53e225b3fa0a8bd5562c8833b1a32afa88761c4e661d3177b8cdc4e13cbf078e" dependencies = [ "ahash", "bitflags 2.6.0", @@ -2090,7 +2083,7 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ - "autocfg 1.3.0", + "autocfg 1.4.0", "scopeguard", ] @@ -2183,7 +2176,7 @@ dependencies = [ "proc-macro-error", "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2204,7 +2197,7 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" dependencies = [ - "autocfg 1.3.0", + "autocfg 1.4.0", ] [[package]] @@ -2242,15 +2235,6 @@ dependencies = [ "parse-js", ] -[[package]] -name = "miniz_oxide" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.8.0" @@ -2325,9 +2309,9 @@ dependencies = [ [[package]] name = "mlua-sys" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab7a5b4756b8177a2dfa8e0bbcde63bd4000afbc4ab20cbb68d114a25470f29" +checksum = "ebe026d6bd1583a9cf9080e189030ddaea7e6f5f0deb366a8e26f8a26c4135b8" dependencies = [ "cc", "cfg-if 1.0.0", @@ -2442,7 +2426,7 @@ version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ - "autocfg 1.3.0", + "autocfg 1.4.0", ] [[package]] @@ -2466,9 +2450,12 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "oorandom" @@ -2505,7 +2492,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2528,9 +2515,9 @@ dependencies = [ [[package]] name = "parcel_selectors" -version = "0.26.6" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512215cb1d3814e276ace4ec2dbc2cac16726ea3fcac20c22ae1197e16fdd72d" +checksum = "1f4d26c18a8377a64728c04bf3b2e48ec43b0c77e687a18e03eb837d65e08a14" dependencies = [ "bitflags 2.6.0", "cssparser 0.33.0", @@ -2544,9 +2531,9 @@ dependencies = [ [[package]] name = "parking" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "parking_lot" @@ -2592,7 +2579,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.5.3", + "redox_syscall 0.5.6", "smallvec 1.13.2", "windows-targets", ] @@ -2732,7 +2719,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2779,7 +2766,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2796,9 +2783,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "poly1305" @@ -2813,9 +2800,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "powerfmt" @@ -2910,7 +2897,7 @@ version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "pin-project-lite", "quinn-proto", "quinn-udp", @@ -2928,7 +2915,7 @@ version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "rand 0.8.5", "ring", "rustc-hash 2.0.0", @@ -3152,7 +3139,7 @@ checksum = "a7e86f5670bd8b028edfb240f0616cad620705b31ec389d55e4f3da2c38dcd48" dependencies = [ "arc-swap", "async-trait", - "bytes 1.7.1", + "bytes 1.7.2", "combine", "futures 0.3.30", "futures-util", @@ -3175,9 +3162,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" dependencies = [ "bitflags 2.6.0", ] @@ -3259,7 +3246,7 @@ checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ "async-compression", "base64 0.22.1", - "bytes 1.7.1", + "bytes 1.7.2", "futures-core", "futures-util", "h2 0.4.6", @@ -3368,9 +3355,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.12" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ "once_cell", "ring", @@ -3392,15 +3379,15 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" +checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" [[package]] name = "rustls-webpki" -version = "0.102.7" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring", "rustls-pki-types", @@ -3436,11 +3423,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3479,9 +3466,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -3539,22 +3526,22 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3646,7 +3633,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ - "autocfg 1.3.0", + "autocfg 1.4.0", ] [[package]] @@ -3813,9 +3800,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", @@ -3840,7 +3827,7 @@ dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", "syn 1.0.109", - "unicode-xid 0.2.5", + "unicode-xid 0.2.6", ] [[package]] @@ -3894,22 +3881,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4011,7 +3998,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", - "bytes 1.7.1", + "bytes 1.7.2", "libc", "mio 1.0.2", "parking_lot 0.12.3", @@ -4072,7 +4059,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4189,7 +4176,7 @@ version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-core", "futures-sink", "pin-project-lite", @@ -4205,27 +4192,6 @@ dependencies = [ "serde", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio 1.40.0", - "tower-layer", - "tower-service", -] - -[[package]] -name = "tower-layer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" - [[package]] name = "tower-service" version = "0.3.3" @@ -4296,30 +4262,30 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" @@ -4329,9 +4295,9 @@ checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "universal-hash" @@ -4477,7 +4443,7 @@ dependencies = [ "once_cell", "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-shared", ] @@ -4511,7 +4477,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4534,16 +4500,16 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.5" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" dependencies = [ "rustls-pki-types", ] [[package]] name = "websurfx" -version = "1.17.22" +version = "1.18.0" dependencies = [ "actix-cors", "actix-files", @@ -4796,7 +4762,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 2365cbb..753b6ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "websurfx" -version = "1.17.22" +version = "1.18.0" edition = "2021" description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind." repository = "https://github.com/neon-mmd/websurfx" diff --git a/public/images/close.svg b/public/images/close.svg new file mode 100644 index 0000000..7d5875c --- /dev/null +++ b/public/images/close.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/static/index.js b/public/static/index.js index 515065a..c743497 100644 --- a/public/static/index.js +++ b/public/static/index.js @@ -32,3 +32,10 @@ searchBox.addEventListener('keyup', (e) => { searchWeb() } }) + +/** +* A function that clears the search input text when the clear button is clicked. +*/ +function clearSearchText() { + document.querySelector('.search_bar input').value = '' +} diff --git a/public/static/themes/simple.css b/public/static/themes/simple.css index 8f5fcc7..dc8fcbc 100644 --- a/public/static/themes/simple.css +++ b/public/static/themes/simple.css @@ -73,6 +73,11 @@ button { font-size: 1.6rem; } +.search_bar input::-webkit-search-results-button, +.search_bar input::-webkit-search-cancel-button{ + display: none; +} + .search_bar input:focus { outline: 2px solid var(--foreground-color); } diff --git a/src/templates/partials/bar.rs b/src/templates/partials/bar.rs index ebf89fe..bf66c4c 100644 --- a/src/templates/partials/bar.rs +++ b/src/templates/partials/bar.rs @@ -16,6 +16,9 @@ pub fn bar(query: &str) -> Markup { html!( (PreEscaped("
")) input type="search" name="search-box" value=(query) placeholder="Type to search"; + button type="reset" onclick="clearSearchText()" { + img src="./images/close.svg" alt="Clear button icon for clearing search input text"; + } button type="submit" onclick="searchWeb()" { img src="./images/magnifying_glass.svg" alt="Info icon for error box"; } From 56bfcbba0e58dcff9e35af2967cafe5f6cb1bbf9 Mon Sep 17 00:00:00 2001 From: Laptop Date: Fri, 18 Oct 2024 13:16:32 +0300 Subject: [PATCH 11/17] less javascript (#621) --- Cargo.lock | 13 ++++++++++ public/static/index.js | 37 +------------------------- public/static/pagination.js | 39 ---------------------------- public/static/search_area_options.js | 18 ------------- public/static/themes/simple.css | 4 +-- src/server/routes/search.rs | 1 + src/templates/partials/bar.rs | 7 ++--- src/templates/partials/search_bar.rs | 9 ++++--- src/templates/views/search.rs | 8 +++--- 9 files changed, 30 insertions(+), 106 deletions(-) delete mode 100644 public/static/pagination.js delete mode 100644 public/static/search_area_options.js diff --git a/Cargo.lock b/Cargo.lock index c273074..fdce525 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3273,6 +3273,7 @@ dependencies = [ "sync_wrapper", "tokio 1.40.0", "tokio-rustls", + "tokio-socks", "tokio-util", "tower-service", "url 2.5.2", @@ -4103,6 +4104,18 @@ dependencies = [ "tokio 1.40.0", ] +[[package]] +name = "tokio-socks" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4770b8024672c1101b3f6733eab95b18007dbe0847a8afe341fcf79e06043f" +dependencies = [ + "either", + "futures-util", + "thiserror", + "tokio 1.40.0", +] + [[package]] name = "tokio-sync" version = "0.1.8" diff --git a/public/static/index.js b/public/static/index.js index c743497..6858a66 100644 --- a/public/static/index.js +++ b/public/static/index.js @@ -1,41 +1,6 @@ -/** - * Selects the input element for the search box - * @type {HTMLInputElement} - */ -const searchBox = document.querySelector('input') - -/** - * Redirects the user to the search results page with the query parameter - */ -function searchWeb() { - const query = searchBox.value.trim() - try { - let safeSearchLevel = document.querySelector('.search_options select').value - if (query) { - window.location.href = `search?q=${encodeURIComponent( - query, - )}&safesearch=${encodeURIComponent(safeSearchLevel)}` - } - } catch (error) { - if (query) { - window.location.href = `search?q=${encodeURIComponent(query)}` - } - } -} - -/** - * Listens for the 'Enter' key press event on the search box and calls the searchWeb function - * @param {KeyboardEvent} e - The keyboard event object - */ -searchBox.addEventListener('keyup', (e) => { - if (e.key === 'Enter') { - searchWeb() - } -}) - /** * A function that clears the search input text when the clear button is clicked. */ function clearSearchText() { - document.querySelector('.search_bar input').value = '' + document.querySelector('.search_bar > input').value = '' } diff --git a/public/static/pagination.js b/public/static/pagination.js deleted file mode 100644 index bdbfb39..0000000 --- a/public/static/pagination.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Navigates to the next page by incrementing the current page number in the URL query string. - * @returns {void} - */ -function navigate_forward() { - let url = new URL(window.location); - let searchParams = url.searchParams; - - let q = searchParams.get('q'); - let page = parseInt(searchParams.get('page')); - - if (isNaN(page)) { - page = 1; - } else { - page++; - } - - window.location.href = `${url.origin}${url.pathname}?q=${encodeURIComponent(q)}&page=${page}`; -} - -/** - * Navigates to the previous page by decrementing the current page number in the URL query string. - * @returns {void} - */ -function navigate_backward() { - let url = new URL(window.location); - let searchParams = url.searchParams; - - let q = searchParams.get('q'); - let page = parseInt(searchParams.get('page')); - - if (isNaN(page)) { - page = 0; - } else if (page > 0) { - page--; - } - - window.location.href = `${url.origin}${url.pathname}?q=${encodeURIComponent(q)}&page=${page}`; -} diff --git a/public/static/search_area_options.js b/public/static/search_area_options.js deleted file mode 100644 index 10e0390..0000000 --- a/public/static/search_area_options.js +++ /dev/null @@ -1,18 +0,0 @@ -document.addEventListener( - 'DOMContentLoaded', - () => { - let url = new URL(window.location) - let searchParams = url.searchParams - - let safeSearchLevel = searchParams.get('safesearch') - - if ( - safeSearchLevel >= 0 && - safeSearchLevel <= 2 && - safeSearchLevel !== null - ) { - document.querySelector('.search_options select').value = safeSearchLevel - } - }, - false, -) diff --git a/public/static/themes/simple.css b/public/static/themes/simple.css index dc8fcbc..36472a9 100644 --- a/public/static/themes/simple.css +++ b/public/static/themes/simple.css @@ -448,7 +448,7 @@ footer div { align-items: center; } -.page_navigation button { +.page_navigation a { background: var(--background-color); color: var(--foreground-color); padding: 1rem; @@ -457,7 +457,7 @@ footer div { border: none; } -.page_navigation button:active { +.page_navigation a:active { filter: brightness(1.2); } diff --git a/src/server/routes/search.rs b/src/server/routes/search.rs index e4f40de..883017f 100644 --- a/src/server/routes/search.rs +++ b/src/server/routes/search.rs @@ -129,6 +129,7 @@ pub async fn search( &config.style.theme, &config.style.animation, query, + page, &results.0, ) .0, diff --git a/src/templates/partials/bar.rs b/src/templates/partials/bar.rs index bf66c4c..a381186 100644 --- a/src/templates/partials/bar.rs +++ b/src/templates/partials/bar.rs @@ -14,12 +14,13 @@ use maud::{html, Markup, PreEscaped}; /// It returns the compiled html code for the search bar as a result. pub fn bar(query: &str) -> Markup { html!( + (PreEscaped("
")) (PreEscaped("
")) - input type="search" name="search-box" value=(query) placeholder="Type to search"; - button type="reset" onclick="clearSearchText()" { + input type="search" name="q" value=(query) placeholder="Type to search"; + button type="button" onclick="clearSearchText()" { img src="./images/close.svg" alt="Clear button icon for clearing search input text"; } - button type="submit" onclick="searchWeb()" { + button type="submit" { img src="./images/magnifying_glass.svg" alt="Info icon for error box"; } ) diff --git a/src/templates/partials/search_bar.rs b/src/templates/partials/search_bar.rs index 9c6ea9c..3c7478c 100644 --- a/src/templates/partials/search_bar.rs +++ b/src/templates/partials/search_bar.rs @@ -29,7 +29,7 @@ pub fn search_bar( (bar(query)) .error_box { @if !engine_errors_info.is_empty(){ - button onclick="toggleErrorBox()" class="error_box_toggle_button"{ + button type="button" onclick="toggleErrorBox()" class="error_box_toggle_button"{ img src="./images/warning.svg" alt="Info icon for error box"; } .dropdown_error_box{ @@ -43,7 +43,7 @@ pub fn search_bar( } } @else { - button onclick="toggleErrorBox()" class="error_box_toggle_button"{ + button type="button" onclick="toggleErrorBox()" class="error_box_toggle_button"{ img src="./images/info.svg" alt="Warning icon for error box"; } .dropdown_error_box { @@ -56,10 +56,10 @@ pub fn search_bar( (PreEscaped("
")) .search_options { @if safe_search_level >= 3 { - (PreEscaped("")) } @else{ - (PreEscaped("", safe_search_level))) } @for (idx, name) in SAFE_SEARCH_LEVELS_NAME.iter().enumerate() { @if (safe_search_level as usize) == idx { @@ -71,6 +71,7 @@ pub fn search_bar( } (PreEscaped("")) } + (PreEscaped("
")) } ) } diff --git a/src/templates/views/search.rs b/src/templates/views/search.rs index c5ab456..4ffa423 100644 --- a/src/templates/views/search.rs +++ b/src/templates/views/search.rs @@ -24,6 +24,7 @@ pub fn search( theme: &str, animation: &Option, query: &str, + page: u32, search_results: &SearchResults, ) -> Markup { html!( @@ -108,15 +109,14 @@ pub fn search( } } .page_navigation { - button type="button" onclick="navigate_backward()"{ + a href=(format!("/search?q={}&safesearch={}&page={}", query, search_results.safe_search_level, if page > 1 {page-1} else {1})) { (PreEscaped("←")) "previous" } - button type="button" onclick="navigate_forward()"{"next" (PreEscaped("→"))} + a href=(format!("/search?q={}&safesearch={}&page={}", query, search_results.safe_search_level, page+2)) { + "next" (PreEscaped("→"))} } } script src="static/index.js"{} - script src="static/search_area_options.js"{} - script src="static/pagination.js"{} script src="static/error_box.js"{} (footer()) ) From 718e172b6daaaa1e61ee7f5e9ca7be8a371f0fa6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2024 11:27:27 +0000 Subject: [PATCH 12/17] build(deps): bump tokio from 1.40.0 to 1.41.0 (#624) --- Cargo.lock | 42 +++++++++++++++++++++--------------------- Cargo.toml | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fdce525..a6bafea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,7 +14,7 @@ dependencies = [ "futures-sink", "memchr", "pin-project-lite", - "tokio 1.40.0", + "tokio 1.41.0", "tokio-util", "tracing", ] @@ -100,7 +100,7 @@ dependencies = [ "rand 0.8.5", "sha1", "smallvec 1.13.2", - "tokio 1.40.0", + "tokio 1.41.0", "tokio-util", "tracing", ] @@ -136,7 +136,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24eda4e2a6e042aa4e55ac438a2ae052d3b5da0ecf83d7411e1a368946925208" dependencies = [ "futures-core", - "tokio 1.40.0", + "tokio 1.41.0", "tokio-uring", ] @@ -153,7 +153,7 @@ dependencies = [ "futures-util", "mio 1.0.2", "socket2 0.5.7", - "tokio 1.40.0", + "tokio 1.41.0", "tokio-uring", "tracing", ] @@ -356,7 +356,7 @@ dependencies = [ "futures-core", "memchr", "pin-project-lite", - "tokio 1.40.0", + "tokio 1.41.0", ] [[package]] @@ -713,7 +713,7 @@ dependencies = [ "futures-core", "memchr", "pin-project-lite", - "tokio 1.40.0", + "tokio 1.41.0", "tokio-util", ] @@ -1528,7 +1528,7 @@ dependencies = [ "http 1.1.0", "indexmap 2.5.0", "slab", - "tokio 1.40.0", + "tokio 1.41.0", "tokio-util", "tracing", ] @@ -1746,7 +1746,7 @@ dependencies = [ "itoa 1.0.11", "pin-project-lite", "smallvec 1.13.2", - "tokio 1.40.0", + "tokio 1.41.0", "want 0.3.1", ] @@ -1762,7 +1762,7 @@ dependencies = [ "hyper-util", "rustls", "rustls-pki-types", - "tokio 1.40.0", + "tokio 1.41.0", "tokio-rustls", "tower-service", "webpki-roots", @@ -1795,7 +1795,7 @@ dependencies = [ "hyper 1.4.1", "pin-project-lite", "socket2 0.5.7", - "tokio 1.40.0", + "tokio 1.41.0", "tower-service", "tracing", ] @@ -2905,7 +2905,7 @@ dependencies = [ "rustls", "socket2 0.5.7", "thiserror", - "tokio 1.40.0", + "tokio 1.41.0", "tracing", ] @@ -3148,7 +3148,7 @@ dependencies = [ "percent-encoding 2.3.1", "pin-project-lite", "ryu", - "tokio 1.40.0", + "tokio 1.41.0", "tokio-retry", "tokio-util", "url 2.5.2", @@ -3271,7 +3271,7 @@ dependencies = [ "serde_json", "serde_urlencoded 0.7.1", "sync_wrapper", - "tokio 1.40.0", + "tokio 1.41.0", "tokio-rustls", "tokio-socks", "tokio-util", @@ -3994,9 +3994,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes 1.7.2", @@ -4090,7 +4090,7 @@ checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" dependencies = [ "pin-project", "rand 0.8.5", - "tokio 1.40.0", + "tokio 1.41.0", ] [[package]] @@ -4101,7 +4101,7 @@ checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ "rustls", "rustls-pki-types", - "tokio 1.40.0", + "tokio 1.41.0", ] [[package]] @@ -4113,7 +4113,7 @@ dependencies = [ "either", "futures-util", "thiserror", - "tokio 1.40.0", + "tokio 1.41.0", ] [[package]] @@ -4180,7 +4180,7 @@ dependencies = [ "libc", "slab", "socket2 0.4.10", - "tokio 1.40.0", + "tokio 1.41.0", ] [[package]] @@ -4193,7 +4193,7 @@ dependencies = [ "futures-core", "futures-sink", "pin-project-lite", - "tokio 1.40.0", + "tokio 1.41.0", ] [[package]] @@ -4562,7 +4562,7 @@ dependencies = [ "stop-words", "tempfile", "thesaurus", - "tokio 1.40.0", + "tokio 1.41.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 753b6ab..0e9a921 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ reqwest = { version = "0.12.5", default-features = false, features = [ "http2", "socks", ] } -tokio = { version = "1.32.0", features = [ +tokio = { version = "1.41.0", features = [ "rt-multi-thread", "macros", "fs", From d75e7d07ecbec7da4ce38c6a15518210bedbce93 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2024 11:32:26 +0000 Subject: [PATCH 13/17] build(deps): bump actix-governor from 0.6.0 to 0.7.0 (#625) --- Cargo.lock | 44 +++++++++++++++++++++++--------------------- Cargo.toml | 2 +- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6bafea..2831232 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,9 +59,9 @@ dependencies = [ [[package]] name = "actix-governor" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0954b0f27aabd8f56bb03f2a77b412ddf3f8c034a3c27b2086c1fc75415760df" +checksum = "072a3d7907b945b0956f9721e01c117ad5765ce5be2fd9bb1e44a117c669de22" dependencies = [ "actix-http", "actix-web", @@ -1020,11 +1020,12 @@ dependencies = [ [[package]] name = "dashmap" -version = "5.5.3" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" dependencies = [ "cfg-if 1.0.0", + "crossbeam-utils 0.8.20", "hashbrown 0.14.5", "lock_api 0.4.12", "once_cell", @@ -1343,9 +1344,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1353,9 +1354,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-cpupool" @@ -1380,15 +1381,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", @@ -1397,15 +1398,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-timer" @@ -1415,9 +1416,9 @@ checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -1478,14 +1479,15 @@ checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "governor" -version = "0.6.3" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a7f542ee6b35af73b06abc0dad1c1bae89964e4e253bc4b587b91c9637867b" +checksum = "0746aa765db78b521451ef74221663b57ba595bf83f75d0ce23cc09447c8139f" dependencies = [ "cfg-if 1.0.0", "dashmap", - "futures 0.3.30", + "futures-sink", "futures-timer", + "futures-util", "no-std-compat", "nonzero_ext", "parking_lot 0.12.3", diff --git a/Cargo.toml b/Cargo.toml index 0e9a921..18beb75 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,7 @@ futures = { version = "0.3.30", default-features = false, features = ["alloc"] } dhat = { version = "0.3.2", optional = true, default-features = false } mimalloc = { version = "0.1.43", default-features = false } async-once-cell = { version = "0.5.3", default-features = false } -actix-governor = { version = "0.6.0", default-features = false } +actix-governor = { version = "0.7.0", default-features = false } moka = { version = "0.12.8", optional = true, default-features = false, features = [ "future", ] } From ee4bc00576522e403f304a08ebe56df1ccd5ad93 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2024 13:03:31 +0000 Subject: [PATCH 14/17] build(deps): bump futures from 0.3.30 to 0.3.31 (#626) --- Cargo.lock | 14 +++++++------- Cargo.toml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2831232..fe7f3a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,7 +65,7 @@ checksum = "072a3d7907b945b0956f9721e01c117ad5765ce5be2fd9bb1e44a117c669de22" dependencies = [ "actix-http", "actix-web", - "futures 0.3.30", + "futures 0.3.31", "governor", ] @@ -1329,9 +1329,9 @@ checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -1370,9 +1370,9 @@ dependencies = [ [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -3143,7 +3143,7 @@ dependencies = [ "async-trait", "bytes 1.7.2", "combine", - "futures 0.3.30", + "futures 0.3.31", "futures-util", "itoa 1.0.11", "num-bigint", @@ -4544,7 +4544,7 @@ dependencies = [ "env_logger", "error-stack", "fake-useragent", - "futures 0.3.30", + "futures 0.3.31", "itertools 0.13.0", "keyword_extraction", "lightningcss", diff --git a/Cargo.toml b/Cargo.toml index 18beb75..45ca5e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ error-stack = { version = "0.5.0", default-features = false, features = [ ] } async-trait = { version = "0.1.80", default-features = false } regex = { version = "1.11.0", features = ["perf"], default-features = false } -futures = { version = "0.3.30", default-features = false, features = ["alloc"] } +futures = { version = "0.3.31", default-features = false, features = ["alloc"] } dhat = { version = "0.3.2", optional = true, default-features = false } mimalloc = { version = "0.1.43", default-features = false } async-once-cell = { version = "0.5.3", default-features = false } From e08c0754f86acd4c23e08532a470cfc52baf7fd1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2024 13:08:35 +0000 Subject: [PATCH 15/17] build(deps): bump redis from 0.27.2 to 0.27.5 (#627) --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe7f3a6..37b0f48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3135,9 +3135,9 @@ dependencies = [ [[package]] name = "redis" -version = "0.27.2" +version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e86f5670bd8b028edfb240f0616cad620705b31ec389d55e4f3da2c38dcd48" +checksum = "81cccf17a692ce51b86564334614d72dcae1def0fd5ecebc9f02956da74352b5" dependencies = [ "arc-swap", "async-trait", @@ -3151,7 +3151,7 @@ dependencies = [ "pin-project-lite", "ryu", "tokio 1.41.0", - "tokio-retry", + "tokio-retry2", "tokio-util", "url 2.5.2", ] @@ -4085,10 +4085,10 @@ dependencies = [ ] [[package]] -name = "tokio-retry" -version = "0.3.0" +name = "tokio-retry2" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" +checksum = "903934dba1c4c2f2e9cb460ef10b5695e0b0ecad3bf9ee7c8675e540c5e8b2d1" dependencies = [ "pin-project", "rand 0.8.5", diff --git a/Cargo.toml b/Cargo.toml index 45ca5e1..0b8a4e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,7 @@ mlua = { version = "0.9.9", features = [ "luajit", "vendored", ], default-features = false } -redis = { version = "0.27.2", features = [ +redis = { version = "0.27.5", features = [ "tokio-comp", "connection-manager", "tcp_nodelay" From 4fa9a7491e41f356759dcec3b051ce8ac164fa7a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2024 13:14:02 +0000 Subject: [PATCH 16/17] build(deps): bump regex from 1.11.0 to 1.11.1 (#628) --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37b0f48..8511059 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3173,9 +3173,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick 1.1.3", "memchr", diff --git a/Cargo.toml b/Cargo.toml index 0b8a4e4..84dffc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ error-stack = { version = "0.5.0", default-features = false, features = [ "std", ] } async-trait = { version = "0.1.80", default-features = false } -regex = { version = "1.11.0", features = ["perf"], default-features = false } +regex = { version = "1.11.1", features = ["perf"], default-features = false } futures = { version = "0.3.31", default-features = false, features = ["alloc"] } dhat = { version = "0.3.2", optional = true, default-features = false } mimalloc = { version = "0.1.43", default-features = false } From ef0ae2f0aada18074b08afdb55dfc6d917ae8f3a Mon Sep 17 00:00:00 2001 From: Jorge Botto Date: Sat, 2 Nov 2024 15:36:14 +0000 Subject: [PATCH 17/17] Fixing Librex SearchResultParser results selector (#619) --- src/engines/librex.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engines/librex.rs b/src/engines/librex.rs index 840e8f4..04494a6 100644 --- a/src/engines/librex.rs +++ b/src/engines/librex.rs @@ -30,7 +30,7 @@ impl LibreX { Ok(Self { parser: SearchResultParser::new( ".text-result-container>p", - ".text-result-container", + ".text-result-wrapper", ".text-result-wrapper>a>h2", ".text-result-wrapper>a", ".text-result-wrapper>span",