Archived
1
0
Fork
You've already forked lxmf
0
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.
  • Elixir 100%
2025年09月02日 16:58:59 +02:00
lib Hello, git! 2025年09月02日 16:58:59 +02:00
test Hello, git! 2025年09月02日 16:58:59 +02:00
.gitignore Hello, git! 2025年09月02日 16:58:59 +02:00
mix.exs Hello, git! 2025年09月02日 16:58:59 +02:00
README.md Hello, git! 2025年09月02日 16:58:59 +02:00

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.