class

RNS::Destination

Inherits RNS::Destination::DestinationInterface < Reference < Object

A named endpoint for sending or receiving packets, identified by a hash derived from the application name, aspects, and an optional identity.

Constants

ALLOW_ALL = 1_u8
ALLOW_LIST = 2_u8
ALLOW_NONE = 0_u8

─── Request policy constants ─────────────────────────────────────

DIRECTIONS = [IN, OUT]
GROUP = 1_u8
IN = 17_u8

─── Direction constants ──────────────────────────────────────────

LINK = 3_u8
OUT = 18_u8
PLAIN = 2_u8
PR_TAG_WINDOW = 30

─── Ratchet constants ────────────────────────────────────────────

PROOF_STRATEGIES = [PROVE_NONE, PROVE_APP, PROVE_ALL]
PROVE_ALL = 35_u8
PROVE_APP = 34_u8
PROVE_NONE = 33_u8

─── Proof strategy constants ─────────────────────────────────────

RATCHET_COUNT = 512
RATCHET_INTERVAL = 30 * 60
REQUEST_POLICIES = [ALLOW_NONE, ALLOW_ALL, ALLOW_LIST]
SINGLE = 0_u8

─── Type constants ───────────────────────────────────────────────

TYPES = [SINGLE, GROUP, PLAIN, LINK]

Constructors

new(identity : Identity | Nil, direction : UInt8, type : UInt8, app_name : String, aspects : Array(String) = [] of String, register : Bool = true)

Creates a new destination.

  • identity: the Identity that owns this destination (nil for PLAIN type)
  • direction: IN (receive) or OUT (send)
  • type: SINGLE, GROUP, PLAIN, or LINK
  • app_name: application name (no dots allowed)
  • aspects: additional name components appended after app_name
  • register: whether to register with Transport immediately
Source

Class methods

app_and_aspects_from_name(full_name : String) : Tuple(String, Array(String))
Source
expand_name(identity : Identity | Nil, app_name : String, aspects : Array(String)) : String
Source
expand_name(identity : Identity | Nil, app_name : String, *aspects : String) : String
Source
hash(identity_hash : Bytes, app_name : String, aspects : Array(String)) : Bytes
Source
hash(identity : Identity | Nil, app_name : String, aspects : Array(String)) : Bytes
Source
hash(identity : Identity | Nil, app_name : String, *aspects : String) : Bytes
Source
hash_from_name_and_identity(full_name : String, identity : Identity | Nil) : Bytes

Derives a destination hash from a dot-separated full_name and an optional identity.

Source

Instance methods

announce(app_data : Bytes | Nil = nil, path_response : Bool = false, attached_interface = nil, tag : Bytes | Nil = nil, send : Bool = true) : Packet | Nil

Sends an announce packet for this destination, advertising its public key and optional app_data to the network. Only valid for SINGLE/IN destinations.

Source
callbacks
Source
callbacks=(callbacks : DestinationCallbacks)
Source
clear_default_app_data
Source
create_keys
Source
decrypt(ciphertext : Bytes) : Bytes | Nil

Decrypts ciphertext using this destination's identity or group key. Returns nil if decryption fails. PLAIN destinations return data unmodified.

Source
default_app_data
Source
default_app_data=(default_app_data : Bytes | Proc(Bytes | Nil) | Nil)
Source
deregister_request_handler(path : String) : Bool
Source
direction
Source
enable_ratchets(ratchets_path : String) : Bool
Source
encrypt(plaintext : Bytes) : Bytes

Encrypts plaintext using this destination's identity or group key. PLAIN destinations return data unmodified.

Source
enforce_ratchets
Source
get_private_key
Source
hash

─── Instance properties ──────────────────────────────────────────

Source
hash=(hash : Bytes)

─── Instance properties ──────────────────────────────────────────

Source
hexhash
Source
hexhash=(hexhash : String)
Source
identity
Source
latest_ratchet_id
Source
latest_ratchet_id=(latest_ratchet_id : Bytes | Nil)
Source
latest_ratchet_time
Source
latest_ratchet_time=(latest_ratchet_time : Float64 | Nil)
Source
load_private_key(key : Bytes)
Source
load_public_key(key : Bytes)
Source
mtu=(mtu : Int32)
Source
name
Source
name_hash
Source
proof_strategy
Source
proof_strategy=(proof_strategy : UInt8)
Source
prv=(prv : Cryptography::Token | Nil)
Source
prv_bytes

GROUP key properties

Source
prv_bytes=(prv_bytes : Bytes | Nil)

GROUP key properties

Source
ratchet_interval
Source
ratchet_interval=(ratchet_interval : Int32)
Source
ratchets

Ratchet properties

Source
ratchets=(ratchets : Array(Bytes) | Nil)

Ratchet properties

Source
ratchets_path
Source
ratchets_path=(ratchets_path : String | Nil)
Source
receive(packet : Packet) : Bool
Source
register_request_handler(path : String, response_generator : Proc(String, Bytes | Nil, Bytes, Bytes, Identity | Nil, Float64, Bytes | Nil), allow : UInt8 = ALLOW_NONE, allowed_list : Array(Bytes) | Nil = nil, auto_compress : Bool = true)

Registers a request handler for the given path. The response_generator proc is called when a matching request arrives; allow controls the access policy.

Source
request_handlers
Source
retained_ratchets
Source
retained_ratchets=(retained_ratchets : Int32)
Source
rotate_ratchets
Source
set_default_app_data(app_data : Bytes | Proc(Bytes | Nil) | Nil = nil)
Source
set_packet_callback(callback : Proc(Bytes, Packet, Nil))

Sets the callback invoked when a data packet is received at this destination.

Source
set_proof_requested_callback(callback : Proc(Packet, Bool))

Sets the callback invoked to decide whether a proof should be sent for a packet. Used when proof_strategy is PROVE_APP.

Source
set_proof_strategy(proof_strategy : UInt8)

Configures the proof strategy: PROVE_NONE, PROVE_ALL, or PROVE_APP.

Source
set_ratchet_interval(interval : Int32) : Bool
Source
set_retained_ratchets(retained_ratchets : Int32) : Bool
Source
sign(message : Bytes) : Bytes | Nil

Signs message using the identity's private key. Only works for SINGLE destinations.

Source
to_s(io : IO) : Nil

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>
Source
type
Source

Nested types