mirror of
https://github.com/EasyTier/EasyTier.git
synced 2025-12-24 13:29:38 +08:00
Some checks failed
EasyTier Core / pre_job (push) Has been cancelled
EasyTier GUI / pre_job (push) Has been cancelled
EasyTier Mobile / pre_job (push) Has been cancelled
EasyTier OHOS / cargo_fmt_check (push) Has been cancelled
EasyTier OHOS / pre_job (push) Has been cancelled
EasyTier Test / pre_job (push) Has been cancelled
EasyTier Core / build_web (push) Has been cancelled
EasyTier Core / build (freebsd-13.2-x86_64, 13.2, ubuntu-22.04, x86_64-unknown-freebsd) (push) Has been cancelled
EasyTier Core / build (linux-aarch64, ubuntu-22.04, aarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-arm, ubuntu-22.04, arm-unknown-linux-musleabi) (push) Has been cancelled
EasyTier Core / build (linux-armhf, ubuntu-22.04, arm-unknown-linux-musleabihf) (push) Has been cancelled
EasyTier Core / build (linux-armv7, ubuntu-22.04, armv7-unknown-linux-musleabi) (push) Has been cancelled
EasyTier Core / build (linux-armv7hf, ubuntu-22.04, armv7-unknown-linux-musleabihf) (push) Has been cancelled
EasyTier Core / build (linux-loongarch64, ubuntu-24.04, loongarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-mips, ubuntu-22.04, mips-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-mipsel, ubuntu-22.04, mipsel-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-riscv64, ubuntu-22.04, riscv64gc-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-x86_64, ubuntu-22.04, x86_64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (macos-aarch64, macos-latest, aarch64-apple-darwin) (push) Has been cancelled
EasyTier Core / build (macos-x86_64, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
EasyTier Core / build (windows-arm64, windows-latest, aarch64-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / build (windows-i686, windows-latest, i686-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / build (windows-x86_64, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / core-result (push) Has been cancelled
EasyTier Core / magisk_build (push) Has been cancelled
EasyTier GUI / build-gui (linux-aarch64, aarch64-unknown-linux-gnu, ubuntu-22.04, aarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier GUI / build-gui (linux-x86_64, x86_64-unknown-linux-gnu, ubuntu-22.04, x86_64-unknown-linux-musl) (push) Has been cancelled
EasyTier GUI / build-gui (macos-aarch64, aarch64-apple-darwin, macos-latest, aarch64-apple-darwin) (push) Has been cancelled
EasyTier GUI / build-gui (macos-x86_64, x86_64-apple-darwin, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
EasyTier GUI / build-gui (windows-arm64, aarch64-pc-windows-msvc, windows-latest, aarch64-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / build-gui (windows-i686, i686-pc-windows-msvc, windows-latest, i686-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / build-gui (windows-x86_64, x86_64-pc-windows-msvc, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / gui-result (push) Has been cancelled
EasyTier Mobile / build-mobile (android, ubuntu-22.04, android) (push) Has been cancelled
EasyTier Mobile / mobile-result (push) Has been cancelled
EasyTier OHOS / build-ohos (push) Has been cancelled
EasyTier Test / test (push) Has been cancelled
* refactor(gui): refactor gui to use RemoteClient trait and RemoteManagement component * feat(gui): Add network config saving and refactor RemoteManagement
87 lines
2.6 KiB
Rust
87 lines
2.6 KiB
Rust
use std::net::SocketAddr;
|
|
|
|
use crate::{
|
|
common::global_ctx::ArcGlobalCtx,
|
|
proto::{
|
|
common::Void,
|
|
peer_rpc::{
|
|
DirectConnectorRpc, GetIpListRequest, GetIpListResponse, SendV6HolePunchPacketRequest,
|
|
},
|
|
rpc_types::{self, controller::BaseController},
|
|
},
|
|
tunnel::udp,
|
|
};
|
|
|
|
#[derive(Clone)]
|
|
pub struct DirectConnectorManagerRpcServer {
|
|
// TODO: this only cache for one src peer, should make it global
|
|
global_ctx: ArcGlobalCtx,
|
|
}
|
|
|
|
#[async_trait::async_trait]
|
|
impl DirectConnectorRpc for DirectConnectorManagerRpcServer {
|
|
type Controller = BaseController;
|
|
|
|
async fn get_ip_list(
|
|
&self,
|
|
_: BaseController,
|
|
_: GetIpListRequest,
|
|
) -> rpc_types::error::Result<GetIpListResponse> {
|
|
let mut ret = self.global_ctx.get_ip_collector().collect_ip_addrs().await;
|
|
ret.listeners = self
|
|
.global_ctx
|
|
.config
|
|
.get_mapped_listeners()
|
|
.into_iter()
|
|
.chain(self.global_ctx.get_running_listeners())
|
|
.map(Into::into)
|
|
.collect();
|
|
// remove et ipv6 from the interface ipv6 list
|
|
if let Some(et_ipv6) = self.global_ctx.get_ipv6() {
|
|
let et_ipv6: crate::proto::common::Ipv6Addr = et_ipv6.address().into();
|
|
ret.interface_ipv6s.retain(|x| *x != et_ipv6);
|
|
}
|
|
tracing::trace!(
|
|
"get_ip_list: public_ipv4: {:?}, public_ipv6: {:?}, listeners: {:?}",
|
|
ret.public_ipv4,
|
|
ret.public_ipv6,
|
|
ret.listeners
|
|
);
|
|
Ok(ret)
|
|
}
|
|
|
|
async fn send_v6_hole_punch_packet(
|
|
&self,
|
|
_: BaseController,
|
|
req: SendV6HolePunchPacketRequest,
|
|
) -> rpc_types::error::Result<Void> {
|
|
let listener_port = req.listener_port as u16;
|
|
let SocketAddr::V6(connector_addr) = req
|
|
.connector_addr
|
|
.ok_or(anyhow::anyhow!("connector_addr is required"))?
|
|
.into()
|
|
else {
|
|
return Err(anyhow::anyhow!("connector_addr is not a v6 address").into());
|
|
};
|
|
|
|
tracing::info!(
|
|
"Sending v6 hole punch packet to {} from listener port {}",
|
|
connector_addr,
|
|
listener_port
|
|
);
|
|
|
|
// send 3 packets to the connector
|
|
for _ in 0..3 {
|
|
udp::send_v6_hole_punch_packet(listener_port, connector_addr).await?;
|
|
tokio::time::sleep(std::time::Duration::from_millis(30)).await;
|
|
}
|
|
Ok(Default::default())
|
|
}
|
|
}
|
|
|
|
impl DirectConnectorManagerRpcServer {
|
|
pub fn new(global_ctx: ArcGlobalCtx) -> Self {
|
|
Self { global_ctx }
|
|
}
|
|
}
|