class

RNS::AutoInterface

Inherits RNS::Interface < Reference < Object

AutoInterface implements zero-configuration peer discovery and data transfer using IPv6 multicast. Ports RNS/Interfaces/AutoInterface.py (663 LOC).

Discovery works by:

  1. Each interface periodically sends a peering hash (group_id + link-local addr) to a multicast group on the discovery port
  2. When a peer's peering hash is received and validated, an AutoInterfacePeer is spawned for unicast data transfer on the data port
  3. Peers are tracked with timeouts and removed when they go silent
  4. Reverse peering packets are sent unicast to keep peers alive

Constants

ALL_IGNORE_IFS = ["lo0"]
ANDROID_IGNORE_IFS = ["dummy0", "lo", "tun0"]
ANNOUNCE_INTERVAL = 1.6
BITRATE_GUESS = 10000000_i64
DARWIN_IGNORE_IFS = ["awdl0", "llw0", "lo0", "en5"]
DEFAULT_DATA_PORT = 42671
DEFAULT_DISCOVERY_PORT = 29716
DEFAULT_GROUP_ID = "reticulum".encode("UTF-8")
DEFAULT_IFAC_SIZE = 16
DISABLE_LIVE_INTERFACE_SETUP_ENV = "RNS_TEST_DISABLE_AUTO_INTERFACE_NETWORK"
FIXED_MTU = true
HW_MTU = 1196
IPPROTO_IPV6 = 41

IPv6 multicast socket options

IPV6_JOIN_GROUP = {% if flag?(:darwin) %} 12 {% elsif flag?(:linux) %} 20 {% else %} 12 {% end %}
IPV6_MULTICAST_IF = {% if flag?(:darwin) %} 9 {% elsif flag?(:linux) %} 17 {% else %} 9 {% end %}
IPV6_MULTICAST_LOOP = {% if flag?(:darwin) %} 11 {% elsif flag?(:linux) %} 19 {% else %} 11 {% end %}
MCAST_ECHO_TIMEOUT = 6.5
MULTI_IF_DEQUE_LEN = 48
MULTI_IF_DEQUE_TTL = 0.75
MULTICAST_PERMANENT_ADDRESS_TYPE = "0"
MULTICAST_TEMPORARY_ADDRESS_TYPE = "1"
PEER_JOB_INTERVAL = 4.0
PEERING_TIMEOUT = 22.0
SCOPE_ADMIN = "4"
SCOPE_GLOBAL = "e"
SCOPE_LINK = "2"
SCOPE_ORGANISATION = "8"
SCOPE_SITE = "5"

Constructors

new(configuration : Hash(String, String), inbound_callback : Proc(Bytes, Interface, Nil) | Nil = nil)
Source

Instance methods

add_peer(addr : String, ifname : String)

Add or refresh a peer

Source
adopted_interfaces
Source
adopted_interfaces=(adopted_interfaces : Hash(String, String))
Source
allowed_interfaces
Source
announce_handler(ifname : String)

Periodically send multicast peering announcements

Source
announce_interval
Source
carrier_changed
Source
carrier_changed=(carrier_changed : Bool)
Source
compute_mcast_address(group_hash : Bytes) : String

Compute the IPv6 multicast discovery address from the group hash. Matches Python: "ff" + address_type + scope + ":" + formatted_hash

Source
data_port
Source
detach

Called when the interface is being detached/removed

Source
dir_in
Source
dir_in=(dir_in : Bool)
Source
dir_out
Source
dir_out=(dir_out : Bool)
Source
discovery_handler(socket : UDPSocket, ifname : String, announce : Bool = true)

Handle incoming discovery packets

Source
discovery_port
Source
discovery_scope
Source
final_init

Start discovery and data listeners, peer jobs, and go online

Source
final_init_done=(final_init_done : Bool)
Source
final_init_done?
Source
group_hash
Source
group_id
Source
ignored_interfaces
Source
inbound_callback=(cb : Proc(Bytes, Interface, Nil) | Nil)
Source
initial_echoes
Source
initial_echoes=(initial_echoes : Hash(String, Float64))
Source
mcast_discovery_address
Source
mif_deque_add(data_hash : Bytes)

Add to multi-interface deduplication deque

Source
mif_deque_hit?(data_hash : Bytes) : Bool

Check if data hash is in the multi-interface deque and still valid

Source
multicast_address_type
Source
multicast_echo_timeout
Source
multicast_echoes
Source
multicast_echoes=(multicast_echoes : Hash(String, Float64))
Source
outbound_udp_socket
Source
outbound_udp_socket=(outbound_udp_socket : UDPSocket | Nil)
Source
owner_inbound

Owner reference (Reticulum instance or similar object that calls inbound)

Source
owner_inbound=(owner_inbound : Proc(Bytes, Interface, Nil) | Nil)

Owner reference (Reticulum instance or similar object that calls inbound)

Source
peer_announce(ifname : String)

Send a multicast peering announcement on an interface

Source
peer_count

Number of active peer connections

Source
peer_job_interval
Source
peer_jobs

Periodic peer maintenance

Source
peering_timeout
Source
peers

Properties

Source
peers=(peers : Hash(String, PeerEntry))

Properties

Source
process_incoming(data : Bytes, addr : String | Nil = nil)

Route incoming data to the appropriate spawned peer interface

Source
process_outgoing(data : Bytes)

Send data out through the interface. Subclasses must implement this.

Source
receives=(receives : Bool)
Source
receives?
Source
refresh_peer(addr : String)

Update a peer's last_heard timestamp

Source
reverse_announce(ifname : String, peer_addr : String)

Send a reverse (unicast) peering announcement to a specific peer

Source
reverse_peering_interval
Source
spawned_peer_interfaces

Expose spawned peer interfaces (for testing and Transport integration)

Source
timed_out_interfaces
Source
timed_out_interfaces=(timed_out_interfaces : Hash(String, Bool))
Source
to_s(io : IO)

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
unicast_discovery_port
Source
write_lock
Source
write_lock=(write_lock : Mutex)
Source

Nested types