Skip to content

Commit

Permalink
Add close connections
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanChane committed Aug 1, 2024
1 parent f86565a commit e9dce3b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions clashtui/api/src/clash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ impl ClashUtil {
.map_err(process_err)
}

pub fn close_connnections(&self) -> Result<String> {
self.request(Method::Delete, "/connections", None)
}

/*** update_providers_with_api
pub fn update_providers(&self, provider_type: ProfileSectionType) -> Result<Vec<(String, Result<String>)>> {
self.extract_net_providers(provider_type).and_then(|names| self.update_providers_helper(names, provider_type))
Expand Down
1 change: 1 addition & 0 deletions clashtui/src/tui/tabs/clashsrvctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl ClashSrvCtlTab {
ClashSrvOp::StartClashService.into(),
ClashSrvOp::StopClashService.into(),
ClashSrvOp::SwitchMode.into(),
ClashSrvOp::CloseConnections.into(),
]);
let mut modes = List::new("Mode".to_string());
modes.set_items(vec![
Expand Down
3 changes: 2 additions & 1 deletion clashtui/src/tui/tabs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ define_enum!(
StartClashService,
StopClashService,
SetPermission,
SwitchMode
SwitchMode,
CloseConnections
]
);
3 changes: 3 additions & 0 deletions clashtui/src/utils/tui/impl_clashsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ impl ClashTuiUtil {
ipc::exec_with_sbin("pkexec", cmd)
}
}
ClashSrvOp::CloseConnections => {
self.clash_api.close_connnections()
}
_ => Err(Error::new(
std::io::ErrorKind::NotFound,
"No Support Action",
Expand Down

0 comments on commit e9dce3b

Please sign in to comment.