mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 02:09:06 +00:00
support quic proxy (#993)
QUIC proxy works like kcp proxy, it can proxy TCP streams and transfer data with QUIC. QUIC has better congestion algorithm (BBR) for network with both high loss rate and high bandwidth. QUIC proxy can be enabled by passing `--enable-quic-proxy` to easytier in the client side. The proxy status can be viewed by `easytier-cli proxy`.
This commit is contained in:
@@ -20,6 +20,7 @@ use crate::connector::manual::{ConnectorManagerRpcService, ManualConnectorManage
|
||||
use crate::connector::udp_hole_punch::UdpHolePunchConnector;
|
||||
use crate::gateway::icmp_proxy::IcmpProxy;
|
||||
use crate::gateway::kcp_proxy::{KcpProxyDst, KcpProxyDstRpcService, KcpProxySrc};
|
||||
use crate::gateway::quic_proxy::{QUICProxyDst, QUICProxyDstRpcService, QUICProxySrc};
|
||||
use crate::gateway::tcp_proxy::{NatDstTcpConnector, TcpProxy, TcpProxyRpcService};
|
||||
use crate::gateway::udp_proxy::UdpProxy;
|
||||
use crate::peer_center::instance::PeerCenterInstance;
|
||||
@@ -232,6 +233,9 @@ pub struct Instance {
|
||||
kcp_proxy_src: Option<KcpProxySrc>,
|
||||
kcp_proxy_dst: Option<KcpProxyDst>,
|
||||
|
||||
quic_proxy_src: Option<QUICProxySrc>,
|
||||
quic_proxy_dst: Option<QUICProxyDst>,
|
||||
|
||||
peer_center: Arc<PeerCenterInstance>,
|
||||
|
||||
vpn_portal: Arc<Mutex<Box<dyn VpnPortal>>>,
|
||||
@@ -312,6 +316,9 @@ impl Instance {
|
||||
kcp_proxy_src: None,
|
||||
kcp_proxy_dst: None,
|
||||
|
||||
quic_proxy_src: None,
|
||||
quic_proxy_dst: None,
|
||||
|
||||
peer_center,
|
||||
|
||||
vpn_portal: Arc::new(Mutex::new(Box::new(vpn_portal_inst))),
|
||||
@@ -562,6 +569,20 @@ impl Instance {
|
||||
self.kcp_proxy_dst = Some(dst_proxy);
|
||||
}
|
||||
|
||||
if self.global_ctx.get_flags().enable_quic_proxy {
|
||||
let quic_src = QUICProxySrc::new(self.get_peer_manager()).await;
|
||||
quic_src.start().await;
|
||||
self.quic_proxy_src = Some(quic_src);
|
||||
}
|
||||
|
||||
if !self.global_ctx.get_flags().disable_quic_input {
|
||||
let quic_dst = QUICProxyDst::new(self.global_ctx.clone())?;
|
||||
quic_dst.start().await?;
|
||||
self.global_ctx
|
||||
.set_quic_proxy_port(Some(quic_dst.local_addr()?.port()));
|
||||
self.quic_proxy_dst = Some(quic_dst);
|
||||
}
|
||||
|
||||
// run after tun device created, so listener can bind to tun device, which may be required by win 10
|
||||
self.ip_proxy = Some(IpProxy::new(
|
||||
self.get_global_ctx(),
|
||||
@@ -737,6 +758,20 @@ impl Instance {
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(quic_proxy) = self.quic_proxy_src.as_ref() {
|
||||
s.registry().register(
|
||||
TcpProxyRpcServer::new(TcpProxyRpcService::new(quic_proxy.get_tcp_proxy())),
|
||||
"quic_src",
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(quic_proxy) = self.quic_proxy_dst.as_ref() {
|
||||
s.registry().register(
|
||||
TcpProxyRpcServer::new(QUICProxyDstRpcService::new(quic_proxy)),
|
||||
"quic_dst",
|
||||
);
|
||||
}
|
||||
|
||||
s.set_hook(Arc::new(InstanceRpcServerHook::new(
|
||||
self.global_ctx.config.get_rpc_portal_whitelist(),
|
||||
)));
|
||||
|
||||
Reference in New Issue
Block a user