erbridge_core/lib.rs
1//! TCP/UDP port forwarding and reverse tunnels, usable as a library.
2//!
3//! Embedding the `connect` role of a reverse tunnel, with a way to stop it
4//! and to observe what it is doing:
5//!
6//! ```no_run
7//! use erbridge_core::config::{ConnectConfig, ConnectTunnel};
8//! use erbridge_core::reverse::connect::run_connect_with_shutdown;
9//! use erbridge_core::stats::{Event, Registry};
10//! use tokio_util::sync::CancellationToken;
11//!
12//! # async fn demo() -> anyhow::Result<()> {
13//! let cfg = ConnectConfig {
14//! server: "relay.example.com:9000".into(),
15//! token: "secret".into(),
16//! tunnel: vec![ConnectTunnel {
17//! name: "web".into(),
18//! target: "127.0.0.1:8080".into(),
19//! }],
20//! reconnect_min_secs: 1,
21//! reconnect_max_secs: 30,
22//! };
23//!
24//! let registry = Registry::new();
25//! let mut events = registry.subscribe();
26//! let shutdown = CancellationToken::new();
27//! let task = tokio::spawn(run_connect_with_shutdown(cfg, registry, shutdown.clone()));
28//!
29//! while let Ok(event) = events.recv().await {
30//! if let Event::Error { message } = event {
31//! eprintln!("tunnel: {message}");
32//! }
33//! }
34//!
35//! shutdown.cancel();
36//! task.await??;
37//! # Ok(())
38//! # }
39//! ```
40//!
41//! The command-line interface and terminal UI are in the separate `erbridge`
42//! crate, so depending on this one pulls in neither.
43
44pub mod client;
45pub mod config;
46pub mod forward;
47#[doc(hidden)]
48pub mod mux;
49#[doc(hidden)]
50pub mod noise;
51#[doc(hidden)]
52pub mod proxy;
53pub mod reverse;
54pub mod sni;
55pub mod stats;
56pub mod tenant;
57pub mod tenant_store;
58#[doc(hidden)]
59pub mod tls;