Skip to content

Commit 9e4a931

Browse files
committed
Nits
1 parent 40b0b02 commit 9e4a931

File tree

4 files changed

+37
-40
lines changed

4 files changed

+37
-40
lines changed

src/config.rs

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -240,39 +240,42 @@ pub fn parse_opts(globals: &mut Globals) {
240240
.or_else(|| globals.tls_cert_path.clone());
241241
}
242242

243-
if let Some(hostname) = matches.get_one::<String>("hostname") {
244-
let mut builder =
245-
dnsstamps::DoHBuilder::new(hostname.to_string(), globals.path.to_string());
246-
if let Some(public_address) = matches.get_one::<String>("public_address") {
247-
builder = builder.with_address(public_address.to_string());
248-
}
249-
if let Some(public_port) = matches.get_one::<String>("public_port") {
250-
let public_port = public_port.parse().expect("Invalid public port");
251-
builder = builder.with_port(public_port);
252-
}
253-
println!(
254-
"Test DNS stamp to reach [{}] over DoH: [{}]\n",
255-
hostname,
256-
builder.serialize().unwrap()
257-
);
243+
match matches.get_one::<String>("hostname") {
244+
Some(hostname) => {
245+
let mut builder =
246+
dnsstamps::DoHBuilder::new(hostname.to_string(), globals.path.to_string());
247+
if let Some(public_address) = matches.get_one::<String>("public_address") {
248+
builder = builder.with_address(public_address.to_string());
249+
}
250+
if let Some(public_port) = matches.get_one::<String>("public_port") {
251+
let public_port = public_port.parse().expect("Invalid public port");
252+
builder = builder.with_port(public_port);
253+
}
254+
println!(
255+
"Test DNS stamp to reach [{}] over DoH: [{}]\n",
256+
hostname,
257+
builder.serialize().unwrap()
258+
);
258259

259-
let mut builder =
260-
dnsstamps::ODoHTargetBuilder::new(hostname.to_string(), globals.path.to_string());
261-
if let Some(public_port) = matches.get_one::<String>("public_port") {
262-
let public_port = public_port.parse().expect("Invalid public port");
263-
builder = builder.with_port(public_port);
264-
}
265-
println!(
266-
"Test DNS stamp to reach [{}] over Oblivious DoH: [{}]\n",
267-
hostname,
268-
builder.serialize().unwrap()
269-
);
260+
let mut builder =
261+
dnsstamps::ODoHTargetBuilder::new(hostname.to_string(), globals.path.to_string());
262+
if let Some(public_port) = matches.get_one::<String>("public_port") {
263+
let public_port = public_port.parse().expect("Invalid public port");
264+
builder = builder.with_port(public_port);
265+
}
266+
println!(
267+
"Test DNS stamp to reach [{}] over Oblivious DoH: [{}]\n",
268+
hostname,
269+
builder.serialize().unwrap()
270+
);
270271

271-
println!("Check out https://dnscrypt.info/stamps/ to compute the actual stamps.\n")
272-
} else {
273-
println!(
272+
println!("Check out https://dnscrypt.info/stamps/ to compute the actual stamps.\n")
273+
}
274+
_ => {
275+
println!(
274276
"Please provide a fully qualified hostname (-H <hostname> command-line option) to get \
275277
test DNS stamps for your server.\n"
276278
);
279+
}
277280
}
278281
}

src/libdoh/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,7 @@ impl DoH {
257257
content_types: &[&'static str],
258258
) -> Option<&'static str> {
259259
let accept = headers.get(hyper::header::ACCEPT);
260-
let accept = match accept {
261-
None => return None,
262-
Some(accept) => accept,
263-
};
260+
let accept = accept?;
264261
for part in accept.to_str().unwrap_or("").split(',').map(|s| s.trim()) {
265262
if let Some(found) = part
266263
.split(';')

src/libdoh/src/odoh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl ODoHPublicKey {
7777

7878
impl ODoHQueryContext {
7979
pub fn encrypt_response(self, response_body: Vec<u8>) -> Result<Vec<u8>, DoHError> {
80-
let response_nonce = rand::thread_rng().gen::<ResponseNonce>();
80+
let response_nonce = rand::thread_rng().r#gen::<ResponseNonce>();
8181
let response_body_ = ObliviousDoHMessagePlaintext::new(response_body, 0);
8282
let encrypted_response = odoh_rs::encrypt_response(
8383
&self.query,

src/libdoh/src/tls.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,9 @@ where
8787
let server_config_builder = ServerConfig::builder()
8888
.with_safe_defaults()
8989
.with_no_client_auth();
90-
if let Ok(found_config) =
91-
server_config_builder.with_single_cert(certs.clone(), certs_key)
92-
{
93-
Some(found_config)
94-
} else {
95-
None
90+
match server_config_builder.with_single_cert(certs.clone(), certs_key) {
91+
Ok(found_config) => Some(found_config),
92+
_ => None,
9693
}
9794
})
9895
.ok_or_else(|| {

0 commit comments

Comments
 (0)