commit c1a0f4f192b9cf420dbd9752419b999e24e93339 Author: nuno Date: Sat May 30 05:21:19 2026 +0000 Add blockunblock diff --git a/blockunblock b/blockunblock new file mode 100644 index 0000000..7ecf429 --- /dev/null +++ b/blockunblock @@ -0,0 +1,77 @@ +function cmd::block::run() { + local name="" identity="" type="" block_name="" + local ips=() subnets=() ports=() services=() + local quiet=false force=false + local reason="" + + while [[ $# -gt 0 ]]; do + case "$1" in + --name) name="$2"; shift 2 ;; + --identity) identity="$2"; shift 2 ;; + --type) type="$2"; shift 2 ;; + --ip) ips+=("$2"); shift 2 ;; + --block-name) block_name="$2"; shift 2 ;; + --service) services+=("$2"); shift 2 ;; + --force) force=true; shift ;; + --quiet) quiet=true; shift ;; + --subnet) subnets+=("$2"); shift 2 ;; + --port) ports+=("$2"); shift 2 ;; + --reason) reason="$2"; shift 2 ;; + --help) cmd::block::help; return ;; + *) + log::error "Unknown flag: $1" + cmd::block::help + return 1 + ;; + esac + done + + # --identity: block all peers for this identity + if [[ -n "$identity" ]]; then + cmd::block::_block_identity "$identity" "$quiet" \ + "${ips[@]+"${ips[@]}"}" || return 1 + return 0 + fi + + [[ -z "$name" ]] && { + log::error "Missing required flag: --name or --identity" + cmd::block::help + return 1 + } +function cmd::unblock::run() { + local name="" identity="" type="" + local ips=() subnets=() ports=() services=() + local all=false quiet=false force=false + local reason="" + + while [[ $# -gt 0 ]]; do + case "$1" in + --name) name="$2"; shift 2 ;; + --identity) identity="$2"; shift 2 ;; + --type) type="$2"; shift 2 ;; + --ip) ips+=("$2"); shift 2 ;; + --force) force=true; shift ;; + --quiet) quiet=true; shift ;; + --subnet) subnets+=("$2"); shift 2 ;; + --port) ports+=("$2"); shift 2 ;; + --service) services+=("$2"); shift 2 ;; + --reason) reason="$2"; shift 2 ;; + --all) all=true; shift ;; + --help) cmd::unblock::help; return ;; + *) + log::error "Unknown flag: $1" + cmd::unblock::help + return 1 + ;; + esac + done + + # --identity: unblock all peers for this identity + if [[ -n "$identity" ]]; then + cmd::unblock::_unblock_identity "$identity" "$quiet" || return 1 + return 0 + fi + + if [[ -z "$name" ]]; then + log::error "Missing required flag: --name or --identity" + cmd::unblock::help \ No newline at end of file