mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-08-15 18:47:27 +00:00
more simpler clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
3f7440916f
commit
8e70d421f2
@ -64,11 +64,9 @@ impl ServerAdapter for StaticAuthAdapter {
|
|||||||
Box::new(SimpleUserInformation {});
|
Box::new(SimpleUserInformation {});
|
||||||
Ok((String::from("root@pam"), user_info))
|
Ok((String::from("root@pam"), user_info))
|
||||||
}
|
}
|
||||||
_ => {
|
_ => Err(AuthError::Generic(format_err!(
|
||||||
return Err(AuthError::Generic(format_err!(
|
"invalid file restore ticket provided"
|
||||||
"invalid file restore ticket provided"
|
))),
|
||||||
)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
|
|||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use tokio_stream::wrappers::ReceiverStream;
|
use tokio_stream::wrappers::ReceiverStream;
|
||||||
|
|
||||||
use proxmox_http::client::{RateLimitedStream, ShareableRateLimit};
|
use proxmox_http::client::RateLimitedStream;
|
||||||
use proxmox_lang::try_block;
|
use proxmox_lang::try_block;
|
||||||
use proxmox_metrics::MetricsData;
|
use proxmox_metrics::MetricsData;
|
||||||
use proxmox_router::{RpcEnvironment, RpcEnvironmentType, UserInformation};
|
use proxmox_router::{RpcEnvironment, RpcEnvironmentType, UserInformation};
|
||||||
@ -46,7 +46,7 @@ use proxmox_backup::{
|
|||||||
jobstate::{self, Job},
|
jobstate::{self, Job},
|
||||||
},
|
},
|
||||||
tools::disks::BlockDevStat,
|
tools::disks::BlockDevStat,
|
||||||
traffic_control_cache::TRAFFIC_CONTROL_CACHE,
|
traffic_control_cache::{SharedRateLimit, TRAFFIC_CONTROL_CACHE},
|
||||||
};
|
};
|
||||||
|
|
||||||
use pbs_buildcfg::configdir;
|
use pbs_buildcfg::configdir;
|
||||||
@ -1387,10 +1387,7 @@ async fn run_traffic_control_updater() {
|
|||||||
|
|
||||||
fn lookup_rate_limiter(
|
fn lookup_rate_limiter(
|
||||||
peer: std::net::SocketAddr,
|
peer: std::net::SocketAddr,
|
||||||
) -> (
|
) -> (Option<SharedRateLimit>, Option<SharedRateLimit>) {
|
||||||
Option<Arc<dyn ShareableRateLimit>>,
|
|
||||||
Option<Arc<dyn ShareableRateLimit>>,
|
|
||||||
) {
|
|
||||||
let mut cache = TRAFFIC_CONTROL_CACHE.lock().unwrap();
|
let mut cache = TRAFFIC_CONTROL_CACHE.lock().unwrap();
|
||||||
|
|
||||||
let now = proxmox_time::epoch_i64();
|
let now = proxmox_time::epoch_i64();
|
||||||
|
@ -20,6 +20,8 @@ use pbs_config::ConfigVersionCache;
|
|||||||
|
|
||||||
use crate::tools::SharedRateLimiter;
|
use crate::tools::SharedRateLimiter;
|
||||||
|
|
||||||
|
pub type SharedRateLimit = Arc<dyn ShareableRateLimit>;
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
/// Shared traffic control cache singleton.
|
/// Shared traffic control cache singleton.
|
||||||
pub static ref TRAFFIC_CONTROL_CACHE: Arc<Mutex<TrafficControlCache>> =
|
pub static ref TRAFFIC_CONTROL_CACHE: Arc<Mutex<TrafficControlCache>> =
|
||||||
@ -54,13 +56,7 @@ pub struct TrafficControlCache {
|
|||||||
last_update: i64,
|
last_update: i64,
|
||||||
last_traffic_control_generation: usize,
|
last_traffic_control_generation: usize,
|
||||||
rules: Vec<ParsedTcRule>,
|
rules: Vec<ParsedTcRule>,
|
||||||
limiter_map: HashMap<
|
limiter_map: HashMap<String, (Option<SharedRateLimit>, Option<SharedRateLimit>)>,
|
||||||
String,
|
|
||||||
(
|
|
||||||
Option<Arc<dyn ShareableRateLimit>>,
|
|
||||||
Option<Arc<dyn ShareableRateLimit>>,
|
|
||||||
),
|
|
||||||
>,
|
|
||||||
use_utc: bool, // currently only used for testing
|
use_utc: bool, // currently only used for testing
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +111,7 @@ fn create_limiter(
|
|||||||
name: &str,
|
name: &str,
|
||||||
rate: u64,
|
rate: u64,
|
||||||
burst: u64,
|
burst: u64,
|
||||||
) -> Result<Arc<dyn ShareableRateLimit>, Error> {
|
) -> Result<SharedRateLimit, Error> {
|
||||||
if use_shared_memory {
|
if use_shared_memory {
|
||||||
let limiter = SharedRateLimiter::mmap_shmem(name, rate, burst)?;
|
let limiter = SharedRateLimiter::mmap_shmem(name, rate, burst)?;
|
||||||
Ok(Arc::new(limiter))
|
Ok(Arc::new(limiter))
|
||||||
@ -339,11 +335,7 @@ impl TrafficControlCache {
|
|||||||
&self,
|
&self,
|
||||||
peer: SocketAddr,
|
peer: SocketAddr,
|
||||||
now: i64,
|
now: i64,
|
||||||
) -> (
|
) -> (&str, Option<SharedRateLimit>, Option<SharedRateLimit>) {
|
||||||
&str,
|
|
||||||
Option<Arc<dyn ShareableRateLimit>>,
|
|
||||||
Option<Arc<dyn ShareableRateLimit>>,
|
|
||||||
) {
|
|
||||||
let peer_ip = cannonical_ip(peer.ip());
|
let peer_ip = cannonical_ip(peer.ip());
|
||||||
|
|
||||||
log::debug!("lookup_rate_limiter: {:?}", peer_ip);
|
log::debug!("lookup_rate_limiter: {:?}", peer_ip);
|
||||||
|
Loading…
Reference in New Issue
Block a user