Distributed Erlang over iroh P2P + TLS, with a bot powers SDK
1//! # erl_iroh
2//!
3//! Distributed Erlang over [iroh](https://iroh.computer) P2P (QUIC + TLS) and
4//! optional classic TCP/TLS, with a small **bot powers** SDK.
5//!
6//! ## Architecture
7//!
8//! ```text
9//! Bot SDK (powers: rpc, send, introspect, cluster, …)
10//! │
11//! Session ── erl_dist handshake + message channel + net ticks
12//! │
13//! Transport
14//! ├─ iroh (public-key dialing, holepunch, built-in TLS)
15//! ├─ tcp (plain, for local / EPMD peers)
16//! └─ tls (TCP + rustls mTLS for the security pedants)
17//! ```
18//!
19//! ## Quick start (bot)
20//!
21//! ```no_run
22//! use erl_iroh::{Bot, Powers};
23//!
24//! # async fn demo() -> erl_iroh::Result<()> {
25//! let bot = Bot::builder("scout")
26//! .cookie("super-secret-cookie")
27//! .powers(Powers::all()) // bitflags: every defined power
28//! .build()
29//! .await?;
30//!
31//! println!("iroh endpoint id: {}", bot.endpoint_id());
32//!
33//! // Dial another bot by iroh EndpointId (base32)
34//! // bot.connect_iroh("…endpoint id…").await?;
35//!
36//! // Or classic BEAM over TLS
37//! // bot.connect_tls("app@host", "cookie", tls_config).await?;
38//! # Ok(())
39//! # }
40//! ```
41
42#![warn(missing_docs)]
43
44pub mod bot;
45pub mod error;
46pub mod powers;
47pub mod session;
48pub mod stream;
49pub mod term;
50pub mod transport;
51
52pub use bot::{Bot, BotBuilder};
53pub use error::{Error, Result};
54pub use powers::Powers;
55pub use session::Session;
56pub use transport::tls::TlsConfig;
57
58/// ALPN identifier for Erlang distribution over iroh.
59///
60/// Both peers must advertise this ALPN for the connection to be accepted.
61pub const ALPN: &[u8] = b"erl-iroh/1";
62
63/// Re-exports of useful `erl_dist` / ETF types.
64pub mod dist {
65 pub use erl_dist::handshake::{ClientSideHandshake, HandshakeStatus, ServerSideHandshake};
66 pub use erl_dist::message::{self, Message};
67 pub use erl_dist::node::{Creation, LocalNode, NodeName, PeerNode};
68 pub use erl_dist::term::{self, Atom, FixInteger, List, Pid, Reference, Term};
69 pub use erl_dist::{
70 DistributionFlags, HIGHEST_DISTRIBUTION_PROTOCOL_VERSION,
71 LOWEST_DISTRIBUTION_PROTOCOL_VERSION,
72 };
73}