Merge pull request 'add support for Udp interface' (#1) from seb/transport-node:udp into main

Reviewed-on: #1
This commit is contained in:
sigil-03 2025-12-02 14:23:35 -07:00
commit b53def2613

View file

@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize};
// RETICULUM INCLUDES
use reticulum::iface::tcp_client::TcpClient;
use reticulum::iface::tcp_server::TcpServer;
use reticulum::iface::udp::UdpInterface;
use reticulum::transport::{Transport, TransportConfig};
#[derive(Serialize, Deserialize, Debug, Clone)]
@ -18,10 +19,17 @@ struct TcpClientConfig {
bind_addr: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
struct UdpConfig {
bind_addr: String,
forward_addr: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
enum InterfaceConfig {
TcpServer(TcpServerConfig),
TcpClient(TcpClientConfig),
Udp(UdpConfig),
}
#[derive(Serialize, Deserialize, Debug, Clone)]
@ -70,6 +78,12 @@ async fn main() {
.await
.spawn(TcpClient::new(cfg.bind_addr), TcpClient::spawn);
}
InterfaceConfig::Udp(cfg) => {
let _ = transport.iface_manager().lock().await.spawn(
UdpInterface::new(cfg.bind_addr, cfg.forward_addr),
UdpInterface::spawn,
);
}
}
}