A simple store-and-forward + flooding daemon with signature verification
Go to file
Alain Zscheile 025b4a826f make TTL hop-based
this avoid dozens of issues regarding time warps, and also solves the issue
of infinitely cycling packets when the system is under saturation, as now
packets expire after passing the set amount of hops
2022-11-26 12:55:48 +01:00
asn1 make TTL hop-based 2022-11-26 12:55:48 +01:00
lib make TTL hop-based 2022-11-26 12:55:48 +01:00
mock_keydb first try at integration test 2022-11-24 16:30:14 +01:00
test make TTL hop-based 2022-11-26 12:55:48 +01:00
.formatter.exs initial commit 2022-11-22 17:35:08 +01:00
.gitignore fix crash at startup when upstream is given 2022-11-25 01:17:23 +01:00
mix.exs fix compilation in fresh env 2022-11-25 00:42:44 +01:00
mix.lock fix compilation warning about ASN.1 2022-11-23 23:06:28 +01:00
README.md make TTL hop-based 2022-11-26 12:55:48 +01:00
shell.nix use erlang R25 2022-11-25 13:35:06 +01:00

Floof

A simple forwarding + flooding daemon with signature verification

Installation

This package has enacl as a dependency, and thus requires libsodium to be installed in the system/environment. See also the shell.nix for a suitable environment.

If available in Hex, the package can be installed by adding floof to your list of dependencies in mix.exs:

def deps do
  [
    {:floof, "~> 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/floof.

Configuration

The config should be written to config/runtime.exs. Adjust the ip addresses below as appropriate.

upstream

import Config

if config_env() == :prod do
  config :floof, listen_opts: [ip: {192,168,0,1}]
  config :floof, pubkey_config: %{:keydb => ".keydb"}
end

downstream

import Config

if config_env() == :prod do
  config :floof, listen_port: nil
  config :floof, pubkey_config: %{:keydb => ".keydb"}

  config :floof,
    upstreams: [
      {{192, 168, 0, 1}, 2540,
       <<"randomly-generated-session-key">>}
    ]
end

Manually emitting a message

Build a release using mix release. Then run/start the server using _build/prod/rel/floof/bin/floof start.

Log into a running floof process (e.g. using _build/prod/rel/floof/bin/floof remote)

# generate and save a keypair
kp = :enacl.sign_keypair()
:ok = File.write("test01.ed25519k", kp.secret)
source = [
  {:RelativeDistinguishedName, {0, 9, 2342, 19200300, 100, 1, 25}, "de"},
  {:RelativeDistinguishedName, {0, 9, 2342, 19200300, 100, 1, 25}, "ytrizja"},
  {:RelativeDistinguishedName, {0, 9, 2342, 19200300, 100, 1, 9}, "myhost"}
]
{:ok, pkname} = :FloofProtocol.encode(:RDNSequence, source)
# ".keydb" needs to be configured using `config/runtime.exs`
:ok = File.write(".keydb/" <> Base.url_encode64(pkname), kp.public)

# copy the keydb entry to the other participating nodes

# send a message
{:ok, secret} = File.read("test01.ed25519k")
msg_topic = [{:RelativeDistinguishedName, {2, 5, 4, 41}, "test topic"}]
msg_inner = Floof.Message.pack_inner(msg_topic, [], :info, <<0, 0>>)
msg_outer = Floof.Message.build_outer(source, 255, [], secret, msg_inner)
Floof.Message.emit(msg_outer)