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,10 +136,11 @@ 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(
|
||||||
|
certs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|cert| openssl::x509::X509::try_from(&cert))
|
.map(|cert| openssl::x509::X509::try_from(&cert)),
|
||||||
.try_collect::<Vec<openssl::x509::X509>>()
|
)
|
||||||
.or_unexpected_while("parsing x509 certs")?
|
.or_unexpected_while("parsing x509 certs")?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.reduce(|a, b| if a.not_after() < b.not_after() { a } else { b })
|
.reduce(|a, b| if a.not_after() < b.not_after() { a } else { b })
|
||||||
@ -304,7 +305,8 @@ 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(
|
||||||
|
order
|
||||||
.certificate()
|
.certificate()
|
||||||
.await
|
.await
|
||||||
.or_unexpected_while("fetching certificate")?
|
.or_unexpected_while("fetching certificate")?
|
||||||
@ -312,8 +314,8 @@ impl Manager for ManagerImpl {
|
|||||||
"expected the order to return a certificate",
|
"expected the order to return a certificate",
|
||||||
))?
|
))?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|cert| Certificate::try_from(cert.as_ref()))
|
.map(|cert| Certificate::try_from(cert.as_ref())),
|
||||||
.try_collect::<Vec<Certificate>>()
|
)
|
||||||
.or_unexpected_while("parsing certificate")?;
|
.or_unexpected_while("parsing certificate")?;
|
||||||
|
|
||||||
if certs.len() <= 1 {
|
if certs.len() <= 1 {
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
collect_into(
|
||||||
|
&mut res,
|
||||||
self.config
|
self.config
|
||||||
.builtin_domains
|
.builtin_domains
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(domain, config)| ManagedDomain {
|
.map(|(domain, config)| ManagedDomain {
|
||||||
domain: domain.clone(),
|
domain: domain.clone(),
|
||||||
public: config.public,
|
public: config.public,
|
||||||
})
|
}),
|
||||||
.collect_into(&mut res);
|
);
|
||||||
|
|
||||||
|
collect_into(
|
||||||
|
&mut res,
|
||||||
self.config
|
self.config
|
||||||
.proxied_domains
|
.proxied_domains
|
||||||
.keys()
|
.keys()
|
||||||
.map(|domain| ManagedDomain {
|
.map(|domain| ManagedDomain {
|
||||||
domain: domain.clone(),
|
domain: domain.clone(),
|
||||||
public: false,
|
public: false,
|
||||||
})
|
}),
|
||||||
.collect_into(&mut res);
|
);
|
||||||
|
|
||||||
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 {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
collect_into(
|
||||||
|
&mut res,
|
||||||
self.config
|
self.config
|
||||||
.external_domains
|
.external_domains
|
||||||
.keys()
|
.keys()
|
||||||
.map(|domain| ManagedDomain {
|
.map(|domain| ManagedDomain {
|
||||||
domain: domain.clone(),
|
domain: domain.clone(),
|
||||||
public: false,
|
public: false,
|
||||||
})
|
}),
|
||||||
.collect_into(&mut res);
|
);
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
@ -72,9 +72,7 @@ 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()?
|
|
||||||
.map(
|
|
||||||
|dir_entry_res: io::Result<fs::DirEntry>| -> unexpected::Result<domain::Name> {
|
|dir_entry_res: io::Result<fs::DirEntry>| -> unexpected::Result<domain::Name> {
|
||||||
let domain = dir_entry_res.or_unexpected()?.file_name();
|
let domain = dir_entry_res.or_unexpected()?.file_name();
|
||||||
let domain = domain.to_str().ok_or(unexpected::Error::from(
|
let domain = domain.to_str().ok_or(unexpected::Error::from(
|
||||||
@ -85,8 +83,9 @@ impl Store for FSStore {
|
|||||||
.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