AutoInterface implements zero-configuration peer discovery and data transfer
using IPv6 multicast. Ports RNS/Interfaces/AutoInterface.py (663 LOC).
Discovery works by:
- Each interface periodically sends a peering hash (group_id + link-local addr)
to a multicast group on the discovery port
- When a peer's peering hash is received and validated, an AutoInterfacePeer
is spawned for unicast data transfer on the data port
- Peers are tracked with timeouts and removed when they go silent
- Reverse peering packets are sent unicast to keep peers alive
Constants
ANDROID_IGNORE_IFS = ["dummy0", "lo", "tun0"]
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")
DISABLE_LIVE_INTERFACE_SETUP_ENV = "RNS_TEST_DISABLE_AUTO_INTERFACE_NETWORK"
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 %}
MULTI_IF_DEQUE_TTL = 0.75
MULTICAST_PERMANENT_ADDRESS_TYPE = "0"
MULTICAST_TEMPORARY_ADDRESS_TYPE = "1"
Instance methods
announce_handler(ifname :
String)
Periodically send multicast peering announcements
SourceCompute the IPv6 multicast discovery address from the group hash.
Matches Python: "ff" + address_type + scope + ":" + formatted_hash
Sourcedetach
Called when the interface is being detached/removed
SourceHandle incoming discovery packets
Sourcefinal_init
Start discovery and data listeners, peer jobs, and go online
Sourcemif_deque_add(data_hash :
Bytes)
Add to multi-interface deduplication deque
SourceCheck if data hash is in the multi-interface deque and still valid
Sourceowner_inbound
Owner reference (Reticulum instance or similar object that calls inbound)
Sourceowner_inbound=(owner_inbound :
Proc(
Bytes,
Interface,
Nil) |
Nil)
Owner reference (Reticulum instance or similar object that calls inbound)
Sourcepeer_announce(ifname :
String)
Send a multicast peering announcement on an interface
Sourcepeer_count
Number of active peer connections
Sourcepeer_jobs
Periodic peer maintenance
Sourceprocess_incoming(data :
Bytes, addr :
String |
Nil = nil)
Route incoming data to the appropriate spawned peer interface
Sourceprocess_outgoing(data :
Bytes)
Send data out through the interface. Subclasses must implement this.
SourceUpdate a peer's last_heard timestamp
SourceSend a reverse (unicast) peering announcement to a specific peer
Sourcereverse_peering_interval
Sourcespawned_peer_interfaces
Expose spawned peer interfaces (for testing and Transport integration)
SourceAppends 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