mirror of
https://codeberg.org/YGGverse/psocks.git
synced 2026-03-31 16:35:28 +00:00
rename some methods
This commit is contained in:
parent
f5345e963d
commit
0b08744f8f
2 changed files with 11 additions and 11 deletions
12
src/main.rs
12
src/main.rs
|
|
@ -33,7 +33,7 @@ async fn api_allow(
|
|||
totals: &State<Arc<Total>>,
|
||||
) -> Result<Json<bool>, Status> {
|
||||
let result = rules.allow(rule).await;
|
||||
totals.set_entries(rules.rules().await);
|
||||
totals.set_entries(rules.total().await);
|
||||
info!("Delete `{rule}` from the in-memory rules (operation status: {result:?})");
|
||||
Ok(Json(result.map_err(|e| {
|
||||
error!("Allow request handle error for `{rule}`: `{e}`");
|
||||
|
|
@ -48,7 +48,7 @@ async fn api_block(
|
|||
totals: &State<Arc<Total>>,
|
||||
) -> Result<Json<bool>, Status> {
|
||||
let result = rules.block(rule).await;
|
||||
totals.set_entries(rules.rules().await);
|
||||
totals.set_entries(rules.total().await);
|
||||
info!("Add `{rule}` to the in-memory rules (operation status: {result:?})");
|
||||
Ok(Json(result.map_err(|e| {
|
||||
error!("Block request handle error for `{rule}`: `{e}`");
|
||||
|
|
@ -58,9 +58,9 @@ async fn api_block(
|
|||
|
||||
#[rocket::get("/api/rules")]
|
||||
async fn api_rules(rules: &State<Arc<Rules>>) -> Result<Json<Vec<String>>, Status> {
|
||||
let result = rules.list().await;
|
||||
info!("Get rules (total: {})", result.len());
|
||||
Ok(Json(result))
|
||||
let active = rules.active().await;
|
||||
info!("Get rules (total: {})", active.len());
|
||||
Ok(Json(active))
|
||||
}
|
||||
|
||||
#[rocket::launch]
|
||||
|
|
@ -71,7 +71,7 @@ async fn rocket() -> _ {
|
|||
|
||||
let rules = Arc::new(Rules::from_opt(&opt.allow_list).await.unwrap());
|
||||
|
||||
let totals = Arc::new(Total::with_rules(rules.rules().await));
|
||||
let totals = Arc::new(Total::with_rules(rules.total().await));
|
||||
|
||||
tokio::spawn({
|
||||
let socks_rules = rules.clone();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue