fix crash without selected strategy

This commit is contained in:
CherretGit
2026-03-14 23:27:17 +07:00
parent eac364a9e1
commit 476b73a422
2 changed files with 10 additions and 8 deletions

View File

@@ -21,10 +21,10 @@ use tokio::io::{copy, AsyncWriteExt};
pub static DEFAULT_STRATEGY_NFQWS: &str = "
--filter-tcp=80 --dpi-desync=fake,split2 --dpi-desync-autottl=2 --dpi-desync-fooling=md5sig,badsum ${hostlists} --new
--filter-tcp=443 ${hostlists} --dpi-desync=fake,split2 --dpi-desync-repeats=6 --dpi-desync-fooling=md5sig,badsum --dpi-desync-fake-tls=${zaprettdir}/bin/tls_clienthello_www_google_com.bin --new
--filter-tcp=443 ${hostlists} --dpi-desync=fake,split2 --dpi-desync-repeats=6 --dpi-desync-fooling=md5sig,badsum --dpi-desync-fake-tls=${zaprettdir}/files/bin/tls_clienthello_www_google_com.bin --new
--filter-tcp=80,443 --dpi-desync=fake,disorder2 --dpi-desync-repeats=6 --dpi-desync-autottl=2 --dpi-desync-fooling=md5sig,badsum ${hostlists} --new
--filter-udp=50000-50100 --dpi-desync=fake --dpi-desync-any-protocol --dpi-desync-fake-quic=0xC30000000108 --new
--filter-udp=443 ${hostlists} --dpi-desync=fake --dpi-desync-repeats=6 --dpi-desync-fake-quic=${zaprettdir}/bin/quic_initial_www_google_com.bin --new
--filter-udp=443 ${hostlists} --dpi-desync=fake --dpi-desync-repeats=6 --dpi-desync-fake-quic=${zaprettdir}/files/bin/quic_initial_www_google_com.bin --new
--filter-udp=443 --dpi-desync=fake --dpi-desync-repeats=6 ${hostlists}
";
// тестовая стратегия, заменить на нормальную потом

View File

@@ -56,17 +56,19 @@ pub async fn start_service() -> anyhow::Result<()> {
}
let config: Config = serde_json::from_str(&config_contents)?;
let strategy = match config.service_type() {
ServiceType::Nfqws => get_manifest(Path::new(config.strategy()))?,
ServiceType::Nfqws2 => get_manifest(Path::new(config.strategy_nfqws2()))?
let strategy_path = match config.service_type() {
ServiceType::Nfqws => config.strategy(),
ServiceType::Nfqws2 => config.strategy_nfqws2(),
};
let default_strategy = match config.service_type() {
ServiceType::Nfqws => DEFAULT_STRATEGY_NFQWS,
ServiceType::Nfqws2 => DEFAULT_STRATEGY_NFQWS2
};
let start = match fs::read_to_string(strategy.file()).await {
Ok(s) => Cow::Owned(s),
Err(_) => Cow::Borrowed(default_strategy)
let start = if strategy_path.is_empty() || !Path::new(strategy_path).exists() {
Cow::Borrowed(default_strategy)
} else {
let manifest = get_manifest(Path::new(strategy_path))?;
Cow::Owned(fs::read_to_string(manifest.file()).await?)
};
let regex_hostlists = Regex::new(r"\$(?:hostlists|\{hostlists})")?;
let regex_hostlist = Regex::new(r"\$\{hostlist:([^}]+)\}")?;