mac wakeup compact code
This commit is contained in:
parent
08278059ac
commit
944ca510cc
@ -93,14 +93,6 @@ pub fn new() -> ServerPtr {
|
||||
Arc::new(RwLock::new(server))
|
||||
}
|
||||
|
||||
fn mac_wakeup(){
|
||||
#[cfg(target_os = "macos")]{
|
||||
use std::process::Command;
|
||||
Command::new("/usr/bin/caffeinate").arg("-u").arg("-t 5").spawn().ok();
|
||||
log::info!("wake up macos");
|
||||
}
|
||||
}
|
||||
|
||||
async fn accept_connection_(server: ServerPtr, socket: Stream, secure: bool) -> ResultType<()> {
|
||||
let local_addr = socket.local_addr();
|
||||
drop(socket);
|
||||
@ -112,7 +104,6 @@ async fn accept_connection_(server: ServerPtr, socket: Stream, secure: bool) ->
|
||||
if let Ok((stream, addr)) = timeout(CONNECT_TIMEOUT, listener.accept()).await? {
|
||||
stream.set_nodelay(true).ok();
|
||||
let stream_addr = stream.local_addr()?;
|
||||
mac_wakeup();
|
||||
create_tcp_connection(server, Stream::from(stream, stream_addr), addr, secure).await?;
|
||||
}
|
||||
Ok(())
|
||||
@ -203,6 +194,11 @@ pub async fn create_tcp_connection(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]{
|
||||
use std::process::Command;
|
||||
Command::new("/usr/bin/caffeinate").arg("-u").arg("-t 5").spawn().ok();
|
||||
log::info!("wake up macos");
|
||||
}
|
||||
Connection::start(addr, stream, id, Arc::downgrade(&server)).await;
|
||||
Ok(())
|
||||
}
|
||||
@ -261,7 +257,6 @@ async fn create_relay_connection_(
|
||||
..Default::default()
|
||||
});
|
||||
stream.send(&msg_out).await?;
|
||||
mac_wakeup();
|
||||
create_tcp_connection(server, stream, peer_addr, secure).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user