A (work in progress) implementation of the Lightweight eXtensible Message Protocol(LXMF) in elixir.
This repository has been archived on 2026年04月25日 . You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
| lib | Hello, git! | |
| test | Hello, git! | |
| .gitignore | Hello, git! | |
| mix.exs | Hello, git! | |
| README.md | Hello, git! | |
LXMF
An implementation of LXMF in elixir, for my Reticulum implementation(in elixir).
Some examples
Listening for announces
# Start Reticulum
RNS.Reticulum.start_link()
# Adds the current process as a peer handler, to receive announces from new peers.
LXMF.add_peer_handler()
# This should be in a loop
receive do
{:announce, destination} ->
destination
|> LXMF.parse_destination()
|> IO.inspect()
_ ->
IO.inspect("unknown message")
end
# The result will be similar to this:
# {:ok, {:peer, <<72, 4, 186, 175, 6, 165, 252, 138, 46, 106, 20, 49, 84, 193, 3, 54>>, "Int32", nil}}
Sending a message
# Start Reticulum
RNS.Reticulum.start_link()
# Create an identity.
source_identity = RNS.Identity.new()
# And add it to the store.
RNS.IdentityStore.put(source_identity)
# Create a new destination using the identity.
source = RNS.Destination.new("lxmf", aspects: ["delivery"], identity_hash: RNS.Identity.hash(source_identity), interface: self())
# And add it to the store.
RNS.DestinationStore.put(source)
# You can get the destination you want from the store like this.
{:ok, destination} = RNS.DestinationStore.fetch(<<72, 4, 186, 175, 6, 165, 252, 138, 46, 106, 20, 49, 84, 193, 3, 54>>)
{:ok, destination_identity} = RNS.IdentityStore.fetch(RNS.Destination.identity_hash(destination))
{:ok, destination_ratchet} = RNS.DestinationStore.fetch_recent_ratchet(RNS.Destination.hash(destination))
# NOW, we can create the message!
{:ok, message} = LXMF.Message.new(destination, source, content: "Hello world!")
packet = LXMF.Message.to_packet(message) |> RNS.Packet.maybe_encrypt(destination_identity, destination_ratchet)
RNS.Interface.send(packet, RNS.Destination.interface(destination))
Installation
If available in Hex, the package can be installed
by adding lxmf to your list of dependencies in mix.exs:
def deps do
[
{:lxmf, "~> 0.1.0"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/lxmf.