function cmd::logs::follow() {
  local filter_ip="${1:-}" filter_name="${2:-}" filter_type="${3:-}"
  local fw_only="${4:-false}" wg_only="${5:-false}"

  log::section "WireGuard Live Log (Ctrl+C to stop)"
  printf "\n"

  local watch_args=()
  [[ -n "$filter_name" ]] && watch_args+=(--name "$filter_name")
  [[ -n "$filter_type" ]] && watch_args+=(--type "$filter_type")
  $fw_only && watch_args+=(--restricted)
  $wg_only && watch_args+=(--blocked)

  cmd::watch::run "${watch_args[@]}"
}
function cmd::watch::run() {
  local filter_name="" filter_type="" filter_peers=""
  local blocked_only=false allowed_only=false restricted_only=false
  local raw=false

  rm -f /tmp/wgctl_hs_* /tmp/wgctl_attempt_* 2>/dev/null || true

  while [[ $# -gt 0 ]]; do
    case "$1" in
      --name)       filter_name="$2";     shift 2 ;;
      --type)       filter_type="$2";     shift 2 ;;
      --peers)      filter_peers="$2";    shift 2 ;;
      --blocked)    blocked_only=true;    shift   ;;
      --allowed)    allowed_only=true;    shift   ;;
      --restricted) restricted_only=true; shift   ;;
      --raw)        _WGCTL_RAW=true;      shift   ;;
      --help)       cmd::watch::help;     return  ;;
      *)
        log::error "Unknown flag: $1"
        cmd::watch::help
        return 1
        ;;
    esac
  done

  log::section "wgctl — Live Monitor (Ctrl+C to stop)"
  printf "\n"

  local w_client=20 w_dest=18

  if ! $blocked_only && ! $restricted_only; then
    (
      while true; do
        cmd::watch::_poll_handshakes \
          "$filter_name" "$filter_type" "$filter_peers" "$w_client" "$w_dest"
        sleep 5
      done
    ) &
    local poller_pid=$!
  fi

  cmd::watch::_tail_events \
    "$filter_name" "$filter_type" "$filter_peers" \
    "$blocked_only" "$restricted_only" "$allowed_only" \
    "$w_client" "$w_dest" &
  local tailer_pid=$!

  trap "kill $tailer_pid ${poller_pid:-} 2>/dev/null; \
    rm -f /tmp/wgctl_hs_* /tmp/wgctl_attempt_*; printf '\n'; exit 0" INT TERM

  wait
}
