mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-22 05:58:21 -05:00
Added config option to enable the reqwest client adaptive window
This commit is contained in:
parent
2df6499fb2
commit
2cb5b7c08b
@ -30,6 +30,8 @@ pub struct Config {
|
||||
pub logging: bool,
|
||||
/// It stores the option to whether enable or disable debug mode.
|
||||
pub debug: bool,
|
||||
/// It toggles whether to use adaptive TCP windows
|
||||
pub adaptive_window: bool,
|
||||
/// It stores all the engine names that were enabled by the user.
|
||||
pub upstream_search_engines: HashMap<String, bool>,
|
||||
/// It stores the time (secs) which controls the server request timeout.
|
||||
@ -68,6 +70,7 @@ impl Config {
|
||||
|
||||
let debug: bool = globals.get::<_, bool>("debug")?;
|
||||
let logging: bool = globals.get::<_, bool>("logging")?;
|
||||
let adaptive_window: bool = globals.get::<_, bool>("adaptive_window")?;
|
||||
|
||||
if !logging_initialized {
|
||||
set_logging_level(debug, logging);
|
||||
@ -125,6 +128,7 @@ impl Config {
|
||||
},
|
||||
logging,
|
||||
debug,
|
||||
adaptive_window,
|
||||
upstream_search_engines: globals
|
||||
.get::<_, HashMap<String, bool>>("upstream_search_engines")?,
|
||||
request_timeout: globals.get::<_, u8>("request_timeout")?,
|
||||
|
@ -71,6 +71,7 @@ pub async fn aggregate(
|
||||
upstream_search_engines: &[EngineHandler],
|
||||
request_timeout: u8,
|
||||
safe_search: u8,
|
||||
adaptive_window: bool,
|
||||
) -> Result<SearchResults, Box<dyn std::error::Error>> {
|
||||
let client = CLIENT.get_or_init(|| {
|
||||
ClientBuilder::new()
|
||||
@ -78,6 +79,7 @@ pub async fn aggregate(
|
||||
.https_only(true)
|
||||
.gzip(true)
|
||||
.brotli(true)
|
||||
.http2_adaptive_window(adaptive_window)
|
||||
.build()
|
||||
.unwrap()
|
||||
});
|
||||
|
@ -218,6 +218,7 @@ async fn results(
|
||||
.collect::<Vec<EngineHandler>>(),
|
||||
config.request_timeout,
|
||||
safe_search_level,
|
||||
config.adaptive_window,
|
||||
)
|
||||
.await?
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ rate_limiter = {
|
||||
number_of_requests = 20, -- The number of request that are allowed within a provided time limit.
|
||||
time_limit = 3, -- The time limit in which the quantity of requests that should be accepted.
|
||||
}
|
||||
-- Set whether the server will use an adaptive/dynamic TCP window size
|
||||
adaptive_window = true
|
||||
|
||||
-- ### Search ###
|
||||
-- Filter results based on different levels. The levels provided are:
|
||||
|
Loading…
Reference in New Issue
Block a user