Skip to content

Commit 5ee07e0

Browse files
committed
refactor
1 parent cb01281 commit 5ee07e0

File tree

6 files changed

+23
-24
lines changed

6 files changed

+23
-24
lines changed

modoh-lib/src/httpsig_handler/handler_main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ where
4545
C: Send + Sync + Connect + Clone + 'static,
4646
B: Body + Send + Unpin + 'static,
4747
<B as Body>::Data: Send,
48-
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
48+
<B as Body>::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
4949
{
5050
/// force to refetch notifier for the public keys
5151
pub(super) force_refetch_notify: Arc<tokio::sync::Notify>,

modoh-lib/src/hyper_client.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use crate::{
88
use http::{Request, Response};
99
use hyper::body::{Body, Incoming};
1010
use hyper_util::client::legacy::{
11-
connect::{Connect, HttpConnector},
1211
Client,
12+
connect::{Connect, HttpConnector},
1313
};
1414
use tracing::instrument;
1515

@@ -20,7 +20,7 @@ where
2020
C: Send + Sync + Connect + Clone + 'static,
2121
B: Body + Send + Unpin + 'static,
2222
<B as Body>::Data: Send,
23-
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
23+
<B as Body>::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
2424
{
2525
pub inner: Client<C, B>,
2626
}
@@ -30,7 +30,7 @@ where
3030
C: Send + Sync + Connect + Clone + 'static,
3131
B: Body + Send + Unpin + 'static,
3232
<B as Body>::Data: Send,
33-
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
33+
<B as Body>::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
3434
{
3535
#[instrument(level = "debug", name = "http_request", skip_all)]
3636
/// wrapper request fn
@@ -71,7 +71,7 @@ impl<B> HttpClient<HttpConnector, B>
7171
where
7272
B: Body + Send + Unpin + 'static,
7373
<B as Body>::Data: Send,
74-
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
74+
<B as Body>::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
7575
{
7676
/// Build inner client with http
7777
pub fn try_new(runtime_handle: tokio::runtime::Handle) -> Result<Self> {
@@ -96,7 +96,7 @@ impl<B> HttpClient<hyper_tls::HttpsConnector<HttpConnector>, B>
9696
where
9797
B: Body + Send + Unpin + 'static,
9898
<B as Body>::Data: Send,
99-
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
99+
<B as Body>::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
100100
{
101101
/// Build inner client with hyper-tls
102102
pub fn try_new(runtime_handle: tokio::runtime::Handle) -> Result<Self> {
@@ -126,7 +126,7 @@ impl<B> HttpClient<hyper_rustls::HttpsConnector<HttpConnector>, B>
126126
where
127127
B: Body + Send + Unpin + 'static,
128128
<B as Body>::Data: Send,
129-
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
129+
<B as Body>::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
130130
{
131131
/// Build forwarder
132132
pub fn try_new(runtime_handle: tokio::runtime::Handle) -> Result<Self> {

modoh-lib/src/relay/relay_handle_url.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ fn is_looped(current_url: &Url) -> bool {
1616
let mut seen = vec![current_url.host_str().unwrap_or(HOSTNAME).to_ascii_lowercase()];
1717
let hostnames = current_url.query_pairs().filter_map(|(k, v)| {
1818
// filter "targethost" or "relayhost"
19-
if k.contains("host") {
20-
Some(v)
21-
} else {
22-
None
23-
}
19+
if k.contains("host") { Some(v) } else { None }
2420
});
2521
for h in hostnames {
2622
let hostname = h.to_ascii_lowercase();
@@ -37,7 +33,7 @@ where
3733
C: Send + Sync + Connect + Clone + 'static,
3834
B: Body + Send + Unpin + 'static,
3935
<B as Body>::Data: Send,
40-
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
36+
<B as Body>::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
4137
{
4238
#[instrument(level = "debug", skip_all)]
4339
/// build next-hop url with loop detection and max subsequent nodes check
@@ -118,7 +114,7 @@ where
118114
mod tests {
119115
use super::*;
120116
use crate::hyper_client::HttpClient;
121-
use hyper::{body::Incoming, HeaderMap};
117+
use hyper::{HeaderMap, body::Incoming};
122118
use std::sync::Arc;
123119

124120
#[test]
@@ -179,7 +175,10 @@ mod tests {
179175

180176
let url = Url::parse("https://example1.com/proxy?targethost=example2.com&targetpath=/dns-query&relayhost[1]=example3.com&relaypath[1]=/proxy&relayhost[2]=example4.com&relaypath[2]=/proxy").unwrap();
181177
let next_hop_url = inner.build_nexthop_url(&url).unwrap();
182-
assert_eq!(next_hop_url.as_str(), "https://example3.com/proxy?relayhost%5B1%5D=example4.com&relaypath%5B1%5D=%2Fproxy&targethost=example2.com&targetpath=%2Fdns-query");
178+
assert_eq!(
179+
next_hop_url.as_str(),
180+
"https://example3.com/proxy?relayhost%5B1%5D=example4.com&relaypath%5B1%5D=%2Fproxy&targethost=example2.com&targetpath=%2Fdns-query"
181+
);
183182

184183
let url = Url::parse("https://example1.com/proxy?targethost=example2.com&targetpath=/dns-query&relayhost[1]=example3.com&relaypath[1]=/proxy&relayhost[2]=example4.com&relaypath[2]=/proxy&relayhost[3]=example5.com&relaypath[3]=/proxy").unwrap();
185184
let next_hop_url = inner.build_nexthop_url(&url);

modoh-lib/src/relay/relay_main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ use crate::{
55
httpsig_handler::HttpSigKeysHandler,
66
hyper_body::{BoxBody, IncomingOr},
77
hyper_client::HttpClient,
8-
message_util::{check_content_type, inspect_host, inspect_request_body, RequestType},
8+
message_util::{RequestType, check_content_type, inspect_host, inspect_request_body},
99
request_filter::RequestFilter,
1010
trace::*,
1111
};
1212
use http::{
13+
Method, Request, Response,
1314
header::{self, HeaderMap, HeaderValue},
1415
request::Parts,
15-
Method, Request, Response,
1616
};
1717
use hyper::body::{Body, Incoming};
1818
use hyper_util::client::legacy::connect::Connect;
@@ -26,7 +26,7 @@ where
2626
C: Send + Sync + Connect + Clone + 'static,
2727
B: Body + Send + Unpin + 'static,
2828
<B as Body>::Data: Send,
29-
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
29+
<B as Body>::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
3030
{
3131
/// hyper client
3232
pub(super) inner: Arc<HttpClient<C, B>>,

modoh-lib/src/validator/validator_jwks_service.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::validator_main::Validator;
22
use crate::{constants::JWKS_REFETCH_DELAY_SEC, error::*, hyper_client::HttpClient, trace::*};
33
use auth_validator::JwksHttpClient;
4-
use futures::{select, FutureExt};
4+
use futures::{FutureExt, select};
55
use hyper::body::Body;
66
use hyper_util::client::legacy::connect::Connect;
77
use std::{sync::Arc, time::Duration};
@@ -12,7 +12,7 @@ where
1212
C: Send + Sync + Connect + Clone + 'static,
1313
B: Body + Send + Unpin + 'static,
1414
<B as Body>::Data: Send,
15-
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
15+
<B as Body>::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
1616
HttpClient<C, B>: JwksHttpClient,
1717
{
1818
/// Check token expiration every 60 secs, and refresh if the token is about to expire.

modoh-lib/src/validator/validator_main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use crate::{
66
hyper_client::HttpClient,
77
};
88
use async_trait::async_trait;
9-
use auth_validator::{reexports::Claims, JwksHttpClient, TokenValidator};
10-
use http::{header, HeaderValue, Method, Request};
9+
use auth_validator::{JwksHttpClient, TokenValidator, reexports::Claims};
10+
use http::{HeaderValue, Method, Request, header};
1111
use http_body_util::{BodyExt, Empty};
1212
use hyper::body::{Body, Buf, Bytes};
1313
use hyper_util::client::legacy::connect::Connect;
@@ -80,7 +80,7 @@ where
8080
C: Send + Sync + Connect + Clone + 'static,
8181
B: Body + Send + Unpin + 'static,
8282
<B as Body>::Data: Send,
83-
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
83+
<B as Body>::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
8484
HttpClient<C, B>: JwksHttpClient,
8585
{
8686
pub(super) inner: TokenValidator<HttpClient<C, B>>,
@@ -91,7 +91,7 @@ where
9191
C: Send + Sync + Connect + Clone + 'static,
9292
B: Body + Send + Unpin + 'static,
9393
<B as Body>::Data: Send,
94-
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
94+
<B as Body>::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
9595
HttpClient<C, B>: JwksHttpClient,
9696
{
9797
#[instrument(name = "validate_request", skip_all)]

0 commit comments

Comments
 (0)