-
Notifications
You must be signed in to change notification settings - Fork 598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Breaking Issue] Dictionary in config.yaml file doesn't follow order after preprocessing #1862
Comments
The problem has been pinpointed in backend\tauri\src\enhance\mod.rs //检查点1:字典顺序正常
// 内建脚本最后跑
if enable_builtin {
let mut script_runner = RunnerManager::new();
for item in ChainItem::builtin()
.into_iter()
.filter(|(s, _)| s.contains(*clash_core.as_ref().unwrap_or(&ClashCore::default())))
.map(|(_, c)| c)
{
log::debug!(target: "app", "run builtin script {}", item.uid);
if let ChainTypeWrapper::Script(script) = item.data {
let (res, _) = script_runner
.process_script(&script, config.to_owned())
.await;
match res {
Ok(res_config) => {
config = res_config;
}
Err(err) => {
log::error!(target: "app", "builtin script error `{err:?}`");
}
}
}
}
}
//检查点2:字典顺序混乱 The execution of this part will cause the dictionary of config to be disordered |
Maybe the cause is the deserialization of table from lua. What's more, why mihomo use the order of a map, which is mostly implemented as a hashmap? |
It may be that dictionaries are written with fewer parentheses than arrays, or perform better |
I glanced at the document. The mlua don't provide a helper to resolve this issue. So in current situation, we should implement a diff algorithm to resort the map key order according to original one recursively. |
If using lua preprocessing on the mihomo core, the sorting problem needs to be solved from algorithm. |
…to mihomo limitation (#1866) [1]#1862 Fix DNS policy order for mihomo 1. Just don't touch lua for mihomo core. JS processing can maintain dictionary order. This way, at least for now, it works fine when users are not using their own lua for processing. 2. Preserve todo for lua defects [2]#1819 Support group hidden display for mihomo 1. `hidden` wasn't working. 2. The `hidden` decision should be present at all times, so fixed the logic hole [3]#1864 Fix one-click installation service on windows 1. `wmic` utility may be deprecated or not installed in newer versions of Windows Solved some very critical usage issues, it's time to update a release. Please point out if anything is inappropriate COMMIT HISTORY: * Ditch lua's default processing, switch to js * prettier * Fix hidden logic when deferredProxiesFilter doesn't exist * Fix issue with getting current user SID on Windows * Keep todo markfor the root cause of the problem * Add fallback for new version of windows * Keep the sid method and fix it in the upstream * chore: correct fronend code styles --------- Co-authored-by: Jonson Petard <[email protected]>
复现步骤 / Step to reproduce
A config.yaml file with nameserver-policy attribute.
预期行为 / Expected behavior
Keeping the text of the dictionary in order
实际行为 / Actual behavior
Dictionaries are treated as logical structures, unordered. This leads to chaotic rules for DNS. For example, dns loopbacks, or huge delays due to wrong parsing order
应用日志 / App logs
No response
备注 / Addition details
Dictionaries are unordered logical structures in the yaml syntax. But the actual configuration effect does not treat it as unordered. MetaCubeX/mihomo#1598 The order of the dictionaries in the mihomo configuration file for yaml is important
环境信息 / Environment information
Nyanpasu 1.6.1
自查步骤 / Verify steps
The text was updated successfully, but these errors were encountered: