fix: improve external-controller parse and log

This commit is contained in:
GyDi 2022-06-20 01:36:56 +08:00
parent 2f1ea08b8a
commit 6d0625c409
No known key found for this signature in database
GPG Key ID: 1C95E0D3467B3084
2 changed files with 14 additions and 9 deletions

View File

@ -49,15 +49,16 @@ impl ClashInfo {
// `external-controller` could be
// "127.0.0.1:9090" or ":9090"
// "9090" or 9090 (clash do not support this)
let server = match config.get(&key_server) {
Some(value) => match value {
Value::String(val_str) => match val_str.starts_with(":") {
true => Some(format!("127.0.0.1{val_str}")),
false => Some(val_str.clone()),
},
_ => None,
},
Some(value) => {
let val_str = value.as_str().unwrap_or("");
if val_str.starts_with(":") {
Some(format!("127.0.0.1{val_str}"))
} else {
Some(val_str.into())
}
}
_ => None,
};

View File

@ -139,7 +139,11 @@ impl Service {
config::save_yaml(temp_path.clone(), &config, Some("# Clash Verge Temp File"))?;
if info.server.is_none() {
bail!("failed to parse the server");
if info.port.is_none() {
bail!("failed to parse config.yaml file");
} else {
bail!("failed to parse the server");
}
}
let server = info.server.unwrap();