mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-06 17:59:11 +00:00
clippy all codes (#1214)
1. clippy code 2. add fmt and clippy check in ci
This commit is contained in:
@@ -258,7 +258,7 @@ pub struct Instance {
|
||||
}
|
||||
|
||||
impl Instance {
|
||||
pub fn new(config: impl ConfigLoader + Send + Sync + 'static) -> Self {
|
||||
pub fn new(config: impl ConfigLoader + 'static) -> Self {
|
||||
let global_ctx = Arc::new(GlobalCtx::new(config));
|
||||
|
||||
tracing::info!(
|
||||
@@ -304,10 +304,10 @@ impl Instance {
|
||||
#[cfg(feature = "socks5")]
|
||||
let socks5_server = Socks5Server::new(global_ctx.clone(), peer_manager.clone(), None);
|
||||
|
||||
let rpc_server = global_ctx.config.get_rpc_portal().and_then(|s| {
|
||||
Some(StandAloneServer::new(TcpTunnelListener::new(
|
||||
let rpc_server = global_ctx.config.get_rpc_portal().map(|s| {
|
||||
StandAloneServer::new(TcpTunnelListener::new(
|
||||
format!("tcp://{}", s).parse().unwrap(),
|
||||
)))
|
||||
))
|
||||
});
|
||||
|
||||
Instance {
|
||||
@@ -470,7 +470,7 @@ impl Instance {
|
||||
continue;
|
||||
}
|
||||
|
||||
let last_ip = current_dhcp_ip.clone();
|
||||
let last_ip = current_dhcp_ip;
|
||||
tracing::debug!(
|
||||
?current_dhcp_ip,
|
||||
?candidate_ipv4_addr,
|
||||
@@ -509,11 +509,7 @@ impl Instance {
|
||||
Self::use_new_nic_ctx(
|
||||
nic_ctx.clone(),
|
||||
new_nic_ctx,
|
||||
Self::create_magic_dns_runner(
|
||||
peer_manager_c.clone(),
|
||||
ifname,
|
||||
ip.clone(),
|
||||
),
|
||||
Self::create_magic_dns_runner(peer_manager_c.clone(), ifname, ip),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
@@ -890,7 +886,7 @@ impl Instance {
|
||||
) -> Result<GetStatsResponse, rpc_types::error::Error> {
|
||||
let stats_manager = self.global_ctx.stats_manager();
|
||||
let snapshots = stats_manager.get_all_metrics();
|
||||
|
||||
|
||||
let metrics = snapshots
|
||||
.into_iter()
|
||||
.map(|snapshot| {
|
||||
@@ -898,7 +894,7 @@ impl Instance {
|
||||
for label in snapshot.labels.labels() {
|
||||
labels.insert(label.key.clone(), label.value.clone());
|
||||
}
|
||||
|
||||
|
||||
MetricSnapshot {
|
||||
name: snapshot.name_str(),
|
||||
value: snapshot.value,
|
||||
@@ -906,7 +902,7 @@ impl Instance {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
Ok(GetStatsResponse { metrics })
|
||||
}
|
||||
|
||||
@@ -917,7 +913,7 @@ impl Instance {
|
||||
) -> Result<GetPrometheusStatsResponse, rpc_types::error::Error> {
|
||||
let stats_manager = self.global_ctx.stats_manager();
|
||||
let prometheus_text = stats_manager.export_prometheus();
|
||||
|
||||
|
||||
Ok(GetPrometheusStatsResponse { prometheus_text })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user