rayhunter.api

class rayhunter.api.RayhunterApi(hostname: str, port: int)[source]

Bases: object

Properties

property active_recording: bool

Check the manifest file to determine if there’s a recording in progress.

Returns:

True if there’s a “current_entry” in the manifest, else False

property configuration: Config

Fetch the current runtime configuration from the target device.

Returns:

An instance of Config populated with the current runtime configuration.

Note

configuration is a read/write property. Reading it calls get_config(); assigning to it calls set_config() and triggers a device reboot.

Recording control

start_recording()[source]

Start a new recording. Stops the active recording and starts a new one if this device is already recording.

stop_recording()[source]

Stop an active recording. Throws a 500 error if there is no active recording.

Manifest and captures

get_manifest() QmdlManifest[source]

Fetch a copy of the QMDL manifest, used to track the names of previous and active recordings.

Returns:

An instance of QmdlManifest populated from the target device

get_qmdl_file(filename: str) bytes[source]

Fetch a copy of the given QMDL file. Use get_manifest to identify QMDL capture names.

Parameters:

filename – The QMDL file name (found in manifest)

Returns:

The contents of the QMDL file (bytes)

get_pcap_file(filename: str) bytes[source]

Fetch a copy of the pcap file for a given capture. PCAP is dynamically generated from QMDL by the Rayhunter binary when this API is called.

Parameters:

filename – The capture file name (found in manifest)

Returns:

The contents of the pcap file (bytes)

get_zip(filename: str) bytes[source]

Download a ZIP file to the client which contains the QMDL file {name} and a PCAP generated from the same file.

Use get_manifest to identify valid filenames.

Parameters:

filename – QMDL filename to convert and download.

Returns:

A zip file containing the requested files.

get_analysis_report_file(filename: str) bytes[source]

Fetch a copy of the analysis report for a given capture. Use get_manifest to identify capture names.

Parameters:

filename – The capture file name

Returns:

The contents of the analysis report file (bytes)

get_analysis_status() AnalysisStatus[source]

Show analysis status for all QMDL files.

Returns:

An instance of AnalysisStatus populated from the target device.

File management

delete_recording(filename: str) bool[source]

Remove a specific data capture file by name. Use get_manifest to identify available file names.

Parameters:

filename – The file to delete

Returns:

True if deletion was successful, else False

delete_all_recordings() bool[source]

Remove all saved data capture files.

Returns:

True if deletion was successful, else False

System information

get_system_stats() SystemStats[source]

Fetch disk and memory utilization stats from the API.

Returns:

An instance of SystemStats populated from the target device.

get_time() TimeResponse[source]

Get the current time and offset (in seconds) from the target device.

Returns:

An instance of TimeResponse populated from the target device.

get_log() bytes[source]

Download the current device log in UTF-8 plaintext.

Returns:

The contents of the device log (bytes).

Configuration

get_config() Config[source]

Get the current runtime configuration for Rayhunter.

Returns:

An instance of Config populated from the target device.

set_config(config: Config)[source]

Update the Rayhunter runtime configuration to the supplied configuration options and trigger a reboot.

Parameters:

config – An instance of Config populated with the desired configuration options.

Notifications

send_test_notification()[source]

Send a test notification to the ntfy_url currently specified in the Rayhunter runtime configuration.