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
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-2.0-only
/// Error type for all fallible smolmix operations.
pub use SmolmixError;
/// The IPv4/IPv6 address pair allocated to this tunnel by the IPR.
pub use IpPair;
/// A Nym mixnet address, used to target a specific IPR exit node.
pub use Recipient;
/// A TCP stream routed through the mixnet. Implements `AsyncRead + AsyncWrite`.
///
/// Obtained via [`Tunnel::tcp_connect`]. Works as a drop-in replacement for
/// `tokio::net::TcpStream` with tokio-rustls, hyper, tokio-tungstenite, etc.
///
/// ```no_run
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
/// # let tunnel = smolmix::Tunnel::new().await?;
/// use tokio::io::{AsyncReadExt, AsyncWriteExt};
///
/// let mut stream = tunnel.tcp_connect("1.1.1.1:80".parse()?).await?;
/// stream.write_all(b"GET / HTTP/1.1\r\nHost: 1.1.1.1\r\nConnection: close\r\n\r\n").await?;
/// let mut buf = Vec::new();
/// stream.read_to_end(&mut buf).await?;
/// # Ok(())
/// # }
/// ```
pub use TcpStream;
/// A mixnet tunnel providing TCP and UDP socket access.
pub use Tunnel;
/// Builder for configuring and creating a [`Tunnel`].
///
/// See [`Tunnel::builder()`] for usage.
pub use TunnelBuilder;
/// A UDP socket routed through the mixnet. Supports `send_to` / `recv_from`.
///
/// Obtained via [`Tunnel::udp_socket`] or [`Tunnel::udp_socket_on`].
///
/// ```no_run
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
/// # let tunnel = smolmix::Tunnel::new().await?;
/// let udp = tunnel.udp_socket().await?;
/// udp.send_to(b"hello", "1.1.1.1:9999".parse()?).await?;
///
/// let mut buf = [0u8; 1024];
/// let (len, _src) = udp.recv_from(&mut buf).await?;
/// # Ok(())
/// # }
/// ```
pub use UdpSocket;