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:
Mg Pig
2025-10-02 20:30:39 +08:00
committed by GitHub
parent d2efbbef04
commit 841d525913
65 changed files with 1953 additions and 1153 deletions

View File

@@ -132,7 +132,7 @@ pub fn enable_log() {
.init();
}
fn check_route(ipv4: &str, dst_peer_id: PeerId, routes: Vec<crate::proto::cli::Route>) {
fn check_route(ipv4: &str, dst_peer_id: PeerId, routes: Vec<crate::proto::api::instance::Route>) {
let mut found = false;
for r in routes.iter() {
if r.ipv4_addr == Some(ipv4.parse().unwrap()) {
@@ -148,9 +148,9 @@ fn check_route(ipv4: &str, dst_peer_id: PeerId, routes: Vec<crate::proto::cli::R
}
fn check_route_ex(
routes: Vec<crate::proto::cli::Route>,
routes: Vec<crate::proto::api::instance::Route>,
peer_id: PeerId,
checker: impl Fn(&crate::proto::cli::Route) -> bool,
checker: impl Fn(&crate::proto::api::instance::Route) -> bool,
) {
let mut found = false;
for r in routes.iter() {

View File

@@ -18,7 +18,7 @@ use crate::{
stats_manager::{LabelType, MetricName},
},
instance::instance::Instance,
proto::{cli::TcpProxyEntryTransportType, common::CompressionAlgoPb},
proto::{api::instance::TcpProxyEntryTransportType, common::CompressionAlgoPb},
tunnel::{
common::tests::{_tunnel_bench_netns, wait_for_condition},
ring::RingTunnelConnector,
@@ -2100,8 +2100,10 @@ pub async fn acl_group_based_test(
#[serial_test::serial]
pub async fn config_patch_test() {
use crate::proto::{
api::config::{
ConfigPatchAction, InstanceConfigPatch, PortForwardPatch, ProxyNetworkPatch,
},
common::{PortForwardConfigPb, SocketType},
config::{ConfigPatchAction, InstanceConfigPatch, PortForwardPatch, ProxyNetworkPatch},
};
use crate::tunnel::common::tests::_tunnel_pingpong_netns_with_timeout;