mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 18:38:22 +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)]
|
||||
ConfigError(#[from] crate::config_manager::ConfigError),
|
||||
|
||||
#[error(transparent)]
|
||||
IOError(#[from] std::io::Error),
|
||||
}
|
||||
|
||||
impl Into<ErrorObject<'static>> for ApiError {
|
||||
|
|
|
@ -6,6 +6,7 @@ use crate::{
|
|||
};
|
||||
use jsonrpsee::types::Params;
|
||||
use jsonrpsee::RpcModule;
|
||||
use std::process::Command;
|
||||
|
||||
pub fn register_methods(module: &mut RpcModule<RpcState>) {
|
||||
module
|
||||
|
@ -84,5 +85,8 @@ pub fn register_methods(module: &mut RpcModule<RpcState>) {
|
|||
}
|
||||
|
||||
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