mirror of
https://github.com/YGGverse/agate.git
synced 2026-04-08 12:35:28 +00:00
Use if-let chains
This commit is contained in:
parent
cdc72e4f2d
commit
13ad2f363e
1 changed files with 66 additions and 66 deletions
18
src/main.rs
18
src/main.rs
|
|
@ -290,8 +290,9 @@ fn args() -> Result<Args> {
|
||||||
let hostname = Host::parse(&s)?;
|
let hostname = Host::parse(&s)?;
|
||||||
|
|
||||||
// check if we have a certificate for that domain
|
// check if we have a certificate for that domain
|
||||||
if let Host::Domain(ref domain) = hostname {
|
if let Host::Domain(ref domain) = hostname
|
||||||
if !matches!(certs, Some(ref certs) if certs.has_domain(domain)) {
|
&& !matches!(certs, Some(ref certs) if certs.has_domain(domain))
|
||||||
|
{
|
||||||
log::info!("No certificate or key found for {s:?}, generating them.");
|
log::info!("No certificate or key found for {s:?}, generating them.");
|
||||||
|
|
||||||
let mut cert_params = CertificateParams::new(vec![domain.clone()])?;
|
let mut cert_params = CertificateParams::new(vec![domain.clone()])?;
|
||||||
|
|
@ -339,7 +340,6 @@ fn args() -> Result<Args> {
|
||||||
|
|
||||||
reload_certs = true;
|
reload_certs = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
hostnames.push(hostname);
|
hostnames.push(hostname);
|
||||||
}
|
}
|
||||||
|
|
@ -594,15 +594,15 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// correct port
|
// correct port
|
||||||
if let Some(expected_port) = self.local_port_check {
|
if let Some(expected_port) = self.local_port_check
|
||||||
if let Some(port) = url.port() {
|
&& let Some(port) = url.port()
|
||||||
|
{
|
||||||
// Validate that the port in the URL is the same as for the stream this request
|
// Validate that the port in the URL is the same as for the stream this request
|
||||||
// came in on.
|
// came in on.
|
||||||
if port != expected_port {
|
if port != expected_port {
|
||||||
return Err((PROXY_REQUEST_REFUSED, "Proxy request refused"));
|
return Err((PROXY_REQUEST_REFUSED, "Proxy request refused"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ok(url)
|
Ok(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -659,8 +659,9 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(metadata) = tokio::fs::metadata(&path).await {
|
if let Ok(metadata) = tokio::fs::metadata(&path).await
|
||||||
if metadata.is_dir() {
|
&& metadata.is_dir()
|
||||||
|
{
|
||||||
if url.path().ends_with('/') || url.path().is_empty() {
|
if url.path().ends_with('/') || url.path().is_empty() {
|
||||||
// if the path ends with a slash or the path is empty, the links will work the same
|
// if the path ends with a slash or the path is empty, the links will work the same
|
||||||
// without a redirect
|
// without a redirect
|
||||||
|
|
@ -678,7 +679,6 @@ where
|
||||||
return self.send_header(REDIRECT_PERMANENT, url.as_str()).await;
|
return self.send_header(REDIRECT_PERMANENT, url.as_str()).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let data = self.metadata.lock().await.get(&path);
|
let data = self.metadata.lock().await.get(&path);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue