mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 10:14:35 +00:00
chore: update Rust to 2024 edition (#2066)
This commit is contained in:
+27
-26
@@ -4,15 +4,16 @@ use std::{
|
||||
net::{IpAddr, SocketAddr},
|
||||
path::PathBuf,
|
||||
process::ExitCode,
|
||||
sync::{atomic::AtomicBool, Arc},
|
||||
sync::{Arc, atomic::AtomicBool},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
ShellType,
|
||||
common::{
|
||||
config::{
|
||||
load_config_from_file, process_secure_mode_cfg, ConfigFileControl, ConfigLoader,
|
||||
ConsoleLoggerConfig, EncryptionAlgorithm, FileLoggerConfig, LoggingConfigLoader,
|
||||
NetworkIdentity, PeerConfig, PortForwardConfig, TomlConfigLoader, VpnPortalConfig,
|
||||
ConfigFileControl, ConfigLoader, ConsoleLoggerConfig, EncryptionAlgorithm,
|
||||
FileLoggerConfig, LoggingConfigLoader, NetworkIdentity, PeerConfig, PortForwardConfig,
|
||||
TomlConfigLoader, VpnPortalConfig, load_config_from_file, process_secure_mode_cfg,
|
||||
},
|
||||
constants::EASYTIER_VERSION,
|
||||
log,
|
||||
@@ -23,7 +24,7 @@ use crate::{
|
||||
proto::common::{CompressionAlgoPb, SecureModeConfig},
|
||||
rpc_service::ApiRpcServer,
|
||||
utils::setup_panic_handler,
|
||||
web_client, ShellType,
|
||||
web_client,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use cidr::IpCidr;
|
||||
@@ -34,7 +35,7 @@ use tokio::io::AsyncReadExt;
|
||||
|
||||
use crate::tunnel::IpScheme;
|
||||
#[cfg(feature = "jemalloc-prof")]
|
||||
use jemalloc_ctl::{epoch, stats, Access as _, AsName as _};
|
||||
use jemalloc_ctl::{Access as _, AsName as _, epoch, stats};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
windows_service::define_windows_service!(ffi_service_main, win_service_main);
|
||||
@@ -741,17 +742,17 @@ impl Cli {
|
||||
|
||||
let origin_listeners = listeners;
|
||||
let mut listeners: Vec<String> = Vec::new();
|
||||
if origin_listeners.len() == 1 {
|
||||
if let Ok(port) = origin_listeners[0].parse::<u16>() {
|
||||
for proto in IpScheme::VARIANTS {
|
||||
listeners.push(format!(
|
||||
"{}://0.0.0.0:{}",
|
||||
proto,
|
||||
port + proto.port_offset()
|
||||
));
|
||||
}
|
||||
return Ok(listeners);
|
||||
if origin_listeners.len() == 1
|
||||
&& let Ok(port) = origin_listeners[0].parse::<u16>()
|
||||
{
|
||||
for proto in IpScheme::VARIANTS {
|
||||
listeners.push(format!(
|
||||
"{}://0.0.0.0:{}",
|
||||
proto,
|
||||
port + proto.port_offset()
|
||||
));
|
||||
}
|
||||
return Ok(listeners);
|
||||
}
|
||||
|
||||
for l in &origin_listeners {
|
||||
@@ -994,15 +995,15 @@ impl NetworkOptions {
|
||||
local_public_key: None,
|
||||
};
|
||||
cfg.set_secure_mode(Some(process_secure_mode_cfg(c)?));
|
||||
} else if let Some(secure_mode) = self.secure_mode {
|
||||
if secure_mode {
|
||||
let c = SecureModeConfig {
|
||||
enabled: secure_mode,
|
||||
local_private_key: self.local_private_key.clone(),
|
||||
local_public_key: self.local_public_key.clone(),
|
||||
};
|
||||
cfg.set_secure_mode(Some(process_secure_mode_cfg(c)?));
|
||||
}
|
||||
} else if let Some(secure_mode) = self.secure_mode
|
||||
&& secure_mode
|
||||
{
|
||||
let c = SecureModeConfig {
|
||||
enabled: secure_mode,
|
||||
local_private_key: self.local_private_key.clone(),
|
||||
local_public_key: self.local_public_key.clone(),
|
||||
};
|
||||
cfg.set_secure_mode(Some(process_secure_mode_cfg(c)?));
|
||||
}
|
||||
|
||||
let mut f = cfg.get_flags();
|
||||
@@ -1134,7 +1135,7 @@ impl LoggingConfigLoader for &LoggingOptions {
|
||||
#[cfg(target_os = "windows")]
|
||||
fn win_service_set_work_dir(service_name: &std::ffi::OsString) -> anyhow::Result<()> {
|
||||
use crate::common::constants::WIN_SERVICE_WORK_DIR_REG_KEY;
|
||||
use winreg::{enums::*, RegKey};
|
||||
use winreg::{RegKey, enums::*};
|
||||
|
||||
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
|
||||
let key = hklm.open_subkey_with_flags(WIN_SERVICE_WORK_DIR_REG_KEY, KEY_READ)?;
|
||||
|
||||
Reference in New Issue
Block a user