defmodule RNS.Reticulum do @moduledoc "Supervisor to start the Reticulum Network Service" require Logger def child_spec(opts) do %{ id: __MODULE__, start: {__MODULE__, :start_link, [opts]} } end def start_link(config \\ nil) def start_link(nil) do case RNS.Config.parse() do {:ok, config} -> start_link(config) {:error, :invalid_toml} -> Logger.emergency("Failed to start Reticulum: Config contains invalid TOML!") {:error, :invalid_config} end end def start_link(config) do Logger.info("RNS is starting...") transport = RNS.Config.transport(config) children = [ {RNS.Config, config}, RNS.IdentityStore, RNS.DestinationStore, RNS.PacketHashStore, RNS.AnnounceHashStore, RNS.PathRequestStore, {RNS.InterfaceManager, {RNS.Config.interfaces(config), transport}}, {RNS.Packet.PathRequest, transport} ] opts = [strategy: :one_for_one, name: RNS.Reticulum] Supervisor.start_link(children, opts) end end