mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-12 12:47:25 +08:00
fix: clippy errors with stable toolchain and default features (#1553)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -67,13 +67,10 @@ impl IfConfiguerTrait for MacIfConfiger {
|
||||
}
|
||||
|
||||
async fn remove_ip(&self, name: &str, ip: Option<Ipv4Inet>) -> Result<(), Error> {
|
||||
if ip.is_none() {
|
||||
run_shell_cmd(format!("ifconfig {} inet delete", name).as_str()).await
|
||||
if let Some(ip) = ip {
|
||||
run_shell_cmd(format!("ifconfig {} inet {} delete", name, ip.address()).as_str()).await
|
||||
} else {
|
||||
run_shell_cmd(
|
||||
format!("ifconfig {} inet {} delete", name, ip.unwrap().address()).as_str(),
|
||||
)
|
||||
.await
|
||||
run_shell_cmd(format!("ifconfig {} inet delete", name).as_str()).await
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,11 +130,8 @@ impl DNSTunnelConnector {
|
||||
for record in response.iter() {
|
||||
let parsed_record = Self::handle_one_srv_record(record, protocol);
|
||||
tracing::info!(?parsed_record, ?srv_domain, "parsed_record");
|
||||
if parsed_record.is_err() {
|
||||
eprintln!(
|
||||
"got invalid srv record {:?}",
|
||||
parsed_record.as_ref().unwrap_err()
|
||||
);
|
||||
if let Err(e) = &parsed_record {
|
||||
eprintln!("got invalid srv record {:?}", e);
|
||||
continue;
|
||||
}
|
||||
responses.insert(parsed_record.unwrap());
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::{
|
||||
|
||||
use anyhow::Context;
|
||||
use cidr::Ipv4Inet;
|
||||
use clap::{command, Args, CommandFactory, Parser, Subcommand};
|
||||
use clap::{Args, CommandFactory, Parser, Subcommand};
|
||||
use clap_complete::Shell;
|
||||
use dashmap::DashMap;
|
||||
use humansize::format_size;
|
||||
|
||||
@@ -1212,7 +1212,7 @@ async fn run_main(cli: Cli) -> anyhow::Result<()> {
|
||||
if let Some(config_files) = cli.config_file {
|
||||
let config_file_count = config_files.len();
|
||||
for config_file in config_files {
|
||||
let mut cfg = if config_file == PathBuf::from("-") {
|
||||
let mut cfg = if config_file.as_os_str() == "-" {
|
||||
let mut stdin = String::new();
|
||||
_ = tokio::io::stdin().read_to_string(&mut stdin).await?;
|
||||
TomlConfigLoader::new_from_str(stdin.as_str())
|
||||
|
||||
@@ -12,7 +12,7 @@ use thiserror::Error;
|
||||
use tokio::io::{AsyncRead, AsyncReadExt};
|
||||
use tokio::net::lookup_host;
|
||||
|
||||
use tracing::{debug, error};
|
||||
use tracing::debug;
|
||||
|
||||
/// SOCKS5 reply code
|
||||
#[derive(Error, Debug)]
|
||||
|
||||
@@ -492,16 +492,18 @@ impl MagicDnsServerInstance {
|
||||
let mut dns_server = Server::new(dns_config);
|
||||
dns_server.run().await?;
|
||||
|
||||
if !tun_inet.contains(&fake_ip) && tun_dev.is_some() {
|
||||
let cost = if cfg!(target_os = "windows") {
|
||||
Some(4)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let ifcfg = IfConfiger {};
|
||||
ifcfg
|
||||
.add_ipv4_route(tun_dev.as_ref().unwrap(), fake_ip, 32, cost)
|
||||
.await?;
|
||||
if !tun_inet.contains(&fake_ip) {
|
||||
if let Some(tun_dev_name) = &tun_dev {
|
||||
let cost = if cfg!(target_os = "windows") {
|
||||
Some(4)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let ifcfg = IfConfiger {};
|
||||
ifcfg
|
||||
.add_ipv4_route(tun_dev_name, fake_ip, 32, cost)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
let data = Arc::new(MagicDnsServerInstanceData {
|
||||
@@ -544,13 +546,14 @@ impl MagicDnsServerInstance {
|
||||
if let Err(e) = ret {
|
||||
tracing::error!("Failed to close system config: {:?}", e);
|
||||
}
|
||||
}
|
||||
|
||||
if !self.tun_inet.contains(&self.data.fake_ip) && self.data.tun_dev.is_some() {
|
||||
let ifcfg = IfConfiger {};
|
||||
let _ = ifcfg
|
||||
.remove_ipv4_route(self.data.tun_dev.as_ref().unwrap(), self.data.fake_ip, 32)
|
||||
.await;
|
||||
if !self.tun_inet.contains(&self.data.fake_ip) {
|
||||
if let Some(tun_dev_name) = &self.data.tun_dev {
|
||||
let ifcfg = IfConfiger {};
|
||||
let _ = ifcfg
|
||||
.remove_ipv4_route(tun_dev_name, self.data.fake_ip, 32)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let _ = self
|
||||
|
||||
@@ -12,8 +12,8 @@ const MAC_RESOLVER_FILE_HEADER: &str = "# Added by easytier\n";
|
||||
const ETC_RESOLVER: &str = "/etc/resolver";
|
||||
const ETC_RESOLV_CONF: &str = "/etc/resolv.conf";
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct DarwinConfigurator {}
|
||||
|
||||
impl DarwinConfigurator {
|
||||
pub fn new() -> Self {
|
||||
DarwinConfigurator {}
|
||||
|
||||
@@ -102,7 +102,7 @@ async fn test_magic_dns_server_instance() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let routes = vec![
|
||||
let routes = [
|
||||
Route {
|
||||
hostname: "test1".to_string(),
|
||||
ipv4_addr: Some(Ipv4Inet::from_str("8.8.8.8/24").unwrap().into()),
|
||||
|
||||
@@ -2156,9 +2156,9 @@ impl OspfRouteRpc for RouteSessionManager {
|
||||
let peer_infos = request.peer_infos.map(|x| x.items);
|
||||
let conn_info = request.conn_info;
|
||||
let foreign_network = request.foreign_network_infos;
|
||||
let raw_peer_infos = if peer_infos.is_some() {
|
||||
let raw_peer_infos = if let Some(peer_infos_ref) = &peer_infos {
|
||||
let r = get_raw_peer_infos(&mut ctrl.get_raw_input().unwrap()).unwrap();
|
||||
assert_eq!(r.len(), peer_infos.as_ref().unwrap().len());
|
||||
assert_eq!(r.len(), peer_infos_ref.len());
|
||||
Some(r)
|
||||
} else {
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user