Upgrade to rust stable 1.76.0 and fix clippy errors
This commit is contained in:
parent
e416a76668
commit
f562b32edb
38
flake.lock
38
flake.lock
@ -2,15 +2,17 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"fenix": {
|
"fenix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
"rust-analyzer-src": "rust-analyzer-src"
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1699770036,
|
"lastModified": 1708928609,
|
||||||
"narHash": "sha256-bZmI7ytPAYLpyFNgj5xirDkKuAniOkj1xHdv5aIJ5GM=",
|
"narHash": "sha256-LcXC2NP/TzHMmJThZGG1e+7rht5HeuZK5WOirIDg+lU=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "fenix",
|
"repo": "fenix",
|
||||||
"rev": "81ab0b4f7ae9ebb57daa0edf119c4891806e4d3a",
|
"rev": "e928fb6b5179ebd032c19afac5c461ccc0b6de55",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -21,7 +23,7 @@
|
|||||||
},
|
},
|
||||||
"naersk": {
|
"naersk": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1690373729,
|
"lastModified": 1690373729,
|
||||||
@ -39,22 +41,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
|
||||||
"lastModified": 1699099776,
|
|
||||||
"narHash": "sha256-X09iKJ27mGsGambGfkKzqvw5esP1L/Rf8H3u3fCqIiU=",
|
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "85f1ba3e51676fa8cc604a3d863d729026a6b8eb",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nixos",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_2": {
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1691003216,
|
"lastModified": 1691003216,
|
||||||
"narHash": "sha256-Qq/MPkhS12Bl0X060pPvX3v9ac3f2rRQfHjjozPh/Qs=",
|
"narHash": "sha256-Qq/MPkhS12Bl0X060pPvX3v9ac3f2rRQfHjjozPh/Qs=",
|
||||||
@ -68,7 +54,7 @@
|
|||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_3": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1688392541,
|
"lastModified": 1688392541,
|
||||||
"narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=",
|
"narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=",
|
||||||
@ -88,17 +74,17 @@
|
|||||||
"inputs": {
|
"inputs": {
|
||||||
"fenix": "fenix",
|
"fenix": "fenix",
|
||||||
"naersk": "naersk",
|
"naersk": "naersk",
|
||||||
"nixpkgs": "nixpkgs_3"
|
"nixpkgs": "nixpkgs_2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1699715108,
|
"lastModified": 1708878562,
|
||||||
"narHash": "sha256-yPozsobJU55gj+szgo4Lpcg1lHvGQYAT6Y4MrC80mWE=",
|
"narHash": "sha256-IBHMNEe3lspVdIzjpM2OVZiBFmFw1DKtdgVN5G41pRc=",
|
||||||
"owner": "rust-lang",
|
"owner": "rust-lang",
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"rev": "5fcf5289e726785d20d3aa4d13d90a43ed248e83",
|
"rev": "5346002d07d09badaf37949bec68012d963d61fc",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
fenix.url = "github:nix-community/fenix";
|
fenix.url = "github:nix-community/fenix";
|
||||||
|
fenix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
naersk.url = "github:nix-community/naersk/master";
|
naersk.url = "github:nix-community/naersk/master";
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
|
||||||
};
|
};
|
||||||
@ -119,9 +120,8 @@
|
|||||||
# TODO I'd prefer to use the toolchain file
|
# TODO I'd prefer to use the toolchain file
|
||||||
# https://github.com/nix-community/fenix/issues/123
|
# https://github.com/nix-community/fenix/issues/123
|
||||||
fenixToolchain = fenixTarget: (builtins.getAttr "toolchainOf" fenixTarget) {
|
fenixToolchain = fenixTarget: (builtins.getAttr "toolchainOf" fenixTarget) {
|
||||||
channel = "nightly";
|
channel = "1.76.0";
|
||||||
date = "2023-07-23";
|
sha256 = "sha256-e4mlaJehWBymYxJGgnbuCObVlqMlQSilZ8FljG9zPHY=";
|
||||||
sha256 = "sha256-LU4C/i+maIOqBZagUaXpFyWZyOVfQ3Ah5/JTz7v6CG4=";
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
fenixPkgs.combine [
|
fenixPkgs.combine [
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2023-07-23"
|
channel = "1.76.0"
|
||||||
components = [ "rustfmt", "rustc-dev", "clippy", "cargo" ]
|
components = [ "rustfmt", "rustc-dev", "clippy", "cargo", "rust-std" ]
|
||||||
targets = [
|
targets = [
|
||||||
"x86_64-unknown-linux-musl",
|
"x86_64-unknown-linux-musl",
|
||||||
"i686-unknown-linux-musl",
|
"i686-unknown-linux-musl",
|
||||||
|
@ -136,16 +136,17 @@ impl Manager for ManagerImpl {
|
|||||||
let thirty_days = openssl::asn1::Asn1Time::days_from_now(30)
|
let thirty_days = openssl::asn1::Asn1Time::days_from_now(30)
|
||||||
.expect("parsed thirty days from now as Asn1Time");
|
.expect("parsed thirty days from now as Asn1Time");
|
||||||
|
|
||||||
let cert_with_soonest_not_after = certs
|
let cert_with_soonest_not_after = util::try_collect(
|
||||||
.into_iter()
|
certs
|
||||||
.map(|cert| openssl::x509::X509::try_from(&cert))
|
.into_iter()
|
||||||
.try_collect::<Vec<openssl::x509::X509>>()
|
.map(|cert| openssl::x509::X509::try_from(&cert)),
|
||||||
.or_unexpected_while("parsing x509 certs")?
|
)
|
||||||
.into_iter()
|
.or_unexpected_while("parsing x509 certs")?
|
||||||
.reduce(|a, b| if a.not_after() < b.not_after() { a } else { b })
|
.into_iter()
|
||||||
.ok_or(unexpected::Error::from(
|
.reduce(|a, b| if a.not_after() < b.not_after() { a } else { b })
|
||||||
"expected there to be more than one cert",
|
.ok_or(unexpected::Error::from(
|
||||||
))?;
|
"expected there to be more than one cert",
|
||||||
|
))?;
|
||||||
|
|
||||||
if thirty_days < cert_with_soonest_not_after.not_after() {
|
if thirty_days < cert_with_soonest_not_after.not_after() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -304,17 +305,18 @@ impl Manager for ManagerImpl {
|
|||||||
|
|
||||||
// Download the certificate, and panic if it doesn't exist.
|
// Download the certificate, and panic if it doesn't exist.
|
||||||
log::info!("Fetching certificate for domain {}", domain.as_str());
|
log::info!("Fetching certificate for domain {}", domain.as_str());
|
||||||
let certs = order
|
let certs = util::try_collect(
|
||||||
.certificate()
|
order
|
||||||
.await
|
.certificate()
|
||||||
.or_unexpected_while("fetching certificate")?
|
.await
|
||||||
.ok_or(unexpected::Error::from(
|
.or_unexpected_while("fetching certificate")?
|
||||||
"expected the order to return a certificate",
|
.ok_or(unexpected::Error::from(
|
||||||
))?
|
"expected the order to return a certificate",
|
||||||
.into_iter()
|
))?
|
||||||
.map(|cert| Certificate::try_from(cert.as_ref()))
|
.into_iter()
|
||||||
.try_collect::<Vec<Certificate>>()
|
.map(|cert| Certificate::try_from(cert.as_ref())),
|
||||||
.or_unexpected_while("parsing certificate")?;
|
)
|
||||||
|
.or_unexpected_while("parsing certificate")?;
|
||||||
|
|
||||||
if certs.len() <= 1 {
|
if certs.len() <= 1 {
|
||||||
return Err(unexpected::Error::from(
|
return Err(unexpected::Error::from(
|
||||||
|
@ -6,13 +6,9 @@ fn addr_from_url(
|
|||||||
expected_scheme: &str,
|
expected_scheme: &str,
|
||||||
default_port: u16,
|
default_port: u16,
|
||||||
) -> unexpected::Result<String> {
|
) -> unexpected::Result<String> {
|
||||||
let parsed: http::Uri = url
|
let parsed: http::Uri = url.parse().or_unexpected_while("could not parse as url")?;
|
||||||
.parse()
|
|
||||||
.map_unexpected_while(|| format!("could not parse as url"))?;
|
|
||||||
|
|
||||||
let scheme = parsed
|
let scheme = parsed.scheme().or_unexpected_while("scheme is missing")?;
|
||||||
.scheme()
|
|
||||||
.map_unexpected_while(|| format!("scheme is missing"))?;
|
|
||||||
|
|
||||||
if scheme != expected_scheme {
|
if scheme != expected_scheme {
|
||||||
return Err(unexpected::Error::from(
|
return Err(unexpected::Error::from(
|
||||||
|
@ -4,6 +4,15 @@ use crate::{origin, task_stack, util};
|
|||||||
|
|
||||||
use std::sync;
|
use std::sync;
|
||||||
|
|
||||||
|
fn collect_into<I, V>(into: &mut Vec<V>, iter: I)
|
||||||
|
where
|
||||||
|
I: std::iter::Iterator<Item = V>,
|
||||||
|
{
|
||||||
|
for v in iter {
|
||||||
|
into.push(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub enum GetSettingsResult {
|
pub enum GetSettingsResult {
|
||||||
Stored(domain::Settings),
|
Stored(domain::Settings),
|
||||||
Builtin(domain::config::ConfigBuiltinDomain),
|
Builtin(domain::config::ConfigBuiltinDomain),
|
||||||
@ -477,23 +486,27 @@ impl Manager for ManagerImpl {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
self.config
|
collect_into(
|
||||||
.builtin_domains
|
&mut res,
|
||||||
.iter()
|
self.config
|
||||||
.map(|(domain, config)| ManagedDomain {
|
.builtin_domains
|
||||||
domain: domain.clone(),
|
.iter()
|
||||||
public: config.public,
|
.map(|(domain, config)| ManagedDomain {
|
||||||
})
|
domain: domain.clone(),
|
||||||
.collect_into(&mut res);
|
public: config.public,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
self.config
|
collect_into(
|
||||||
.proxied_domains
|
&mut res,
|
||||||
.keys()
|
self.config
|
||||||
.map(|domain| ManagedDomain {
|
.proxied_domains
|
||||||
domain: domain.clone(),
|
.keys()
|
||||||
public: false,
|
.map(|domain| ManagedDomain {
|
||||||
})
|
domain: domain.clone(),
|
||||||
.collect_into(&mut res);
|
public: false,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
if let Some(ref interface_domain) = self.config.interface_domain {
|
if let Some(ref interface_domain) = self.config.interface_domain {
|
||||||
res.push(ManagedDomain {
|
res.push(ManagedDomain {
|
||||||
@ -502,14 +515,16 @@ impl Manager for ManagerImpl {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
self.config
|
collect_into(
|
||||||
.external_domains
|
&mut res,
|
||||||
.keys()
|
self.config
|
||||||
.map(|domain| ManagedDomain {
|
.external_domains
|
||||||
domain: domain.clone(),
|
.keys()
|
||||||
public: false,
|
.map(|domain| ManagedDomain {
|
||||||
})
|
domain: domain.clone(),
|
||||||
.collect_into(&mut res);
|
public: false,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
@ -72,21 +72,20 @@ impl Store for FSStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn all_domains(&self) -> unexpected::Result<Vec<domain::Name>> {
|
fn all_domains(&self) -> unexpected::Result<Vec<domain::Name>> {
|
||||||
fs::read_dir(&self.dir_path)
|
let domains = fs::read_dir(&self.dir_path).or_unexpected()?.map(
|
||||||
.or_unexpected()?
|
|dir_entry_res: io::Result<fs::DirEntry>| -> unexpected::Result<domain::Name> {
|
||||||
.map(
|
let domain = dir_entry_res.or_unexpected()?.file_name();
|
||||||
|dir_entry_res: io::Result<fs::DirEntry>| -> unexpected::Result<domain::Name> {
|
let domain = domain.to_str().ok_or(unexpected::Error::from(
|
||||||
let domain = dir_entry_res.or_unexpected()?.file_name();
|
"couldn't convert os string to &str",
|
||||||
let domain = domain.to_str().ok_or(unexpected::Error::from(
|
))?;
|
||||||
"couldn't convert os string to &str",
|
|
||||||
))?;
|
|
||||||
|
|
||||||
domain
|
domain
|
||||||
.parse()
|
.parse()
|
||||||
.map_unexpected_while(|| format!("parsing {domain} as domain name"))
|
.map_unexpected_while(|| format!("parsing {domain} as domain name"))
|
||||||
},
|
},
|
||||||
)
|
);
|
||||||
.try_collect()
|
|
||||||
|
crate::util::try_collect(domains.into_iter())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
#![feature(result_option_inspect)]
|
|
||||||
#![feature(iterator_try_collect)]
|
|
||||||
#![feature(iter_collect_into)]
|
|
||||||
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod domain;
|
pub mod domain;
|
||||||
pub mod origin;
|
pub mod origin;
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#![feature(trait_upcasting)]
|
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::path;
|
use std::path;
|
||||||
|
|
||||||
|
@ -13,13 +13,9 @@ pub struct GitUrl {
|
|||||||
impl std::str::FromStr for GitUrl {
|
impl std::str::FromStr for GitUrl {
|
||||||
type Err = unexpected::Error;
|
type Err = unexpected::Error;
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
let parsed: http::Uri = s
|
let parsed: http::Uri = s.parse().or_unexpected_while("parsing as url")?;
|
||||||
.parse()
|
|
||||||
.map_unexpected_while(|| format!("parsing as url"))?;
|
|
||||||
|
|
||||||
let scheme = parsed
|
let scheme = parsed.scheme().or_unexpected_while("extracting scheme")?;
|
||||||
.scheme()
|
|
||||||
.map_unexpected_while(|| format!("extracting scheme"))?;
|
|
||||||
|
|
||||||
if scheme != "http" && scheme != "https" {
|
if scheme != "http" && scheme != "https" {
|
||||||
return Err(unexpected::Error::from(
|
return Err(unexpected::Error::from(
|
||||||
|
11
src/util.rs
11
src/util.rs
@ -68,3 +68,14 @@ impl BoxByteStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub type BoxFuture<'a, O> = pin::Pin<Box<dyn futures::Future<Output = O> + Send + 'a>>;
|
pub type BoxFuture<'a, O> = pin::Pin<Box<dyn futures::Future<Output = O> + Send + 'a>>;
|
||||||
|
|
||||||
|
pub fn try_collect<I, V, E>(iter: I) -> Result<Vec<V>, E>
|
||||||
|
where
|
||||||
|
I: std::iter::Iterator<Item = Result<V, E>>,
|
||||||
|
{
|
||||||
|
let mut res = Vec::<V>::new();
|
||||||
|
for v in iter {
|
||||||
|
res.push(v?);
|
||||||
|
}
|
||||||
|
Ok(res)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user