feat: complete nx9-wg v0.8.0 platform

This commit is contained in:
thakares committed 2026-08-17 14:25:45 +05:30
1 parent c75e5c4e71
commit c8a9b7cde6
52 files changed
+7751 -725

No files matched your search

+17 -12
View File
@@ -143,12 +143,25 @@ impl WireGuardEngine for SimulatedWireGuardEngine {
}
}
/// Linux Native WireGuard Engine using kernel netlink / interfaces.
// ── Native Linux WireGuard Engine ─────────────────────────────────────────────
//
// On Linux: the real implementation lives in native_linux.rs and uses
// RTNETLINK + WireGuard Generic Netlink to communicate with the kernel.
//
// On non-Linux platforms: a thin simulation wrapper is provided so that
// the workspace remains portable and tests remain functional.
#[cfg(target_os = "linux")]
pub use crate::native_linux::NativeLinuxWireGuardEngine;
/// Non-Linux fallback: NativeLinuxWireGuardEngine delegates to simulation.
#[cfg(not(target_os = "linux"))]
#[derive(Debug, Clone, Default)]
pub struct NativeLinuxWireGuardEngine {
simulated_fallback: SimulatedWireGuardEngine,
}
#[cfg(not(target_os = "linux"))]
impl NativeLinuxWireGuardEngine {
pub fn new() -> Self {
Self {
@@ -156,24 +169,16 @@ impl NativeLinuxWireGuardEngine {
}
}
/// Check if Linux kernel WireGuard module / interface support is available.
/// Check if Linux kernel WireGuard support is available.
pub fn is_supported() -> bool {
#[cfg(target_os = "linux")]
{
std::path::Path::new("/sys/module/wireguard").exists()
|| std::path::Path::new("/proc/net/dev").exists()
}
#[cfg(not(target_os = "linux"))]
{
false
}
false
}
}
#[cfg(not(target_os = "linux"))]
#[async_trait::async_trait]
impl WireGuardEngine for NativeLinuxWireGuardEngine {
async fn sync_interface(&self, interface: &Interface, peers: &[Peer]) -> Result<()> {
// Fallback to simulated engine for test sandboxes and non-root execution
self.simulated_fallback
.sync_interface(interface, peers)
.await