module

RNS

Crystal port of the Reticulum Network Stack.

Reticulum is a cryptography-based networking protocol for building reliable, encrypted, and authenticated communications over any available medium. This module provides the complete RNS API including Identity management, Destination addressing, Packet construction, Link establishment, Channel messaging, Resource transfers, and a full suite of network interfaces.

See: https://reticulum.network

Constants

LOG_CALLBACK = 147
LOG_CRITICAL = 0
LOG_DEBUG = 6
LOG_ERROR = 1
LOG_EXTREME = 7
LOG_FILE = 146
LOG_INFO = 4
LOG_MAXSIZE = (5 * 1024) * 1024

Maximum log file size before rotation (5 MB).

LOG_NONE = -1

Log level constants, matching the Python RNS log levels exactly.

LOG_NOTICE = 3
LOG_STDOUT = 145

Log destination constants.

LOG_VERBOSE = 5
LOG_WARNING = 2
VERSION = "0.1.0"

Current version of the Crystal RNS shard.

Class methods

compact_log_fmt

When true, omits the log level tag from output.

Source
compact_log_fmt=(compact_log_fmt : Bool)

When true, omits the log level tag from output.

Source
exit(code : Int32 = 0)

Performs graceful shutdown: saves state, tears down interfaces, then exits.

Source
exit_called?

Returns true if exit has already been called.

Source
hexrep(data : Bytes, delimit : Bool = true) : String
Source
host_os

Returns the host operating system name (e.g. "linux", "darwin").

Source
log(msg, level : Int32 = LOG_NOTICE, _override_destination : Bool = false)

Emits a log message at the given level. The message is routed to stdout, a file, or a callback depending on the current logdest.

Source
logcall

Callback proc invoked for each log line when logdest is LOG_CALLBACK.

Source
logcall=(logcall : Proc(String, Nil) | Nil)

Callback proc invoked for each log line when logdest is LOG_CALLBACK.

Source
logdest

Log destination: LOG_STDOUT, LOG_FILE, or LOG_CALLBACK.

Source
logdest=(logdest : Int32)

Log destination: LOG_STDOUT, LOG_FILE, or LOG_CALLBACK.

Source
logfile

Path to log file when logdest is LOG_FILE.

Source
logfile=(logfile : String | Nil)

Path to log file when logdest is LOG_FILE.

Source
loglevel

Current log level. Messages above this level are suppressed.

Source
loglevel=(loglevel : Int32)

Current log level. Messages above this level are suppressed.

Source
loglevelname(level : Int32) : String

Returns a human-readable label for the given log level.

Source
logtimefmt

Timestamp format string for log output.

Source
logtimefmt=(logtimefmt : String)

Timestamp format string for log output.

Source
panic
Source
phyparams

Prints the physical layer parameters (MTU, MDU, key sizes) to stdout.

Source
precise_timestamp_str(time_s : Float64) : String

Returns a high-precision timestamp string (HH:MM:SS.mmm).

Source
prettydistance(m : Float64, suffix : String = "m") : String
Source
prettyfrequency(hz : Float64, suffix : String = "Hz") : String
Source
prettyhexrep(data : Bytes) : String
Source
prettyshorttime(time : Float64, verbose : Bool = false, compact : Bool = false) : String
Source
prettysize(num : Float64, suffix : String = "B") : String
Source
prettyspeed(num : Float64, suffix : String = "b") : String
Source
prettytime(time : Float64, verbose : Bool = false, compact : Bool = false) : String
Source
rand
Source
timestamp_str(time_s : Float64) : String

Formats a Unix timestamp as a human-readable string using the configured format.

Source
trace_exception(e : Exception)

Logs an unhandled exception with full backtrace at ERROR level.

Source
version

Returns the RNS shard version string.

Source

Nested types