1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Copyright 2025 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
//! Nym Transport Bridges library.
//!
//! This crate provides the transport and configuration primitives used by Nym bridge runners and
//! tooling.
//!
//! The primary responsibilities are:
//! - server-side transport configuration for QUIC and TLS listeners,
//! - client-side transport parameters derived from server configuration,
//! - forwarding/session/connection building blocks for bridge implementations.
//!
//! The repository binaries (for example, `nym-bridge` and `bridge-cfg`) use this crate as their
//! shared core.
//!
//! # Shared Types Crate
//!
//! This crate re-exports [`nym-bridges-types`](https://docs.rs/nym-bridges-types) as [`types`].
//!
//! These shared types can be consumed directly when integrating across crates or language bindings.
//!
//! # Example: Simple Client Connection Establishment
//!
//! ```rust no_run
//! # #[tokio::main]
//! # async fn main() -> Result<(),anyhow::Error>{
//! use anyhow::anyhow;
//! use nym_bridges::connection::{BridgeConn, SOCKET_OPEN_NOP};
//! use nym_bridges::config::parse_persisted_config_json;
//! use nym_bridges::forward::UdpForwarder;
//! use tokio_util::sync::CancellationToken;
//!
//! let client_config_str = r#"{"version":"0","transports":[{"transport_type":"quic_plain","args":{"addresses":["139.162.33.226:4443","[2400:8901::2000:faff:fea6:87f2]:4443"],"host":"netdna.bootstrapcdn.com","id_pubkey":"9JC91ZiszhIn3n4FG+MDYE/lYwhGdpHGWQTKUqGl+sE="}}]}"#;
//! let shutdown_token = CancellationToken::new();
//! let entry_bridge_params = parse_persisted_config_json(client_config_str)?;
//! let transport_params = entry_bridge_params
//! .transports
//! .first()
//! .ok_or(anyhow!("no config provided"))?;
//!
//! let bridge_conn = BridgeConn::try_connect(
//! transport_params.clone(),
//! shutdown_token.clone(),
//! #[cfg(any(target_os = "linux", target_os = "android"))]
//! SOCKET_OPEN_NOP,
//! )
//! .await?;
//!
//! let remote_addr = bridge_conn.endpoint();
//! let (listen_addr, join_handle) = UdpForwarder::launch_initiator(
//! bridge_conn,
//! None,
//! None,
//! shutdown_token.clone(),
//! )
//! .await?;
//!
//! # Ok::<(), anyhow::Error>(())
//! # }
//! ```
//!
//! # Example: Parse and Convert Configuration
//!
//! ```
//! use nym_bridges::config::PersistedServerConfig;
//! use nym_bridges::types::PersistedClientConfig;
//!
//! let server_toml = r#"
//! public_ips = ["192.168.0.1", "fe80::1"]
//!
//! [forward]
//! address = "[::1]:51822"
//!
//! [[transports]]
//! transport_type = "quic_plain"
//!
//! [transports.args]
//! stateless_retry = false
//! listen = "[::]:4443"
//! identity_key = "fditK5JfNM/88mLWd3ccbLasSrHA5dw1wj+/+1bfGWk="
//! "#;
//!
//! let server_cfg = PersistedServerConfig::parse(server_toml)?;
//! let client_cfg = PersistedClientConfig::try_from(&server_cfg)?;
//! assert_eq!(client_cfg.version, "0");
//! # Ok::<(), anyhow::Error>(())
//! ```
/// Persisted server/client configuration types and conversion from server transport config to
/// client connection parameters.
/// Runtime components for creating connections over configured transports.
/// Crate-specific error types.
/// Runtime components for forwarding client traffic over established transport connections.
/// Stored state and config for established connection.
/// Protocol-specific transport implementations.
// mod stats;
pub use nym_bridges_types as types;
pub