From ab20f08e42251dbb052ec5aa08534187d8283f03 Mon Sep 17 00:00:00 2001 From: gotoworq <110043355+gotoworq@users.noreply.github.com> Date: Mon, 22 May 2023 14:44:46 -0400 Subject: [PATCH 1/7] Added logo, and changed logon to be on main page --- public/images/websurfx_logo.png | Bin 0 -> 8264 bytes public/templates/index.html | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 public/images/websurfx_logo.png diff --git a/public/images/websurfx_logo.png b/public/images/websurfx_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..9449e33ff4400ee97da4186599ead26e0ead74a7 GIT binary patch literal 8264 zcmV-OAh+L%P)FK#oU~nHKzykz8ilj(NCUjet zWyZ=T<=9wxH^RH#-CzE(5&Oe`ynh_AVTWVoSRZoO(n^#p%aV6RLJ}zwgg}A>MS!?5 z1I*oXcK7uCj;h=r-P6+008JhnIcap_OBOZ`=$_Qq;6@IdsEtC6fWo4qQNUz<(a9IW8? zuTHSGP>WW-&igv<0!#TkwMhLs?g_TP;V)Ob=BQsc`S%d3X8(3T%~7AK{#nQUMU6cN zRn@II>epkM_ZAO;;V(3!=BU3iw#fi(9#+?Zwb{)jTGtl!>n4A*v5mUDwy3`{w$adR zCbpm9ck5b1)UTWTt%2>(`3N;d{gtsD24%}&`x*WM7F4c5>epaz*RcgrE7V_^@AW5Q z!?9$SZi~LI73$ZqWl=NFL4~5VM*SuFxn{b5+o0xq9BYF5HQ&v(i|yI<2vB=gzmBbl zntVW%%~qfQR5WGBBgSK2Qo0U`se$bIA2@eDB*#KU13+>tfV#J{Il!e71(&>08$d3LXb-N{0oEYO0wkL;|N9k#EZv97)eOabI#ZUmrC{Y}G?45yVvwiHVB z#eo(z=Vc?quFZGLtes2~em0Rz__MLaCOU z?eGZ48NW`6In+I5o6<}%-S6yuQakz?-qfq^J^@75z`Fo--q*3g*lg+pkePPObn&Ca z8JU^`DU2t77rhNKmlm@lo2XtLuua|l&31UIfozkKb7=T^Lz{i`SN71a0qR!2jtvEF z0jpm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{Y2!Qz~N7YdCq3%O(18eT(z9wh#mVM^~aBM(Eb`C1H zde^Zs>eOEWsCjv?mACI!_ncJvjsT!c%{gONoS|Qf$yOITAMI(qyJd*k!9JOGJsQTxN_J0rWJWs)^`0Sy@0<=l$BSZM+>Q zDoXd@*V0kZSfH8tLcHsM(!Li%9ZdI;m6h>`n7$)3amuC0Op%nRXn+iaMfs?UnE~C4 zB+1H&xlyt*rL|W4U-_lWD8v_9AxTn-F0(Bqr22uB;?&aZLU>rR`;3_y4 zI94eaMRJyM2{5zyKqN_r%#7=3&NbQoI@XOk^*0@L>Td#;V|49$I{@H1$Y?8L<^HXi z5!eQ({l2at>X)GQ`@JTxy}P-#s9!hyTLZP})U4Hqn(p?kjt8M@Ynl2><3Sj?&A~P>`BeBesQssA)PckE%^$ z%iP=Ys2l$Kh3#YV7x6$?{cSQ<_Yx0;t5dGK`y}ex!m14aN;e;LZ12vYB|fnwBx(qC z_OA;obj!9e`7Ufbho{c|yTJp*d-utZg;RBF8+Xxwns4jI;cj?et60k0feNc%%Z**F z+p~)M4+QR#_uH_~wv)qCXa8z(m(8#J-dadmD+Mdup%R%IMxFgD<1TkR)Nns7uljbf z`YzPj@4|z_`xQ|_{cY0BWhOQ&N^f&KP&?epk4mZ1u>TMGr4mw5JtNEj0000header this}}
- Websurfx meta-search engine logo + Websurfx meta-search engine logo {{>search_bar}}
From ff325153f06dbcb18c78a30dbf6c076996f75d7a Mon Sep 17 00:00:00 2001 From: XFFXFF <1247714429@qq.com> Date: Tue, 23 May 2023 00:31:46 +0000 Subject: [PATCH 2/7] add format and clippy checks to the CI jobs --- .github/workflows/rust_format.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust_format.yml b/.github/workflows/rust_format.yml index d865c8c..c300863 100644 --- a/.github/workflows/rust_format.yml +++ b/.github/workflows/rust_format.yml @@ -19,7 +19,16 @@ jobs: profile: minimal toolchain: stable components: rustfmt, clippy - + - name: Format + uses: actions-rs/cargo@v1 + with: + command: fmt + args: -- --check + - name: Clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all-features --all-targets --all - name: Run cargo check uses: actions-rs/cargo@v1 with: From cecffe41555d76ed254ead5a7cebf277e6b98172 Mon Sep 17 00:00:00 2001 From: XFFXFF <1247714429@qq.com> Date: Tue, 23 May 2023 09:34:46 +0000 Subject: [PATCH 3/7] make format happy --- src/cache/mod.rs | 2 +- src/search_results_handler/aggregation_models.rs | 2 +- src/server/routes.rs | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cache/mod.rs b/src/cache/mod.rs index 91a91ca..de7dd4e 100644 --- a/src/cache/mod.rs +++ b/src/cache/mod.rs @@ -1 +1 @@ -pub mod cacher; +pub mod cacher; diff --git a/src/search_results_handler/aggregation_models.rs b/src/search_results_handler/aggregation_models.rs index 4fe670e..b6e6b81 100644 --- a/src/search_results_handler/aggregation_models.rs +++ b/src/search_results_handler/aggregation_models.rs @@ -116,7 +116,7 @@ impl RawSearchResult { } } -/// A named struct to store, serialize, deserialize the all the search results scraped and +/// A named struct to store, serialize, deserialize the all the search results scraped and /// aggregated from the upstream search engines. /// /// # Fields diff --git a/src/server/routes.rs b/src/server/routes.rs index ed2299f..85c522d 100644 --- a/src/server/routes.rs +++ b/src/server/routes.rs @@ -81,10 +81,10 @@ pub async fn search( .insert_header(("location", "/")) .finish()) } else { - let page_url: String; // Declare the page_url variable without initializing it + let page_url: String; // Declare the page_url variable without initializing it // ... - + let page = match params.page { Some(page_number) => { if page_number <= 1 { @@ -98,7 +98,7 @@ pub async fn search( "http://{}:{}/search?q={}&page={}", config.binding_ip_addr, config.port, query, page_number ); - + page_number } } @@ -110,11 +110,11 @@ pub async fn search( req.uri(), 1 ); - + 1 } }; - + // fetch the cached results json. let cached_results_json = redis_cache.cached_results_json(&page_url); // check if fetched results was indeed fetched or it was an error and if so From 05272884bac1e6068f58180e964227126b9f9067 Mon Sep 17 00:00:00 2001 From: XFFXFF <1247714429@qq.com> Date: Mon, 22 May 2023 01:13:06 +0000 Subject: [PATCH 4/7] supports the option to add a random delay --- src/config_parser/parser.rs | 13 +++++++++++++ src/search_results_handler/aggregator.rs | 10 +++++++--- src/server/routes.rs | 2 +- websurfx/config.lua | 5 +++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/config_parser/parser.rs b/src/config_parser/parser.rs index 4625bd8..21a9bf5 100644 --- a/src/config_parser/parser.rs +++ b/src/config_parser/parser.rs @@ -20,6 +20,14 @@ pub struct Config { pub binding_ip_addr: String, pub style: Style, pub redis_connection_url: String, + pub aggregator: AggreatorConfig, +} + +/// Configuration options for the aggregator. +#[derive(Clone)] +pub struct AggreatorConfig { + /// Whether to introduce a random delay before sending the request to the search engine. + pub random_delay: bool, } impl Config { @@ -41,6 +49,8 @@ impl Config { .load(&fs::read_to_string("./websurfx/config.lua")?) .exec()?; + let aggregator_config = globals.get::<_, rlua::Table>("aggregator")?; + Ok(Config { port: globals.get::<_, u16>("port")?, binding_ip_addr: globals.get::<_, String>("binding_ip_addr")?, @@ -49,6 +59,9 @@ impl Config { globals.get::<_, String>("colorscheme")?, ), redis_connection_url: globals.get::<_, String>("redis_connection_url")?, + aggregator: AggreatorConfig { + random_delay: aggregator_config.get::<_, bool>("random_delay")?, + }, }) }) } diff --git a/src/search_results_handler/aggregator.rs b/src/search_results_handler/aggregator.rs index 5133094..8b86972 100644 --- a/src/search_results_handler/aggregator.rs +++ b/src/search_results_handler/aggregator.rs @@ -29,6 +29,7 @@ use crate::engines::{duckduckgo, searx}; /// /// * `query` - Accepts a string to query with the above upstream search engines. /// * `page` - Accepts an u32 page number. +/// * `random_delay` - Accepts a boolean value to add a random delay before making the request. /// /// # Error /// @@ -38,14 +39,17 @@ use crate::engines::{duckduckgo, searx}; pub async fn aggregate( query: &str, page: u32, + random_delay: bool, ) -> Result> { let user_agent: String = random_user_agent(); let mut result_map: HashMap = HashMap::new(); // Add a random delay before making the request. - let mut rng = rand::thread_rng(); - let delay_secs = rng.gen_range(1..10); - std::thread::sleep(Duration::from_secs(delay_secs)); + if random_delay { + let mut rng = rand::thread_rng(); + let delay_secs = rng.gen_range(1..10); + std::thread::sleep(Duration::from_secs(delay_secs)); + } // fetch results from upstream search engines simultaneously/concurrently. let (ddg_map_results, searx_map_results) = join!( diff --git a/src/server/routes.rs b/src/server/routes.rs index 85c522d..0f84cc9 100644 --- a/src/server/routes.rs +++ b/src/server/routes.rs @@ -127,7 +127,7 @@ pub async fn search( } Err(_) => { let mut results_json: crate::search_results_handler::aggregation_models::SearchResults = - aggregate(query, page).await?; + aggregate(query, page, config.aggregator.random_delay).await?; results_json.add_style(config.style.clone()); redis_cache .cache_results(serde_json::to_string(&results_json)?, &page_url)?; diff --git a/websurfx/config.lua b/websurfx/config.lua index 916a9b3..7dfd515 100644 --- a/websurfx/config.lua +++ b/websurfx/config.lua @@ -19,3 +19,8 @@ theme = "simple" -- the theme name which should be used for the website -- Caching redis_connection_url = "redis://127.0.0.1:8082" -- redis connection url address on which the client should connect on. + +-- Aggregator +aggregator = { + random_delay = false, -- whether to add random delay before sending the request to the search engine +} \ No newline at end of file From 9773cee38dd312696bd17168e5758176a5563b8e Mon Sep 17 00:00:00 2001 From: XFFXFF <1247714429@qq.com> Date: Tue, 23 May 2023 00:56:44 +0000 Subject: [PATCH 5/7] change the 'aggregator' option to 'production_use' --- src/config_parser/parser.rs | 15 +++++++++++---- websurfx/config.lua | 7 +++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/config_parser/parser.rs b/src/config_parser/parser.rs index 21a9bf5..4b73a73 100644 --- a/src/config_parser/parser.rs +++ b/src/config_parser/parser.rs @@ -49,7 +49,16 @@ impl Config { .load(&fs::read_to_string("./websurfx/config.lua")?) .exec()?; - let aggregator_config = globals.get::<_, rlua::Table>("aggregator")?; + let production_use = globals.get::<_, bool>("production_use")?; + let aggregator_config = if production_use { + AggreatorConfig { + random_delay: true, + } + } else { + AggreatorConfig { + random_delay: false, + } + }; Ok(Config { port: globals.get::<_, u16>("port")?, @@ -59,9 +68,7 @@ impl Config { globals.get::<_, String>("colorscheme")?, ), redis_connection_url: globals.get::<_, String>("redis_connection_url")?, - aggregator: AggreatorConfig { - random_delay: aggregator_config.get::<_, bool>("random_delay")?, - }, + aggregator: aggregator_config }) }) } diff --git a/websurfx/config.lua b/websurfx/config.lua index 7dfd515..1c0be7d 100644 --- a/websurfx/config.lua +++ b/websurfx/config.lua @@ -20,7 +20,6 @@ theme = "simple" -- the theme name which should be used for the website -- Caching redis_connection_url = "redis://127.0.0.1:8082" -- redis connection url address on which the client should connect on. --- Aggregator -aggregator = { - random_delay = false, -- whether to add random delay before sending the request to the search engine -} \ No newline at end of file +production_use = false -- whether to use production mode or not +-- if production_use is set to true + -- there will be a random delay before sending the request to the search engines, this is to prevent the search engines from blocking the ip address \ No newline at end of file From 4b70a74ff6196a00d8878333ab4b56b065427230 Mon Sep 17 00:00:00 2001 From: zhou fan <1247714429@qq.com> Date: Tue, 23 May 2023 17:30:36 +0800 Subject: [PATCH 6/7] Update websurfx/config.lua Co-authored-by: neon_arch --- websurfx/config.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/websurfx/config.lua b/websurfx/config.lua index 1c0be7d..c30f376 100644 --- a/websurfx/config.lua +++ b/websurfx/config.lua @@ -20,6 +20,6 @@ theme = "simple" -- the theme name which should be used for the website -- Caching redis_connection_url = "redis://127.0.0.1:8082" -- redis connection url address on which the client should connect on. -production_use = false -- whether to use production mode or not +production_use = false -- whether to use production mode or not (in other words this option should be used if it is to be used to host it on the server to provide a service to a large number of users) -- if production_use is set to true - -- there will be a random delay before sending the request to the search engines, this is to prevent the search engines from blocking the ip address \ No newline at end of file + -- There will be a random delay before sending the request to the search engines, this is to prevent DDoSing the upstream search engines from a large number of simultaneous requests. \ No newline at end of file From ea013e718edae23136befa9609100960431ab5f4 Mon Sep 17 00:00:00 2001 From: XFFXFF <1247714429@qq.com> Date: Tue, 23 May 2023 10:00:35 +0000 Subject: [PATCH 7/7] make format happy --- src/config_parser/parser.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/config_parser/parser.rs b/src/config_parser/parser.rs index 4b73a73..f8dac14 100644 --- a/src/config_parser/parser.rs +++ b/src/config_parser/parser.rs @@ -51,9 +51,7 @@ impl Config { let production_use = globals.get::<_, bool>("production_use")?; let aggregator_config = if production_use { - AggreatorConfig { - random_delay: true, - } + AggreatorConfig { random_delay: true } } else { AggreatorConfig { random_delay: false, @@ -68,7 +66,7 @@ impl Config { globals.get::<_, String>("colorscheme")?, ), redis_connection_url: globals.get::<_, String>("redis_connection_url")?, - aggregator: aggregator_config + aggregator: aggregator_config, }) }) }