mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-03 01:25:37 +00:00
system: add get; rename
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use crate::utils::BoxExt;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod linux;
|
||||
|
||||
@@ -5,16 +7,36 @@ pub mod linux;
|
||||
pub mod windows;
|
||||
|
||||
#[cfg(all(target_os = "macos", not(feature = "macos-ne")))]
|
||||
pub mod darwin;
|
||||
pub mod macos;
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
pub struct OSConfig {
|
||||
pub struct SystemConfig {
|
||||
pub nameservers: Vec<String>,
|
||||
pub search_domains: Vec<String>,
|
||||
pub match_domains: Vec<String>,
|
||||
}
|
||||
|
||||
pub trait SystemConfigurator: Send + Sync + Clone {
|
||||
fn set_dns(&self, cfg: &OSConfig) -> std::io::Result<()>;
|
||||
pub trait SystemConfigurator: Send + Sync {
|
||||
fn set_dns(&self, cfg: &SystemConfig) -> std::io::Result<()>;
|
||||
fn clean(&self) -> std::io::Result<()>;
|
||||
}
|
||||
|
||||
// TODO: move this to nic mod
|
||||
fn get(
|
||||
#[allow(unused_variables)] interface: &str,
|
||||
) -> Result<Option<Box<dyn SystemConfigurator>>, anyhow::Error> {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
use crate::dns::system::windows::WindowsDNSManager;
|
||||
return Ok(Some(WindowsDNSManager::new(interface)?.boxed()));
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "macos", not(feature = "macos-ne")))]
|
||||
{
|
||||
use crate::dns::system_config::darwin::DarwinConfigurator;
|
||||
return Ok(Some(DarwinConfigurator::new().boxed()));
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user