mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-26 15:58:21 -05:00
Compare commits
1 Commits
9b090e06a8
...
8de118c9f3
Author | SHA1 | Date | |
---|---|---|---|
|
8de118c9f3 |
@ -42,8 +42,6 @@ pub struct Config {
|
|||||||
/// It stores the level of safe search to be used for restricting content in the
|
/// It stores the level of safe search to be used for restricting content in the
|
||||||
/// search results.
|
/// search results.
|
||||||
pub safe_search: u8,
|
pub safe_search: u8,
|
||||||
/// It stores the TCP connection keepalive duration in seconds.
|
|
||||||
pub tcp_connection_keepalive: u64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
@ -133,7 +131,6 @@ impl Config {
|
|||||||
upstream_search_engines: globals
|
upstream_search_engines: globals
|
||||||
.get::<_, HashMap<String, bool>>("upstream_search_engines")?,
|
.get::<_, HashMap<String, bool>>("upstream_search_engines")?,
|
||||||
request_timeout: globals.get::<_, u8>("request_timeout")?,
|
request_timeout: globals.get::<_, u8>("request_timeout")?,
|
||||||
tcp_connection_keepalive: globals.get::<_, u64>("tcp_connection_keepalive")?,
|
|
||||||
threads,
|
threads,
|
||||||
rate_limiter: RateLimiter {
|
rate_limiter: RateLimiter {
|
||||||
number_of_requests: rate_limiter["number_of_requests"],
|
number_of_requests: rate_limiter["number_of_requests"],
|
||||||
|
@ -73,11 +73,12 @@ pub async fn aggregate(
|
|||||||
config: &Config,
|
config: &Config,
|
||||||
upstream_search_engines: &[EngineHandler],
|
upstream_search_engines: &[EngineHandler],
|
||||||
safe_search: u8,
|
safe_search: u8,
|
||||||
|
tcp_connection_keepalive: u8,
|
||||||
) -> Result<SearchResults, Box<dyn std::error::Error>> {
|
) -> Result<SearchResults, Box<dyn std::error::Error>> {
|
||||||
let client = CLIENT.get_or_init(|| {
|
let client = CLIENT.get_or_init(|| {
|
||||||
ClientBuilder::new()
|
ClientBuilder::new()
|
||||||
.timeout(Duration::from_secs(config.request_timeout as u64)) // Add timeout to request to avoid DDOSing the server
|
.timeout(Duration::from_secs(config.request_timeout as u64)) // Add timeout to request to avoid DDOSing the server
|
||||||
.tcp_keepalive(Duration::from_secs(config.tcp_connection_keepalive as u64))
|
.tcp_keepalive(Duration::from_secs(tcp_connection_keepalive as u64))
|
||||||
.connect_timeout(Duration::from_secs(config.request_timeout as u64)) // Add timeout to request to avoid DDOSing the server
|
.connect_timeout(Duration::from_secs(config.request_timeout as u64)) // Add timeout to request to avoid DDOSing the server
|
||||||
.https_only(true)
|
.https_only(true)
|
||||||
.gzip(true)
|
.gzip(true)
|
||||||
|
@ -216,6 +216,7 @@ async fn results(
|
|||||||
.filter_map(|engine| EngineHandler::new(engine).ok())
|
.filter_map(|engine| EngineHandler::new(engine).ok())
|
||||||
.collect::<Vec<EngineHandler>>(),
|
.collect::<Vec<EngineHandler>>(),
|
||||||
safe_search_level,
|
safe_search_level,
|
||||||
|
30,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user