Skip to content
Snippets Groups Projects
Unverified Commit ef314c17 authored by GyDi's avatar GyDi Committed by GitHub
Browse files

fix: change mixed port error

parent a3e7626d
No related branches found
No related tags found
No related merge requests found
...@@ -192,31 +192,32 @@ impl Clash { ...@@ -192,31 +192,32 @@ impl Clash {
verge: &mut Verge, verge: &mut Verge,
profiles: &mut Profiles, profiles: &mut Profiles,
) -> Result<()> { ) -> Result<()> {
for (key, value) in patch.iter() { let mix_port_key = Value::from("mixed-port");
let value = value.clone(); let mut port = None;
let key_str = key.as_str().clone().unwrap_or("");
// restart the clash for (key, value) in patch.into_iter() {
if key_str == "mixed-port" { let value = value.clone();
self.restart_sidecar(profiles)?;
let port = if value.is_number() { // check whether the mix_port is changed
match value.as_i64().clone() { if key == mix_port_key {
Some(num) => Some(format!("{num}")), if value.is_number() {
None => None, port = value.as_i64().as_ref().map(|n| n.to_string());
}
} else { } else {
match value.as_str().clone() { port = value.as_str().as_ref().map(|s| s.to_string());
Some(num) => Some(num.into()), }
None => None,
}
};
verge.init_sysproxy(port);
} }
self.config.insert(key.clone(), value); self.config.insert(key.clone(), value);
} }
self.save_config()
self.save_config()?;
if let Some(port) = port {
self.restart_sidecar(profiles)?;
verge.init_sysproxy(Some(port));
}
Ok(())
} }
/// enable tun mode /// enable tun mode
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment