rust fmt for pbs src
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
@ -6,15 +6,11 @@ use anyhow::{bail, format_err, Error};
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox_sys::error::SysError;
|
||||
use proxmox_sys::fs::{CreateOptions, file_read_string};
|
||||
use proxmox_sys::fs::{file_read_string, CreateOptions};
|
||||
|
||||
use pbs_api_types::PROXMOX_SAFE_ID_REGEX;
|
||||
|
||||
use crate::api2::types::{
|
||||
AcmeChallengeSchema,
|
||||
KnownAcmeDirectory,
|
||||
AcmeAccountName,
|
||||
};
|
||||
use crate::api2::types::{AcmeAccountName, AcmeChallengeSchema, KnownAcmeDirectory};
|
||||
|
||||
pub(crate) const ACME_DIR: &str = pbs_buildcfg::configdir!("/acme");
|
||||
pub(crate) const ACME_ACCOUNT_DIR: &str = pbs_buildcfg::configdir!("/acme/accounts");
|
||||
@ -65,7 +61,6 @@ pub fn account_path(name: &str) -> String {
|
||||
format!("{}/{}", ACME_ACCOUNT_DIR, name)
|
||||
}
|
||||
|
||||
|
||||
pub fn foreach_acme_account<F>(mut func: F) -> Result<(), Error>
|
||||
where
|
||||
F: FnMut(AcmeAccountName) -> ControlFlow<Result<(), Error>>,
|
||||
@ -163,7 +158,10 @@ pub fn complete_acme_plugin_type(_arg: &str, _param: &HashMap<String, String>) -
|
||||
]
|
||||
}
|
||||
|
||||
pub fn complete_acme_api_challenge_type(_arg: &str, param: &HashMap<String, String>) -> Vec<String> {
|
||||
pub fn complete_acme_api_challenge_type(
|
||||
_arg: &str,
|
||||
param: &HashMap<String, String>,
|
||||
) -> Vec<String> {
|
||||
if param.get("type") == Some(&"dns".to_string()) {
|
||||
match load_dns_challenge_schema() {
|
||||
Ok(schema) => schema.into_iter().map(|s| s.id).collect(),
|
||||
|
@ -4,11 +4,11 @@
|
||||
//! configuration files.
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use std::path::PathBuf;
|
||||
use nix::sys::stat::Mode;
|
||||
use openssl::rsa::{Rsa};
|
||||
use openssl::x509::{X509Builder};
|
||||
use openssl::pkey::PKey;
|
||||
use openssl::rsa::Rsa;
|
||||
use openssl::x509::X509Builder;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use proxmox_lang::try_block;
|
||||
|
||||
@ -73,23 +73,23 @@ pub fn create_configdir() -> Result<(), Error> {
|
||||
|
||||
let backup_user = pbs_config::backup_user()?;
|
||||
|
||||
nix::unistd::chown(cfgdir, Some(backup_user.uid), Some(backup_user.gid))
|
||||
.map_err(|err| {
|
||||
format_err!(
|
||||
"unable to set configuration directory '{}' permissions - {}",
|
||||
cfgdir,
|
||||
err
|
||||
)
|
||||
})
|
||||
nix::unistd::chown(cfgdir, Some(backup_user.uid), Some(backup_user.gid)).map_err(|err| {
|
||||
format_err!(
|
||||
"unable to set configuration directory '{}' permissions - {}",
|
||||
cfgdir,
|
||||
err
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// Update self signed node certificate.
|
||||
pub fn update_self_signed_cert(force: bool) -> Result<(), Error> {
|
||||
|
||||
let key_path = PathBuf::from(configdir!("/proxy.key"));
|
||||
let cert_path = PathBuf::from(configdir!("/proxy.pem"));
|
||||
|
||||
if key_path.exists() && cert_path.exists() && !force { return Ok(()); }
|
||||
if key_path.exists() && cert_path.exists() && !force {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let rsa = Rsa::generate(4096).unwrap();
|
||||
|
||||
@ -101,7 +101,7 @@ pub fn update_self_signed_cert(force: bool) -> Result<(), Error> {
|
||||
|
||||
let today = openssl::asn1::Asn1Time::days_from_now(0)?;
|
||||
x509.set_not_before(&today)?;
|
||||
let expire = openssl::asn1::Asn1Time::days_from_now(365*1000)?;
|
||||
let expire = openssl::asn1::Asn1Time::days_from_now(365 * 1000)?;
|
||||
x509.set_not_after(&expire)?;
|
||||
|
||||
let nodename = proxmox_sys::nodename();
|
||||
@ -144,8 +144,12 @@ pub fn update_self_signed_cert(force: bool) -> Result<(), Error> {
|
||||
|
||||
alt_names.dns("localhost");
|
||||
|
||||
if nodename != "localhost" { alt_names.dns(nodename); }
|
||||
if nodename != fqdn { alt_names.dns(&fqdn); }
|
||||
if nodename != "localhost" {
|
||||
alt_names.dns(nodename);
|
||||
}
|
||||
if nodename != fqdn {
|
||||
alt_names.dns(&fqdn);
|
||||
}
|
||||
|
||||
let alt_names = alt_names.build(&context)?;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use openssl::ssl::{SslAcceptor, SslMethod};
|
||||
use anyhow::{bail, Error};
|
||||
use openssl::ssl::{SslAcceptor, SslMethod};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use proxmox_schema::{api, ApiStringFormat, ApiType, Updater};
|
||||
@ -66,7 +66,7 @@ pub struct AcmeConfig {
|
||||
// TODO: auto-generate from available translations
|
||||
#[api]
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all="lowercase")]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Translation {
|
||||
/// Arabic
|
||||
Ar,
|
||||
@ -107,7 +107,7 @@ pub enum Translation {
|
||||
/// Polish
|
||||
Pl,
|
||||
/// Portuguese (Brazil)
|
||||
#[serde(rename="pt_BR")]
|
||||
#[serde(rename = "pt_BR")]
|
||||
PtBr,
|
||||
/// Russian
|
||||
Ru,
|
||||
@ -118,10 +118,10 @@ pub enum Translation {
|
||||
/// Turkish
|
||||
Tr,
|
||||
/// Chinese (simplified)
|
||||
#[serde(rename="zh_CN")]
|
||||
#[serde(rename = "zh_CN")]
|
||||
ZhCn,
|
||||
/// Chinese (traditional)
|
||||
#[serde(rename="zh_TW")]
|
||||
#[serde(rename = "zh_TW")]
|
||||
ZhTw,
|
||||
}
|
||||
|
||||
@ -208,11 +208,11 @@ pub struct NodeConfig {
|
||||
pub email_from: Option<String>,
|
||||
|
||||
/// List of TLS ciphers for TLS 1.3 that will be used by the proxy. (Proxy has to be restarted for changes to take effect)
|
||||
#[serde(skip_serializing_if = "Option::is_none", rename="ciphers-tls-1.3")]
|
||||
#[serde(skip_serializing_if = "Option::is_none", rename = "ciphers-tls-1.3")]
|
||||
pub ciphers_tls_1_3: Option<String>,
|
||||
|
||||
/// List of TLS ciphers for TLS <= 1.2 that will be used by the proxy. (Proxy has to be restarted for changes to take effect)
|
||||
#[serde(skip_serializing_if = "Option::is_none", rename="ciphers-tls-1.2")]
|
||||
#[serde(skip_serializing_if = "Option::is_none", rename = "ciphers-tls-1.2")]
|
||||
pub ciphers_tls_1_2: Option<String>,
|
||||
|
||||
/// Default language used in the GUI
|
||||
|
Reference in New Issue
Block a user