Serve command #27

Merged
Dreaded_X merged 20 commits from feature/tftp_side into main 2026-10-21 05:15:47 +00:00
2 changed files with 5 additions and 5 deletions
Showing only changes of commit 5a5df6bfc3 - Show all commits
+1 -1
View File
@@ -111,7 +111,7 @@ async fn main() -> Result<(), Error> {
let re = Regex::new(r"talos/(?<cluster>.+)/(?<node>.+)\.ya?ml")
.expect("regex should be valid");
tftp::serve(move |filename| {
tftp::serve(move |filename, _| {
let filename = filename.to_owned();
let re = re.clone();
+4 -4
View File
@@ -1,5 +1,5 @@
use std::io;
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
use std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4};
use std::time::Duration;
use socket_pktinfo::{PktInfo, PktInfoUdpSocket};
@@ -37,7 +37,7 @@ pub async fn handle_connection<F, Fut>(
callback: F,
) -> Result<(), Error>
where
F: Fn(&str) -> Fut,
F: Fn(&str, IpAddr) -> Fut,
Fut: Future<Output = Option<Vec<u8>>>,
{
let src = info.addr_src;
@@ -59,7 +59,7 @@ where
let filename = request.filename();
println!("{src}: {filename} [{:?}]", request.mode());
let Some(data) = callback(filename).await else {
let Some(data) = callback(filename, info.addr_dst).await else {
Packet::error(ErrorCode::FileNotFound, "Unknown file")
.send_to(&socket, &src)
.await?;
@@ -152,7 +152,7 @@ where
pub async fn serve<F, Fut>(callback: F) -> Result<!, Error>
where
F: Fn(&str) -> Fut + Clone + Send + 'static,
F: Fn(&str, IpAddr) -> Fut + Clone + Send + 'static,
Fut: Future<Output = Option<Vec<u8>>> + Send + 'static,
{
let socket = PktInfoUdpSocket::new(Domain::IPV4)?;