mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 10:14:35 +00:00
refactor(rpc): Centralize RPC service and unify API (#1427)
This change introduces a major refactoring of the RPC service layer to improve modularity, unify the API, and simplify the overall architecture. Key changes: - Replaced per-network-instance RPC services with a single global RPC server, reducing resource usage and simplifying management. - All clients (CLI, Web UI, etc.) now interact with EasyTier core through a unified RPC entrypoint, enabling consistent authentication and control. - RPC implementation logic has been moved to `easytier/src/rpc_service/` and organized by functionality (e.g., `instance_manage.rs`, `peer_manage.rs`, `config.rs`) for better maintainability. - Standardized Protobuf API definitions under `easytier/src/proto/` with an `api_` prefix (e.g., `cli.proto` → `api_instance.proto`) to provide a consistent interface. - CLI commands now require explicit `--instance-id` or `--instance-name` when multiple network instances are running; the parameter is optional when only one instance exists. BREAKING CHANGE: RPC portal configuration (`rpc_portal` and `rpc_portal_whitelist`) has been removed from per-instance configs and the Web UI. The RPC listen address must now be specified globally via the `--rpc-portal` command-line flag or the `ET_RPC_PORTAL` environment variable, as there is only one RPC service for the entire application.
This commit is contained in:
@@ -193,7 +193,7 @@ impl RoutePeerInfo {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RoutePeerInfo> for crate::proto::cli::Route {
|
||||
impl From<RoutePeerInfo> for crate::proto::api::instance::Route {
|
||||
fn from(val: RoutePeerInfo) -> Self {
|
||||
let network_length = if val.network_length == 0 {
|
||||
24
|
||||
@@ -201,7 +201,7 @@ impl From<RoutePeerInfo> for crate::proto::cli::Route {
|
||||
val.network_length
|
||||
};
|
||||
|
||||
crate::proto::cli::Route {
|
||||
crate::proto::api::instance::Route {
|
||||
peer_id: val.peer_id,
|
||||
ipv4_addr: val.ipv4_addr.map(|ipv4_addr| Ipv4Inet {
|
||||
address: Some(ipv4_addr),
|
||||
@@ -2361,7 +2361,7 @@ impl Route for PeerRoute {
|
||||
.map(|x| x.next_hop_peer_id)
|
||||
}
|
||||
|
||||
async fn list_routes(&self) -> Vec<crate::proto::cli::Route> {
|
||||
async fn list_routes(&self) -> Vec<crate::proto::api::instance::Route> {
|
||||
let route_table = &self.service_impl.route_table;
|
||||
let route_table_with_cost = &self.service_impl.route_table_with_cost;
|
||||
let mut routes = Vec::new();
|
||||
@@ -2373,7 +2373,7 @@ impl Route for PeerRoute {
|
||||
continue;
|
||||
};
|
||||
let next_hop_peer_latency_first = route_table_with_cost.get_next_hop(*item.key());
|
||||
let mut route: crate::proto::cli::Route = item.value().clone().into();
|
||||
let mut route: crate::proto::api::instance::Route = item.value().clone().into();
|
||||
route.next_hop_peer_id = next_hop_peer.next_hop_peer_id;
|
||||
route.cost = next_hop_peer.path_len as i32;
|
||||
route.path_latency = next_hop_peer.path_latency;
|
||||
|
||||
Reference in New Issue
Block a user