Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
junkurihara committed Nov 16, 2023
1 parent 7f96e66 commit 735c750
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion legacy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ mimalloc = { version = "*", default-features = false }

# logging
tracing = { version = "0.1.40" }
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

[dev-dependencies]
trust-dns-client = "0.23.2"
Expand Down
2 changes: 1 addition & 1 deletion proxy-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ hot_reload = "0.1.4"

# logging
tracing = { version = "0.1.40" }
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
url = "2.4.1"
dotenv = "0.15.0"
8 changes: 5 additions & 3 deletions proxy-lib/src/http_client/http_client_main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{
error::*,
trait_resolve_ips::{resolve_ips, ResolveIpResponse, ResolveIps},
ProxyConfig,
};
use reqwest::{header::HeaderMap, Client, IntoUrl, RequestBuilder, Url};
use std::sync::Arc;
Expand Down Expand Up @@ -32,13 +33,14 @@ pub struct HttpClient {
impl HttpClient {
/// Build HttpClient
pub async fn new(
proxy_config: &ProxyConfig,
endpoints: &[Url],
timeout_sec: Duration,
user_agent: &str,
default_headers: Option<&HeaderMap>,
resolver_ips: impl ResolveIps,
endpoint_resolution_period_sec: Duration,
) -> Result<Self> {
let timeout_sec = proxy_config.http_timeout_sec;
let user_agent = &proxy_config.http_user_agent;
let endpoint_resolution_period_sec = proxy_config.endpoint_resolution_period_sec;
let resolved_ips = resolve_ips(endpoints, resolver_ips).await?;
Ok(Self {
inner: Arc::new(RwLock::new(
Expand Down
10 changes: 1 addition & 9 deletions proxy-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,7 @@ pub async fn entrypoint(
if let Some(auth) = &proxy_config.authentication_config {
endpoint_candidates.push(auth.token_api.clone());
}
let http_client = HttpClient::new(
&endpoint_candidates,
proxy_config.http_timeout_sec,
&proxy_config.http_user_agent,
None,
bootstrap_dns_resolver.clone(),
proxy_config.endpoint_resolution_period_sec,
)
.await?;
let http_client = HttpClient::new(proxy_config, &endpoint_candidates, None, bootstrap_dns_resolver.clone()).await?;
let http_client = Arc::new(http_client);

// spawn authentication service
Expand Down

0 comments on commit 735c750

Please sign in to comment.