在配置 Rule 规则时,Windows系统下有Bug,如下的例子:
EXTERNAL, site:C:\github\xxxxxxx\build\windows\x64\runner\Debug\data\geosite.dat:cn, Direct
修改 ./leaf/src/config/external_rule.rs 里的 load_file_or_default 函数 (直接替换)
pub fn load_file_or_default(filter: &str, default: &str) -> Result<(String, String)> {
let all_parts: Vec<&str> = filter.split(':').collect();
if all_parts.len() == 2 {
let asset_loc = Path::new(&*crate::option::ASSET_LOCATION);
let path = asset_loc.join(default).to_string_lossy().to_string();
return Ok((path, all_parts[1].to_string()));
}
let first_colon = filter.find(':');
let last_colon = filter.rfind(':');
if let (Some(start), Some(end)) = (first_colon, last_colon) {
if start != end {
let path_part = &filter[start + 1..end];
let code_part = &filter[end + 1..];
let path = if Path::new(path_part).is_absolute() {
path_part.to_string()
} else {
let asset_loc = Path::new(&*crate::option::ASSET_LOCATION);
asset_loc.join(path_part).to_string_lossy().to_string()
};
return Ok((path, code_part.to_string()));
}
}
Err(anyhow!("invalid external rule: {}", filter))
}
感谢作者!
在配置 Rule 规则时,Windows系统下有Bug,如下的例子:
修改
./leaf/src/config/external_rule.rs里的load_file_or_default函数 (直接替换)感谢作者!