mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-11 10:58:21 +00:00
Add wireguard status
This commit is contained in:
parent
d79269676a
commit
913f130fd6
2 changed files with 8 additions and 1 deletions
|
@ -29,6 +29,9 @@ pub enum ApiError {
|
||||||
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
ConfigError(#[from] crate::config_manager::ConfigError),
|
ConfigError(#[from] crate::config_manager::ConfigError),
|
||||||
|
|
||||||
|
#[error(transparent)]
|
||||||
|
IOError(#[from] std::io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<ErrorObject<'static>> for ApiError {
|
impl Into<ErrorObject<'static>> for ApiError {
|
||||||
|
|
|
@ -6,6 +6,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use jsonrpsee::types::Params;
|
use jsonrpsee::types::Params;
|
||||||
use jsonrpsee::RpcModule;
|
use jsonrpsee::RpcModule;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
pub fn register_methods(module: &mut RpcModule<RpcState>) {
|
pub fn register_methods(module: &mut RpcModule<RpcState>) {
|
||||||
module
|
module
|
||||||
|
@ -84,5 +85,8 @@ pub fn register_methods(module: &mut RpcModule<RpcState>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wireguard_status(_: Params, _: &RpcState) -> Result<String, ApiError> {
|
pub fn wireguard_status(_: Params, _: &RpcState) -> Result<String, ApiError> {
|
||||||
Ok("ok".to_string())
|
match Command::new("wg").output() {
|
||||||
|
Ok(out) => Ok(String::from_utf8_lossy(&out.stdout).to_string()),
|
||||||
|
Err(err) => Err(ApiError::IOError(err)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue