Files
Easytier/easytier-core/src/management/mod.rs
T
KKRainbow 3fe427bc99 feat(credentials): manage declarative credentials through TOML (#2515)
* feat(credentials): manage declarative credentials through TOML

Make managed credentials part of the canonical TOML configuration and
load them before peers can authenticate.

Reuse ConfigRpc hot patches to durably replace the configured credential
set without restarting the instance. Serialize credential mutations so
base, managed, and ephemeral keys cannot race into conflicts.

Remove the managed overlay file format, digest protocol, capability
negotiation, force reconciliation, and database CAS machinery. Redact
credential secrets from debug output and management events. Write
credential-bearing files atomically with private permissions.

* fix(core): release JoinSet reapers with their owners

Pass weak task-set references into background reapers so they cannot
retain the JoinSet they are meant to collect. This lets stale smoltcp
bridge tasks terminate when an IPv4 generation is replaced.

Add ownership and TCP generation-replacement regressions covering the
production port-forward failure.
2026-08-22 16:30:51 +08:00

83 lines
3.0 KiB
Rust

//! Process-level management over the canonical Instance collection.
#[cfg(all(feature = "management", any(test, target_os = "wasi")))]
mod forwarded_rpc;
#[cfg(feature = "web-client")]
mod full;
mod instance_rpc;
mod rpc_server_hook;
mod selector;
mod server;
use std::sync::Arc;
use crate::{
instance::{CoreInstance, CoreInstanceHost, manager::InstanceFactory},
rpc::service_registry::ServiceRegistry,
};
#[cfg(all(feature = "management", target_os = "wasi"))]
use easytier_proto::api::config::ConfigRpcServer;
use easytier_proto::api::instance::{ConnectorManageRpcServer, PeerManageRpcServer};
pub use crate::instance::manager::{
ConfigFileControl, ConfigFilePermission, DaemonGuard, InstanceManager, ProcessRuntimeProvider,
};
#[cfg(all(feature = "management", target_os = "wasi"))]
pub(crate) use forwarded_rpc::{
ManagementRpcForwarder, register_forwarded_instance_management_rpc,
};
#[cfg(all(feature = "management", target_os = "wasi"))]
pub(crate) use full::WebClientBackend;
#[cfg(all(feature = "web-client", test))]
pub(crate) use full::register_web_client_rpc;
#[cfg(feature = "management")]
pub use full::remote_client;
#[cfg(feature = "web-client")]
pub use full::{
ConfigFileStorage, ConfigPatchPersistence, ConfigServerEndpoint, InstanceMutationHooks,
InstanceMutationResult, ProcessManagement, ProcessManagementRpc, UnsupportedConfigFileStorage,
WebClient, WebClientConfig, apply_config_patch, config_source_from_rpc, config_source_to_rpc,
network_instance_running_info,
};
#[cfg(feature = "management")]
pub use full::{
LoggerControl, LoggerManagementRpc, UnsupportedLoggerControl, call_instance_json_rpc,
call_management_json_rpc, log_level_name, parse_log_level, register_instance_management_rpc,
register_management_rpc,
};
pub use instance_rpc::InstanceManagementRpc;
pub use rpc_server_hook::ManagementRpcServerHook;
pub use selector::{
ManagementInstance, ManagementSelector, resolve_instance, resolve_management_instance,
resolve_optional_instance_by_name,
};
#[cfg(feature = "management")]
pub use server::ManagementServer;
pub use server::ReadOnlyManagementServer;
/// Registers the read-only status surface used by compact native nodes.
pub fn register_read_only_management_rpc<F, H>(
manager: Arc<InstanceManager<F>>,
registry: &ServiceRegistry,
) where
F: InstanceFactory<Instance = CoreInstance<H>>,
H: CoreInstanceHost,
{
let rpc = InstanceManagementRpc::<F>::new(manager);
registry.register(PeerManageRpcServer::new(rpc.clone()), "");
registry.register(ConnectorManageRpcServer::new(rpc), "");
}
#[cfg(target_os = "wasi")]
pub(crate) fn register_bound_management_rpc<H>(
instance: Arc<CoreInstance<H>>,
registry: &ServiceRegistry,
) where
H: CoreInstanceHost,
{
let rpc = instance_rpc::bound_rpc(instance);
registry.register(PeerManageRpcServer::new(rpc.clone()), "");
registry.register(ConnectorManageRpcServer::new(rpc.clone()), "");
#[cfg(feature = "management")]
registry.register(ConfigRpcServer::new(rpc), "");
}