Skip to content

Commit

Permalink
ref: 优化修复问题
Browse files Browse the repository at this point in the history
  • Loading branch information
SerenitySir committed May 22, 2024
1 parent f0330ad commit 8e16d2a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/core/nal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ impl NalConfig {
pub fn default() -> Self {
NalConfig {
net_type: Option::from(NetType::Sangfor),
login: LoginConfig { username: "".to_string(), password: "".to_string() },
check: NetStatusCheck { interval: 0 },
login: LoginConfig {
username: "".to_string(),
password: "".to_string(),
},
check: NetStatusCheck {
// 默认3秒
interval: 3
},
}
}
}
Expand Down Expand Up @@ -88,7 +94,6 @@ pub fn init_config() -> NalConfig {
}



/// 获取没有代理的客户端
pub fn get_no_proxy_client() -> Client {
Client::builder()
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ async fn main() {
let service = Service::new("net-auto-login");
if cli.install {
service.install();
service.start();
return;
}
if cli.uninstall {
Expand Down
20 changes: 15 additions & 5 deletions src/util/logs.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
use std::fs;
use std::{env, fs};
use std::io::{Error};
use std::path::Path;
use chrono::Local;
use log::LevelFilter;
use log::{error, LevelFilter};

/// 初始化日志
pub fn init(log_file: &str, level: LevelFilter) -> Result<(), fern::InitError> {
fs::create_dir_all("./logs").unwrap(); // 如果需要,创建日志目录
let log_file_path = "./logs/".to_string() + log_file;
/*
pub fn init(log_file: &str, level: LevelFilter) -> Result<(), Error> {
let current_dir = if cfg!(target_os = "windows") {
// env::current_dir()?.to_str().unwrap_or(".").to_string()
env::current_exe()?
.parent().unwrap_or(Path::new("."))
.to_str().unwrap_or(".").to_string()
} else { ".".to_string() };
let logs_dir = current_dir + "/logs/";
fs::create_dir_all(logs_dir.clone()).unwrap(); // 如果需要,创建日志目录
let log_file_path = logs_dir.to_string() + log_file;
/* //env_logger
/// 定义一个函数用于将DateTime对象转换为指定格式的字符串
fn format_timestamp(dt: Timestamp) -> String {
let dt: DateTime<Utc> = DateTime::from_str(&*dt.to_string()).unwrap();
Expand Down

0 comments on commit 8e16d2a

Please sign in to comment.