mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 18:24:36 +00:00
feat(gui): add service and remote mode support (#1578)
This PR fundamentally restructures the EasyTier GUI, introducing support for service mode and remote mode, transforming it from a simple desktop application into a powerful network management terminal. This change allows users to persistently run the EasyTier core as a background service or remotely manage multiple EasyTier instances, greatly improving deployment flexibility and manageability.
This commit is contained in:
@@ -39,6 +39,7 @@ pub struct StandAloneServer<L> {
|
||||
inflight_server: Arc<AtomicU32>,
|
||||
tasks: JoinSet<()>,
|
||||
hook: Option<Arc<dyn RpcServerHook>>,
|
||||
rx_timeout: Option<Duration>,
|
||||
}
|
||||
|
||||
impl<L: TunnelListener + 'static> StandAloneServer<L> {
|
||||
@@ -50,9 +51,14 @@ impl<L: TunnelListener + 'static> StandAloneServer<L> {
|
||||
tasks: JoinSet::new(),
|
||||
|
||||
hook: None,
|
||||
rx_timeout: Some(Duration::from_secs(60)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_rx_timeout(&mut self, timeout: Option<Duration>) {
|
||||
self.rx_timeout = timeout;
|
||||
}
|
||||
|
||||
pub fn set_hook(&mut self, hook: Arc<dyn RpcServerHook>) {
|
||||
self.hook = Some(hook);
|
||||
}
|
||||
@@ -66,6 +72,7 @@ impl<L: TunnelListener + 'static> StandAloneServer<L> {
|
||||
inflight: Arc<AtomicU32>,
|
||||
registry: Arc<ServiceRegistry>,
|
||||
hook: Arc<dyn RpcServerHook>,
|
||||
rx_timeout: Option<Duration>,
|
||||
) -> Result<(), Error> {
|
||||
let tasks = Arc::new(Mutex::new(JoinSet::new()));
|
||||
join_joinset_background(tasks.clone(), "standalone serve_loop".to_string());
|
||||
@@ -87,8 +94,7 @@ impl<L: TunnelListener + 'static> StandAloneServer<L> {
|
||||
|
||||
inflight_server.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
tasks.lock().unwrap().spawn(async move {
|
||||
let server =
|
||||
BidirectRpcManager::new().set_rx_timeout(Some(Duration::from_secs(60)));
|
||||
let server = BidirectRpcManager::new().set_rx_timeout(rx_timeout);
|
||||
server.rpc_server().registry().replace_registry(®istry);
|
||||
server.run_with_tunnel(tunnel);
|
||||
server.wait().await;
|
||||
@@ -101,6 +107,7 @@ impl<L: TunnelListener + 'static> StandAloneServer<L> {
|
||||
pub async fn serve(&mut self) -> Result<(), Error> {
|
||||
let mut listener = self.listener.take().unwrap();
|
||||
let hook = self.hook.take().unwrap_or_else(|| Arc::new(DefaultHook));
|
||||
let rx_timeout = self.rx_timeout;
|
||||
|
||||
listener
|
||||
.listen()
|
||||
@@ -118,6 +125,7 @@ impl<L: TunnelListener + 'static> StandAloneServer<L> {
|
||||
inflight_server.clone(),
|
||||
registry.clone(),
|
||||
hook.clone(),
|
||||
rx_timeout,
|
||||
)
|
||||
.await;
|
||||
if let Err(e) = ret {
|
||||
|
||||
Reference in New Issue
Block a user