forked from mirrors/relay
Merge branch 'cmdline-ls'
This commit is contained in:
commit
08374d0382
3 changed files with 21 additions and 0 deletions
|
@ -11,6 +11,9 @@ pub(crate) struct Args {
|
|||
|
||||
#[arg(short, long, help = "Undo allowing or blocking domains")]
|
||||
undo: bool,
|
||||
|
||||
#[arg(short, long, help = "List allowed and blocked domains")]
|
||||
list: bool,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
|
@ -29,4 +32,8 @@ impl Args {
|
|||
pub(crate) fn undo(&self) -> bool {
|
||||
self.undo
|
||||
}
|
||||
|
||||
pub(crate) fn list(&self) -> bool {
|
||||
self.list
|
||||
}
|
||||
}
|
||||
|
|
|
@ -464,6 +464,10 @@ impl Db {
|
|||
self.unblock(|inner| Ok(inner.blocks().collect())).await
|
||||
}
|
||||
|
||||
pub(crate) async fn allows(&self) -> Result<Vec<String>, Error> {
|
||||
self.unblock(|inner| Ok(inner.allowed().collect())).await
|
||||
}
|
||||
|
||||
pub(crate) async fn inboxes(&self) -> Result<Vec<IriString>, Error> {
|
||||
self.unblock(|inner| Ok(inner.connected_actors().map(|actor| actor.inbox).collect()))
|
||||
.await
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -101,6 +101,16 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
|
||||
let args = Args::new();
|
||||
|
||||
if args.list() {
|
||||
for domain in db.blocks().await? {
|
||||
println!("block {}", domain);
|
||||
}
|
||||
for domain in db.allows().await? {
|
||||
println!("allow {}", domain);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if !args.blocks().is_empty() || !args.allowed().is_empty() {
|
||||
if args.undo() {
|
||||
db.remove_blocks(args.blocks().to_vec()).await?;
|
||||
|
|
Loading…
Reference in a new issue