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