From 9f84fc6efa000350648ae5c1a3d9fe824ced2a8d Mon Sep 17 00:00:00 2001 From: Jett Chen Date: Sun, 17 Dec 2023 03:22:18 +0800 Subject: [PATCH] update for windows --- burrow/src/daemon/net/windows.rs | 2 ++ burrow/src/daemon/response.rs | 1 + burrow/src/lib.rs | 3 +++ burrow/src/main.rs | 11 ++++++++++- tun/src/options.rs | 4 ++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/burrow/src/daemon/net/windows.rs b/burrow/src/daemon/net/windows.rs index c734689..6dfd155 100644 --- a/burrow/src/daemon/net/windows.rs +++ b/burrow/src/daemon/net/windows.rs @@ -1,4 +1,6 @@ use super::*; +use anyhow::Result; +use crate::daemon::DaemonResponse; pub async fn listen( _cmd_tx: async_channel::Sender, diff --git a/burrow/src/daemon/response.rs b/burrow/src/daemon/response.rs index 4bebe14..aa5507a 100644 --- a/burrow/src/daemon/response.rs +++ b/burrow/src/daemon/response.rs @@ -1,6 +1,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use tun::TunInterface; +use anyhow::anyhow; #[derive(Clone, Serialize, Deserialize, Debug, JsonSchema)] pub struct DaemonResponse { diff --git a/burrow/src/lib.rs b/burrow/src/lib.rs index 8bccc30..2fee67f 100644 --- a/burrow/src/lib.rs +++ b/burrow/src/lib.rs @@ -1,6 +1,9 @@ +#[cfg(any(target_os = "linux", target_vendor = "apple"))] pub mod wireguard; +#[cfg(any(target_os = "linux", target_vendor = "apple"))] mod daemon; +#[cfg(any(target_os = "linux", target_vendor = "apple"))] pub use daemon::{ DaemonClient, DaemonCommand, DaemonResponse, DaemonResponseData, DaemonStartOptions, ServerInfo, }; diff --git a/burrow/src/main.rs b/burrow/src/main.rs index 645ed5b..2cc3753 100644 --- a/burrow/src/main.rs +++ b/burrow/src/main.rs @@ -1,5 +1,4 @@ use anyhow::{Context, Result}; -#[cfg(any(target_os = "linux", target_vendor = "apple"))] use clap::{Args, Parser, Subcommand}; use tracing::instrument; use tracing_log::LogTracer; @@ -8,12 +7,16 @@ use tracing_subscriber::{prelude::*, EnvFilter, FmtSubscriber}; #[cfg(any(target_os = "linux", target_vendor = "apple"))] use tun::TunInterface; +#[cfg(any(target_os = "linux", target_vendor = "apple"))] mod daemon; +#[cfg(any(target_os = "linux", target_vendor = "apple"))] mod wireguard; +#[cfg(any(target_os = "linux", target_vendor = "apple"))] use daemon::{DaemonClient, DaemonCommand, DaemonStartOptions}; use tun::TunOptions; +#[cfg(any(target_os = "linux", target_vendor = "apple"))] use crate::daemon::DaemonResponseData; #[derive(Parser)] @@ -184,6 +187,7 @@ async fn try_serverinfo() -> Result<()> { async fn try_serverconfig() -> Result<()> { Ok(()) } +#[cfg(any(target_os = "linux", target_vendor = "apple"))] #[tokio::main(flavor = "current_thread")] async fn main() -> Result<()> { initialize_tracing().await?; @@ -226,3 +230,8 @@ fn system_log() -> Result> { fn system_log() -> Result> { Ok(Some(OsLogger::new("com.hackclub.burrow", "burrow-cli"))) } + +#[cfg(not(any(target_os = "linux", target_vendor = "apple")))] +pub fn main(){ + eprintln!("This platform is not supported currently.") +} \ No newline at end of file diff --git a/tun/src/options.rs b/tun/src/options.rs index f5f6778..339f71a 100644 --- a/tun/src/options.rs +++ b/tun/src/options.rs @@ -2,6 +2,8 @@ use std::io::Error; use fehler::throws; +#[cfg(any(target_os = "linux", target_vendor = "apple"))] +#[cfg(feature = "tokio")] use super::tokio::TunInterface; #[derive(Debug, Clone, Default)] @@ -47,6 +49,8 @@ impl TunOptions { self } + #[cfg(any(target_os = "linux", target_vendor = "apple"))] + #[cfg(feature = "tokio")] #[throws] pub fn open(self) -> TunInterface { let ti = super::TunInterface::new_with_options(self)?;