mirror of
https://github.com/rosenpass/rosenpass.git
synced 2026-03-01 23:13:13 -08:00
Enable privileged only on linux
This commit is contained in:
@@ -1,13 +1,19 @@
|
|||||||
#![cfg(target_os = "linux")]
|
fn main() {
|
||||||
use std::io::{stdin, stdout, Read, Write};
|
#[cfg(target_os = "linux")]
|
||||||
use std::result::Result;
|
linux::main().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
use rosenpass_wireguard_broker::api::msgs;
|
#[cfg(target_os = "linux")]
|
||||||
use rosenpass_wireguard_broker::api::server::BrokerServer;
|
pub mod linux {
|
||||||
use rosenpass_wireguard_broker::brokers::netlink as wg;
|
use std::io::{stdin, stdout, Read, Write};
|
||||||
|
use std::result::Result;
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
use rosenpass_wireguard_broker::api::msgs;
|
||||||
pub enum BrokerAppError {
|
use rosenpass_wireguard_broker::api::server::BrokerServer;
|
||||||
|
use rosenpass_wireguard_broker::brokers::netlink as wg;
|
||||||
|
|
||||||
|
#[derive(thiserror::Error, Debug)]
|
||||||
|
pub enum BrokerAppError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
IoError(#[from] std::io::Error),
|
IoError(#[from] std::io::Error),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
@@ -16,9 +22,9 @@ pub enum BrokerAppError {
|
|||||||
WgSetPskError(#[from] wg::SetPskError),
|
WgSetPskError(#[from] wg::SetPskError),
|
||||||
#[error("Oversized message {}; something about the request is fatally wrong", .0)]
|
#[error("Oversized message {}; something about the request is fatally wrong", .0)]
|
||||||
OversizedMessage(u64),
|
OversizedMessage(u64),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), BrokerAppError> {
|
pub fn main() -> Result<(), BrokerAppError> {
|
||||||
let mut broker = BrokerServer::new(wg::NetlinkWireGuardBroker::new()?);
|
let mut broker = BrokerServer::new(wg::NetlinkWireGuardBroker::new()?);
|
||||||
|
|
||||||
let mut stdin = stdin().lock();
|
let mut stdin = stdin().lock();
|
||||||
@@ -54,4 +60,5 @@ fn main() -> Result<(), BrokerAppError> {
|
|||||||
stdout.write_all(&res)?;
|
stdout.write_all(&res)?;
|
||||||
stdout.flush()?;
|
stdout.flush()?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#![cfg(target_os = "linux")]
|
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
|
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
|
|||||||
Reference in New Issue
Block a user