chore: adjust
This commit is contained in:
parent
dc492a2a0a
commit
573571978c
@ -47,20 +47,15 @@ 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) {
|
let server = match config.get(&key_server) {
|
||||||
Some(value) => match value {
|
Some(value) => match value {
|
||||||
Value::String(val_str) => {
|
Value::String(val_str) => match val_str.starts_with(":") {
|
||||||
// `external-controller` could be
|
true => Some(format!("127.0.0.1{val_str}")),
|
||||||
// "127.0.0.1:9090" or ":9090"
|
false => Some(val_str.clone()),
|
||||||
// Todo: maybe it could support single port
|
},
|
||||||
let server = val_str.clone();
|
|
||||||
let server = match server.starts_with(":") {
|
|
||||||
true => format!("127.0.0.1{server}"),
|
|
||||||
false => server,
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(server)
|
|
||||||
}
|
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
@ -115,13 +110,6 @@ impl Clash {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// todo: delete
|
|
||||||
/// update the clash info
|
|
||||||
pub fn update_config(&mut self) {
|
|
||||||
self.config = Clash::read_config();
|
|
||||||
self.info = ClashInfo::from(&self.config);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// patch update the clash config
|
/// patch update the clash config
|
||||||
/// if the port is changed then return true
|
/// if the port is changed then return true
|
||||||
pub fn patch_config(&mut self, patch: Mapping) -> Result<bool> {
|
pub fn patch_config(&mut self, patch: Mapping) -> Result<bool> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user