mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-08 07:37:41 +00:00
refine code
This commit is contained in:
parent
c583e884b5
commit
e817257866
1 changed files with 10 additions and 9 deletions
|
@ -63,6 +63,8 @@ fn run_service(_arguments: Vec<std::ffi::OsString>) -> Result<(), crate::BoxErro
|
||||||
// Tell the system that the service is running now
|
// Tell the system that the service is running now
|
||||||
status_handle.set_service_status(next_status.clone())?;
|
status_handle.set_service_status(next_status.clone())?;
|
||||||
|
|
||||||
|
// main logic here
|
||||||
|
{
|
||||||
let args = crate::Args::parse_args();
|
let args = crate::Args::parse_args();
|
||||||
|
|
||||||
let default = format!("{:?},trust_dns_proto=warn", args.verbosity);
|
let default = format!("{:?},trust_dns_proto=warn", args.verbosity);
|
||||||
|
@ -70,7 +72,6 @@ fn run_service(_arguments: Vec<std::ffi::OsString>) -> Result<(), crate::BoxErro
|
||||||
|
|
||||||
let rt = tokio::runtime::Builder::new_multi_thread().enable_all().build()?;
|
let rt = tokio::runtime::Builder::new_multi_thread().enable_all().build()?;
|
||||||
rt.block_on(async {
|
rt.block_on(async {
|
||||||
{
|
|
||||||
unsafe extern "C" fn traffic_cb(status: *const crate::TrafficStatus, _: *mut std::ffi::c_void) {
|
unsafe extern "C" fn traffic_cb(status: *const crate::TrafficStatus, _: *mut std::ffi::c_void) {
|
||||||
let status = &*status;
|
let status = &*status;
|
||||||
log::debug!("Traffic: ▲ {} : ▼ {}", status.tx, status.rx);
|
log::debug!("Traffic: ▲ {} : ▼ {}", status.tx, status.rx);
|
||||||
|
@ -80,9 +81,9 @@ fn run_service(_arguments: Vec<std::ffi::OsString>) -> Result<(), crate::BoxErro
|
||||||
if let Err(err) = crate::desktop_run_async(args, shutdown_token).await {
|
if let Err(err) = crate::desktop_run_async(args, shutdown_token).await {
|
||||||
log::error!("main loop error: {}", err);
|
log::error!("main loop error: {}", err);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ok::<(), crate::Error>(())
|
Ok::<(), crate::Error>(())
|
||||||
})?;
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
// Tell the system that the service is stopped now
|
// Tell the system that the service is stopped now
|
||||||
next_status.current_state = windows_service::service::ServiceState::Stopped;
|
next_status.current_state = windows_service::service::ServiceState::Stopped;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue