解决掉线问题

This commit is contained in:
lubeilin
2023-02-06 22:12:04 +08:00
parent af58c3990d
commit 5cd9179ce7
7 changed files with 44 additions and 45 deletions
+8 -6
View File
@@ -4,20 +4,21 @@ use std::path::PathBuf;
use clap::Parser;
use console::style;
use switch::handle::{PeerDeviceStatus, RouteType};
use switch::*;
use switch::handle::{PeerDeviceStatus, RouteType};
#[cfg(windows)]
mod command;
#[cfg(windows)]
mod config;
#[cfg(windows)]
mod windows;
#[derive(Parser, Debug)]
#[command(
author = "Lu Beilin",
version,
about = "一个虚拟网络工具,启动后会获取一个ip,相同token下的设备之间可以用ip直接通信"
author = "Lu Beilin",
version,
about = "一个虚拟网络工具,启动后会获取一个ip,相同token下的设备之间可以用ip直接通信"
)]
struct Args {
/// 32位字符
@@ -33,6 +34,7 @@ struct Args {
name: Option<String>,
}
#[cfg(windows)]
fn log_init_service(home: PathBuf) -> io::Result<()> {
if !home.exists() {
std::fs::create_dir(&home)?;
@@ -115,7 +117,7 @@ fn main() {
#[cfg(any(target_os = "linux", target_os = "macos"))]
fn main() {
log_init();
let _ = log_init();
let args = Args::parse();
if sudo::RunningAs::Root != sudo::check() {
println!("{}", style("需要使用root权限执行...").red());
+6 -6
View File
@@ -1,15 +1,15 @@
use std::{io, thread};
use std::ffi::OsString;
use std::path::PathBuf;
use std::time::Duration;
use std::{io, thread};
use clap::Parser;
use console::style;
use windows_service::Error;
use windows_service::service::{
ServiceAccess, ServiceErrorControl, ServiceInfo, ServiceStartType, ServiceState, ServiceType,
};
use windows_service::service_manager::{ServiceManager, ServiceManagerAccess};
use windows_service::Error;
use crate::config;
@@ -18,9 +18,9 @@ mod windows_admin_check;
#[derive(Parser, Debug)]
#[command(
author = "Lu Beilin",
version,
about = "一个虚拟网络工具,启动后会获取一个ip,相同token下的设备之间可以用ip直接通信"
author = "Lu Beilin",
version,
about = "一个虚拟网络工具,启动后会获取一个ip,相同token下的设备之间可以用ip直接通信"
)]
struct Args {
/// 32位字符
@@ -120,7 +120,7 @@ pub fn main0() {
token.clone(),
args.name.clone(),
))
.unwrap();
.unwrap();
match start() {
Ok(_) => {
//需要检查启动状态
-1
View File
@@ -6,7 +6,6 @@ use std::sync::Arc;
use std::thread;
use std::time::Duration;
use windows_service::service::{
ServiceControl, ServiceControlAccept, ServiceExitCode, ServiceState, ServiceStatus,
};