added install_channel

This commit is contained in:
asxalex 2024-07-17 22:40:06 +08:00
parent 733f93fe16
commit 1d6e1c274f
5 changed files with 14 additions and 1 deletions

View File

@ -28,6 +28,7 @@ async fn main() {
token: "".to_owned(),
allow_p2p: true,
}, tx,
&sdlan_rs::get_install_channel(),
).await;
let _ = rx.recv();

View File

@ -14,6 +14,7 @@ use tokio::sync::mpsc::channel;
use tokio_util::sync::CancellationToken;
use tracing::{debug, error};
pub use utils::{CommandLine, CommandLineInput};
pub use network::get_install_channel;
use sdlan_sn_rs::{
peer::SdlanSock,
@ -23,6 +24,7 @@ use sdlan_sn_rs::{
pub async fn run_sdlan(
args: CommandLine,
sender: std::sync::mpsc::Sender<bool>,
install_channel: &str,
// start_stop_sender: Sender<String>,
// start_stop_receiver: Receiver<String>,
) -> Result<()> {
@ -37,8 +39,9 @@ pub async fn run_sdlan(
debug!("edge inited");
let cancel = CancellationToken::new();
let install_chan = install_channel.to_owned();
tokio::spawn(async move {
if let Err(e) = async_main("linux".to_owned(), args, start_stop_chan, cancel).await {
if let Err(e) = async_main(install_chan, args, start_stop_chan, cancel).await {
error!("failed to run async main: {}", e.as_str());
}
});

View File

@ -10,6 +10,7 @@ pub use packet::*;
#[cfg_attr(target_os = "linux", path = "tun_linux.rs")]
#[cfg_attr(target_os = "windows", path = "tun_win.rs")]
mod tun;
pub use tun::get_install_channel;
mod device;

View File

@ -124,3 +124,7 @@ impl Iface {
(&self.fd).write(content)
}
}
pub fn get_install_channel() -> String {
"linux".to_owned()
}

View File

@ -93,3 +93,7 @@ pub fn new_iface(name: &str, _mode: Mode) -> Iface {
create_wintun("./wintun.dll", name)
// Ok(Box::new(create_wintun("/path/to/file")))
}
pub fn get_install_channel() -> String {
"windows".to_owned()
}