mirror of
https://codeberg.org/YGGverse/psocks.git
synced 2026-03-31 16:35:28 +00:00
implement session cache
This commit is contained in:
parent
e5268e49f1
commit
8de35ff3a6
5 changed files with 123 additions and 31 deletions
10
src/main.rs
10
src/main.rs
|
|
@ -26,7 +26,7 @@ async fn allow(rule: &str, list: &State<Arc<List>>, totals: &State<Arc<Total>>)
|
|||
let result = list.allow(rule).await;
|
||||
totals.set_entries(list.entries().await);
|
||||
info!("Delete `{rule}` from the in-memory rules (operation status: {result:?})");
|
||||
Json(result)
|
||||
Json(result.is_ok_and(|v| v))
|
||||
}
|
||||
|
||||
#[rocket::get("/block/<rule>")]
|
||||
|
|
@ -34,7 +34,7 @@ async fn block(rule: &str, list: &State<Arc<List>>, totals: &State<Arc<Total>>)
|
|||
let result = list.block(rule).await;
|
||||
totals.set_entries(list.entries().await);
|
||||
info!("Add `{rule}` to the in-memory rules (operation status: {result:?})");
|
||||
Json(result)
|
||||
Json(result.is_ok_and(|v| v))
|
||||
}
|
||||
|
||||
#[rocket::launch]
|
||||
|
|
@ -44,11 +44,11 @@ async fn rocket() -> _ {
|
|||
let opt: &'static Opt = Box::leak(Box::new(Opt::from_args()));
|
||||
|
||||
let list = Arc::new(
|
||||
List::from_opt(&opt.allow_list)
|
||||
List::from_opt(&opt.allow_list, opt.cache.clone())
|
||||
.await
|
||||
.map_err(|err| {
|
||||
error!("Can't parse whitelist: `{err}`");
|
||||
SocksError::ArgumentInputError("Can't parse whitelist")
|
||||
error!("Can't parse list: `{err}`");
|
||||
SocksError::ArgumentInputError("Can't parse list")
|
||||
})
|
||||
.unwrap(),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue