mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 02:09:06 +00:00
refactor: handle quic proxy internally instead of use external udp port (#1743)
* deprecate quic_listen_port, add disable_relay_quic and enable_relay_foreign_network_quic * add set_src_modified to TcpProxyForWrappedSrcTrait * prioritize quic over kcp
This commit is contained in:
@@ -24,6 +24,7 @@ use super::env_parser;
|
||||
pub type Flags = crate::proto::common::FlagsInConfig;
|
||||
|
||||
pub fn gen_default_flags() -> Flags {
|
||||
#[allow(deprecated)]
|
||||
Flags {
|
||||
default_protocol: "tcp".to_string(),
|
||||
dev_name: "".to_string(),
|
||||
@@ -52,12 +53,15 @@ pub fn gen_default_flags() -> Flags {
|
||||
private_mode: false,
|
||||
enable_quic_proxy: false,
|
||||
disable_quic_input: false,
|
||||
quic_listen_port: 0,
|
||||
disable_relay_quic: false,
|
||||
enable_relay_foreign_network_quic: false,
|
||||
foreign_relay_bps_limit: u64::MAX,
|
||||
multi_thread_count: 2,
|
||||
encryption_algorithm: "aes-gcm".to_string(),
|
||||
disable_sym_hole_punching: false,
|
||||
tld_dns_zone: DEFAULT_ET_DNS_ZONE.to_string(),
|
||||
|
||||
quic_listen_port: u32::MAX,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1584,7 +1588,6 @@ enable_ipv6 = ${ENABLE_IPV6}
|
||||
async fn test_numeric_type_env_vars() {
|
||||
// 设置数字类型的环境变量
|
||||
std::env::set_var("MTU_VALUE", "1400");
|
||||
std::env::set_var("QUIC_PORT", "8080");
|
||||
std::env::set_var("THREAD_COUNT", "4");
|
||||
|
||||
let mut temp_file = NamedTempFile::new().unwrap();
|
||||
@@ -1597,7 +1600,6 @@ network_secret = "secret"
|
||||
|
||||
[flags]
|
||||
mtu = ${MTU_VALUE}
|
||||
quic_listen_port = ${QUIC_PORT}
|
||||
multi_thread_count = ${THREAD_COUNT}
|
||||
"#;
|
||||
temp_file.write_all(config_content.as_bytes()).unwrap();
|
||||
@@ -1611,10 +1613,6 @@ multi_thread_count = ${THREAD_COUNT}
|
||||
// 验证数字值被正确解析
|
||||
let flags = config.get_flags();
|
||||
assert_eq!(flags.mtu, 1400, "mtu should be 1400");
|
||||
assert_eq!(
|
||||
flags.quic_listen_port, 8080,
|
||||
"quic_listen_port should be 8080"
|
||||
);
|
||||
assert_eq!(
|
||||
flags.multi_thread_count, 4,
|
||||
"multi_thread_count should be 4"
|
||||
@@ -1626,7 +1624,6 @@ multi_thread_count = ${THREAD_COUNT}
|
||||
|
||||
// 清理
|
||||
std::env::remove_var("MTU_VALUE");
|
||||
std::env::remove_var("QUIC_PORT");
|
||||
std::env::remove_var("THREAD_COUNT");
|
||||
}
|
||||
|
||||
|
||||
@@ -92,8 +92,6 @@ pub struct GlobalCtx {
|
||||
|
||||
feature_flags: AtomicCell<PeerFeatureFlag>,
|
||||
|
||||
quic_proxy_port: AtomicCell<Option<u16>>,
|
||||
|
||||
token_bucket_manager: TokenBucketManager,
|
||||
|
||||
stats_manager: Arc<StatsManager>,
|
||||
@@ -149,6 +147,8 @@ impl GlobalCtx {
|
||||
kcp_input: !config_fs.get_flags().disable_kcp_input,
|
||||
no_relay_kcp: config_fs.get_flags().disable_relay_kcp,
|
||||
support_conn_list_sync: true, // Enable selective peer list sync by default
|
||||
quic_input: !config_fs.get_flags().disable_quic_input,
|
||||
no_relay_quic: config_fs.get_flags().disable_relay_quic,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -181,7 +181,6 @@ impl GlobalCtx {
|
||||
p2p_only,
|
||||
|
||||
feature_flags: AtomicCell::new(feature_flags),
|
||||
quic_proxy_port: AtomicCell::new(None),
|
||||
|
||||
token_bucket_manager: TokenBucketManager::new(),
|
||||
|
||||
@@ -393,15 +392,6 @@ impl GlobalCtx {
|
||||
self.feature_flags.store(flags);
|
||||
}
|
||||
|
||||
pub fn get_quic_proxy_port(&self) -> Option<u16> {
|
||||
self.quic_proxy_port.load()
|
||||
}
|
||||
|
||||
pub fn set_quic_proxy_port(&self, port: Option<u16>) {
|
||||
self.acl_filter.set_quic_udp_port(port.unwrap_or(0));
|
||||
self.quic_proxy_port.store(port);
|
||||
}
|
||||
|
||||
pub fn token_bucket_manager(&self) -> &TokenBucketManager {
|
||||
&self.token_bucket_manager
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user