Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

raya Lua API Reference

This document provides an overview of the raya Lua API, which allows users to interact with and extend the functionality of the raya platform. Certain methods are tied to specific events.

Note: I might refactor the extension subsystem so that it's similar to neovim, where an init.lua is loaded by the platform and then you can require more scripts and register events using raya.on


Table of Contents


General Functions

These functions are available in all event contexts.

log(message: string)

Logs a message to the raya platform's console or log file.

  • Parameters:
    • message: A string containing the message to log.
  • Example:
raya.log("Application started.")

Pre Instance Creation

docker_options: table

Sets the docker container options (used in docker challenges)

  • port (string): The container port you wish to publish.
  • volumes (string[]): A list of volume mappings.
  • devices (string[]): A list of devices to mount in the container.
  • host_ip (string): The host IP address, the default is 0.0.0.0.
  • environment (string[]): A list of environment variables.
  • Example:
raya.docker_options = {
    port = "3000",
    volumes = {"/tmp/flag.txt:/app/flag.txt"},
    environment = {"TEAM_NAME=<TEAM_NAME>", "MY_FLAG=FLAG{1234}"}
}

flag: string

Sets the instance flag.

  • Example:
raya.flag = string.format("FLAG{%s}", random_hex(50))

description: string

Sometimes you may wish to add a dynamic description for an instance. For example, the instance may be protected using a random password and you want to show the connection details to the user.

  • description (string): Instance description (markdown is supported)

  • Example:

raya.description = string.format([[
#### Connection information
Your password is: `%s`
]], random_password)

instance: table

Sets the instance options.

  • show_port (bool): Whether to show the allocated port next to the host.
  • host (string[]): The host to show to the user, the default is 127.0.0.1
  • Example:
raya.instance = {
    host = "my_custom_domain.com",
}

Constants

  • raya.user (table)
    • id (string)
    • name (string)
    • is_admin (bool)
    • team (table)