Name update

This commit is contained in:
Miles Ward
2026-05-06 14:13:38 -04:00
parent e1b7154b51
commit 20c585e3ed
56 changed files with 755 additions and 802 deletions
+13 -13
View File
@@ -7,12 +7,12 @@
//! `tftpd`/`in.tftpd` works and is why TFTP is awkward behind stateful NAT:
//! the ephemeral ports must be reachable from the client.
//!
//! We only serve files from `pxeforge_ipxe_assets::asset_bytes` — that is,
//! We only serve files from `openpxe_ipxe_assets::asset_bytes` — that is,
//! the bundled iPXE binaries and wimboot. No filesystem is ever opened, so
//! `../` path traversal attempts simply return ENOENT.
use pxeforge_core::{ClientEvent, ClientRegistry};
use pxeforge_ipxe_assets::asset_bytes;
use openpxe_core::{ClientEvent, ClientRegistry};
use openpxe_ipxe_assets::asset_bytes;
use socket2::{Domain, Protocol, Socket, Type};
use std::net::{IpAddr, SocketAddr};
use std::sync::Arc;
@@ -35,7 +35,7 @@ pub struct TftpServer {
bind: IpAddr,
port: u16,
clients: Arc<ClientRegistry>,
metrics: pxeforge_core::Metrics,
metrics: openpxe_core::Metrics,
}
impl TftpServer {
@@ -43,14 +43,14 @@ impl TftpServer {
bind: IpAddr,
port: u16,
clients: Arc<ClientRegistry>,
metrics: pxeforge_core::Metrics,
metrics: openpxe_core::Metrics,
) -> Self {
Self { bind, port, clients, metrics }
}
pub async fn run(self) -> anyhow::Result<()> {
let sock = bind_udp(self.bind, self.port)?;
tracing::info!(target: "pxeforge::tftp", "TFTP listening on {}:{}", self.bind, self.port);
tracing::info!(target: "openpxe::tftp", "TFTP listening on {}:{}", self.bind, self.port);
let clients = self.clients.clone();
let metrics = self.metrics.clone();
let mut buf = vec![0u8; 2048];
@@ -58,7 +58,7 @@ impl TftpServer {
let (n, from) = match sock.recv_from(&mut buf).await {
Ok(v) => v,
Err(e) => {
tracing::warn!(target: "pxeforge::tftp", "recv error: {e}");
tracing::warn!(target: "openpxe::tftp", "recv error: {e}");
continue;
}
};
@@ -69,7 +69,7 @@ impl TftpServer {
tokio::spawn(async move {
if let Err(e) = handle_rrq(data, from, bind_ip, clients, metrics.clone()).await {
metrics.record_tftp_err();
tracing::warn!(target: "pxeforge::tftp", peer=%from, "handler error: {e}");
tracing::warn!(target: "openpxe::tftp", peer=%from, "handler error: {e}");
}
});
}
@@ -81,7 +81,7 @@ async fn handle_rrq(
peer: SocketAddr,
bind_ip: IpAddr,
clients: Arc<ClientRegistry>,
metrics: pxeforge_core::Metrics,
metrics: openpxe_core::Metrics,
) -> anyhow::Result<()> {
let Some(req) = parse_rrq(&packet) else {
return Ok(());
@@ -93,7 +93,7 @@ async fn handle_rrq(
let Some(file_bytes) = asset_bytes(&filename) else {
let _ = send_error(&sock, peer, ERR_FILE_NOT_FOUND, "no such file").await;
tracing::info!(target: "pxeforge::tftp", peer=%peer, file=%filename, "404");
tracing::info!(target: "openpxe::tftp", peer=%peer, file=%filename, "404");
clients.record(
&peer.ip().to_string(),
Some(peer.ip()),
@@ -104,7 +104,7 @@ async fn handle_rrq(
};
tracing::info!(
target: "pxeforge::tftp",
target: "openpxe::tftp",
peer=%peer, file=%filename, size=file_bytes.len(),
"serving"
);
@@ -200,7 +200,7 @@ async fn handle_rrq(
tries += 1;
if tries > 5 {
tracing::warn!(
target: "pxeforge::tftp",
target: "openpxe::tftp",
peer=%peer, last_block=last_block_in_window,
"timeout after {tries} retries, aborting transfer"
);
@@ -241,7 +241,7 @@ async fn handle_rrq(
let _ = tokio::time::timeout(Duration::from_secs(3), recv_ack(&sock, peer)).await;
}
tracing::debug!(target: "pxeforge::tftp", peer=%peer, bytes=total, "transfer complete");
tracing::debug!(target: "openpxe::tftp", peer=%peer, bytes=total, "transfer complete");
metrics.record_tftp_ok(total as u64);
Ok(())
}