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
setDockerOptions(options: table)
Sets the docker container options (used in docker challenges)
- Parameters:
options
(table): A table containing Docker configuration options.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 is0.0.0.0
.environment
(string[]): A list of environment variables.
- Example:
raya.setDockerOptions({
port = "3000",
volumes = {"/tmp/flag.txt:/app/flag.txt"},
environment = {"TEAM_NAME=<TEAM_NAME>", "MY_FLAG=FLAG{1234}"}
})
flag(flag: string)
Sets the instance flag.
- Parameters:
flag
(string): Instance flag
- Example:
raya.flag(string.format("FLAG{%s}", random_hex(50)))
setInstanceDescription(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.
- Parameters:
description
(table): Instance description (markdown is supported)
- Example:
raya.setInstanceDescription(string.format([[
#### Connection information
Your password is: `%s`
]], random_password))
setInstanceOptions(options: table)
Sets the instance options.
- Parameters:
options
(table): A table containing 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 is127.0.0.1
- Example:
raya.setInstanceOptions({
host = "my_custom_domain.com",
})
Constants
raya.user
(table)id
(string)name
(string)is_admin
(bool)team
(table)