cloudpanel.command

Inspect, mutate, or cancel CloudPanel CLI commands before clpctl runs.

When
After an authenticated CloudPanel API handler builds typed args, before process spawn.
Input
CloudPanelCommandContext with operation, command, and args JSON.
Output
CLOUDPANEL_CONTINUE, CLOUDPANEL_MODIFIED via write_cloudpanel_args, or CLOUDPANEL_CANCEL via write_cloudpanel_cancel.
Route matching
Applies to all /api/system/cloudpanel routes.

Use this hook for policy enforcement and defaults. The command name is read-only; only the JSON args can be changed.

Pipeline

Hooks run in plugin load order. Mutated args become input for the next CloudPanel hook.

Use cases

  • Block destructive CloudPanel operations
  • Inject default paths
  • Rewrite domains for staging

Example

Registration and handler

Register

hook_cloudpanel!(host, on_cloudpanel_command);

Handler

extern "C" fn on_cloudpanel_command(ctx: *const CloudPanelCommandContext) -> i32 {
    let ctx = unsafe { &*ctx };
    let command = unsafe { std::slice::from_raw_parts(ctx.command_ptr, ctx.command_len) };
    if command == b"site:delete" {
        return write_cloudpanel_cancel(ctx, b"site deletion blocked");
    }
    CLOUDPANEL_CONTINUE
}

← Back to index