Enable privileged only on linux

This commit is contained in:
Prabhpreet Dua
2024-06-13 17:34:48 +05:30
parent a75d7a53e0
commit 96bed38ad0
2 changed files with 54 additions and 48 deletions

View File

@@ -1,4 +1,10 @@
#![cfg(target_os = "linux")]
fn main() {
#[cfg(target_os = "linux")]
linux::main().unwrap();
}
#[cfg(target_os = "linux")]
pub mod linux {
use std::io::{stdin, stdout, Read, Write};
use std::result::Result;
@@ -18,7 +24,7 @@ pub enum BrokerAppError {
OversizedMessage(u64),
}
fn main() -> Result<(), BrokerAppError> {
pub fn main() -> Result<(), BrokerAppError> {
let mut broker = BrokerServer::new(wg::NetlinkWireGuardBroker::new()?);
let mut stdin = stdin().lock();
@@ -55,3 +61,4 @@ fn main() -> Result<(), BrokerAppError> {
stdout.flush()?;
}
}
}

View File

@@ -1,4 +1,3 @@
#![cfg(target_os = "linux")]
use std::process::Stdio;
use tokio::io::{AsyncReadExt, AsyncWriteExt};