Add blockunblock
This commit is contained in:
commit
c1a0f4f192
1 changed files with 77 additions and 0 deletions
77
blockunblock
Normal file
77
blockunblock
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Reference in a new issue