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:
Luna Yao
2026-02-02 04:53:40 +01:00
committed by GitHub
parent 21f4a944a7
commit cd2cf56358
21 changed files with 1419 additions and 530 deletions
+5 -8
View File
@@ -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");
}