clippy suggestions
This commit is contained in:
parent
e29de0d29c
commit
0fd832efdd
1
TODO
1
TODO
@ -1,3 +1,4 @@
|
||||
- logging
|
||||
- expect statements (pretend it's "expected", not "expect")
|
||||
- map_unexpected annotation string
|
||||
- clean up main a lot
|
||||
|
@ -34,7 +34,7 @@ impl TryFrom<&Certificate> for openssl::x509::X509 {
|
||||
type Error = openssl::error::ErrorStack;
|
||||
|
||||
fn try_from(c: &Certificate) -> Result<Self, Self::Error> {
|
||||
Ok(openssl::x509::X509::from_der(&c.0)?)
|
||||
openssl::x509::X509::from_der(&c.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ use crate::domain::{self, acme};
|
||||
use crate::error;
|
||||
use crate::error::{MapUnexpected, ToUnexpected};
|
||||
|
||||
const LETS_ENCRYPT_URL: &'static str = "https://acme-v02.api.letsencrypt.org/directory";
|
||||
const LETS_ENCRYPT_URL: &str = "https://acme-v02.api.letsencrypt.org/directory";
|
||||
|
||||
pub type GetHttp01ChallengeKeyError = acme::store::GetHttp01ChallengeKeyError;
|
||||
|
||||
@ -149,7 +149,7 @@ where
|
||||
|
||||
// no matter what the result is, clean up the challenge key
|
||||
self.store
|
||||
.del_http01_challenge_key(&challenge_token)
|
||||
.del_http01_challenge_key(challenge_token)
|
||||
.map_unexpected()?;
|
||||
|
||||
let challenge = challenge_res.map_unexpected()?;
|
||||
|
@ -9,6 +9,7 @@ use serde_with::{DeserializeFromStr, SerializeDisplay};
|
||||
pub struct PrivateKey(Vec<u8>);
|
||||
|
||||
impl PrivateKey {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> PrivateKey {
|
||||
acme2::gen_rsa_private_key(4096)
|
||||
.expect("RSA private key generated")
|
||||
@ -44,7 +45,7 @@ impl TryFrom<&PrivateKey> for openssl::pkey::PKey<openssl::pkey::Private> {
|
||||
type Error = openssl::error::ErrorStack;
|
||||
|
||||
fn try_from(k: &PrivateKey) -> Result<Self, Self::Error> {
|
||||
Ok(openssl::pkey::PKey::private_key_from_der(&k.0)?)
|
||||
openssl::pkey::PKey::private_key_from_der(&k.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ impl Store for BoxedFSStore {
|
||||
) -> Result<(), error::Unexpected> {
|
||||
let to_store = StoredPKeyCert {
|
||||
private_key: key,
|
||||
cert: cert,
|
||||
cert,
|
||||
};
|
||||
|
||||
let cert_file = fs::File::create(self.certificate_path(domain)).map_unexpected()?;
|
||||
@ -194,11 +194,7 @@ impl rustls::server::ResolvesServerCert for BoxedFSStore {
|
||||
&self,
|
||||
client_hello: rustls::server::ClientHello<'_>,
|
||||
) -> Option<sync::Arc<rustls::sign::CertifiedKey>> {
|
||||
let domain = if let Some(domain) = client_hello.server_name() {
|
||||
domain
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
let domain = client_hello.server_name()?;
|
||||
|
||||
match self.get_certificate(domain) {
|
||||
Err(GetCertificateError::NotFound) => Ok(None),
|
||||
@ -208,7 +204,7 @@ impl rustls::server::ResolvesServerCert for BoxedFSStore {
|
||||
Err(err) => Err(err),
|
||||
Ok(key) => Ok(Some(sync::Arc::new(rustls::sign::CertifiedKey {
|
||||
cert: cert.into_iter().map(|cert| cert.into()).collect(),
|
||||
key: key,
|
||||
key,
|
||||
ocsp: None,
|
||||
sct_list: None,
|
||||
}))),
|
||||
|
@ -105,7 +105,7 @@ impl Store for sync::Arc<FSStore> {
|
||||
error::Unexpected::from("couldn't convert os string to &str")
|
||||
})?;
|
||||
|
||||
Ok(domain::Name::from_str(domain).map_unexpected()?)
|
||||
domain::Name::from_str(domain).map_unexpected()
|
||||
},
|
||||
)
|
||||
.collect())
|
||||
|
@ -188,7 +188,7 @@ where
|
||||
origin_store,
|
||||
domain_config_store,
|
||||
domain_checker,
|
||||
acme_manager: acme_manager,
|
||||
acme_manager,
|
||||
})
|
||||
}
|
||||
|
||||
@ -261,7 +261,7 @@ where
|
||||
|
||||
Ok(Box::from(iter.filter_map(|descr| {
|
||||
if let Err(err) = descr {
|
||||
return Some((None, err.to_unexpected().into()));
|
||||
return Some((None, err.to_unexpected()));
|
||||
}
|
||||
|
||||
let descr = descr.unwrap();
|
||||
@ -270,7 +270,7 @@ where
|
||||
.origin_store
|
||||
.sync(descr.clone(), origin::store::Limits {})
|
||||
{
|
||||
return Some((Some(descr), err.to_unexpected().into()));
|
||||
return Some((Some(descr), err.to_unexpected()));
|
||||
}
|
||||
|
||||
None
|
||||
|
@ -312,7 +312,7 @@ async fn main() {
|
||||
})
|
||||
}
|
||||
|
||||
while let Some(_) = wait_group.next().await {}
|
||||
while wait_group.next().await.is_some() {}
|
||||
|
||||
println!("Graceful shutdown complete");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user