mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-16 14:47:25 +08:00
Android Support (#166)
1. Add vpnservice tauri plugin for android. 2. add workflow for android. 3. Easytier Core support android, allow set tun fd.
This commit is contained in:
45
tauri-plugin-vpnservice/src/lib.rs
Normal file
45
tauri-plugin-vpnservice/src/lib.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
use tauri::{
|
||||
plugin::{Builder, TauriPlugin},
|
||||
Runtime,
|
||||
};
|
||||
|
||||
#[cfg(mobile)]
|
||||
use tauri::Manager;
|
||||
|
||||
#[cfg(mobile)]
|
||||
mod mobile;
|
||||
|
||||
#[cfg(mobile)]
|
||||
use mobile::Vpnservice;
|
||||
|
||||
mod error;
|
||||
mod models;
|
||||
|
||||
pub use error::{Error, Result};
|
||||
|
||||
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the vpnservice APIs.
|
||||
#[cfg(mobile)]
|
||||
pub trait VpnserviceExt<R: Runtime> {
|
||||
fn vpnservice(&self) -> &Vpnservice<R>;
|
||||
}
|
||||
|
||||
#[cfg(mobile)]
|
||||
impl<R: Runtime, T: Manager<R>> crate::VpnserviceExt<R> for T {
|
||||
fn vpnservice(&self) -> &Vpnservice<R> {
|
||||
self.state::<Vpnservice<R>>().inner()
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("vpnservice")
|
||||
.setup(|_app, _api| {
|
||||
#[cfg(mobile)]
|
||||
{
|
||||
let vpnservice = mobile::init(_app, _api)?;
|
||||
_app.manage(vpnservice);
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.build()
|
||||
}
|
||||
Reference in New Issue
Block a user