update for windows

This commit is contained in:
Jett Chen 2023-12-17 03:22:18 +08:00
parent b60c6ad687
commit 9f84fc6efa
5 changed files with 20 additions and 1 deletions

View file

@ -1,4 +1,6 @@
use super::*; use super::*;
use anyhow::Result;
use crate::daemon::DaemonResponse;
pub async fn listen( pub async fn listen(
_cmd_tx: async_channel::Sender<DaemonCommand>, _cmd_tx: async_channel::Sender<DaemonCommand>,

View file

@ -1,6 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tun::TunInterface; use tun::TunInterface;
use anyhow::anyhow;
#[derive(Clone, Serialize, Deserialize, Debug, JsonSchema)] #[derive(Clone, Serialize, Deserialize, Debug, JsonSchema)]
pub struct DaemonResponse { pub struct DaemonResponse {

View file

@ -1,6 +1,9 @@
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
pub mod wireguard; pub mod wireguard;
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
mod daemon; mod daemon;
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
pub use daemon::{ pub use daemon::{
DaemonClient, DaemonCommand, DaemonResponse, DaemonResponseData, DaemonStartOptions, ServerInfo, DaemonClient, DaemonCommand, DaemonResponse, DaemonResponseData, DaemonStartOptions, ServerInfo,
}; };

View file

@ -1,5 +1,4 @@
use anyhow::{Context, Result}; use anyhow::{Context, Result};
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
use clap::{Args, Parser, Subcommand}; use clap::{Args, Parser, Subcommand};
use tracing::instrument; use tracing::instrument;
use tracing_log::LogTracer; use tracing_log::LogTracer;
@ -8,12 +7,16 @@ use tracing_subscriber::{prelude::*, EnvFilter, FmtSubscriber};
#[cfg(any(target_os = "linux", target_vendor = "apple"))] #[cfg(any(target_os = "linux", target_vendor = "apple"))]
use tun::TunInterface; use tun::TunInterface;
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
mod daemon; mod daemon;
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
mod wireguard; mod wireguard;
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
use daemon::{DaemonClient, DaemonCommand, DaemonStartOptions}; use daemon::{DaemonClient, DaemonCommand, DaemonStartOptions};
use tun::TunOptions; use tun::TunOptions;
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
use crate::daemon::DaemonResponseData; use crate::daemon::DaemonResponseData;
#[derive(Parser)] #[derive(Parser)]
@ -184,6 +187,7 @@ async fn try_serverinfo() -> Result<()> {
async fn try_serverconfig() -> Result<()> { async fn try_serverconfig() -> Result<()> {
Ok(()) Ok(())
} }
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
#[tokio::main(flavor = "current_thread")] #[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> { async fn main() -> Result<()> {
initialize_tracing().await?; initialize_tracing().await?;
@ -226,3 +230,8 @@ fn system_log() -> Result<Option<tracing_journald::Layer>> {
fn system_log() -> Result<Option<OsLogger>> { fn system_log() -> Result<Option<OsLogger>> {
Ok(Some(OsLogger::new("com.hackclub.burrow", "burrow-cli"))) 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.")
}

View file

@ -2,6 +2,8 @@ use std::io::Error;
use fehler::throws; use fehler::throws;
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
#[cfg(feature = "tokio")]
use super::tokio::TunInterface; use super::tokio::TunInterface;
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]
@ -47,6 +49,8 @@ impl TunOptions {
self self
} }
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
#[cfg(feature = "tokio")]
#[throws] #[throws]
pub fn open(self) -> TunInterface { pub fn open(self) -> TunInterface {
let ti = super::TunInterface::new_with_options(self)?; let ti = super::TunInterface::new_with_options(self)?;