feat: added command response

This commit is contained in:
Andrew Rioux 2023-04-28 17:30:17 -04:00
parent 9e893dbce9
commit 40d105b043

View File

@ -135,6 +135,18 @@ async fn handle_command(
Output::Err => stderr_buffer,
Output::Out => stdout_buffer
}[..len];
let port = match out_type {
Output::Err => 54249,
Output::Out => 54248
};
let udp_packet = UDPPacket::construct(54248, port, msg);
let ip_packet = IPv4Packet::construct(ip_pkt.dest_ip(), ip_pkt.source_ip(), &Layer4Packet::UDP(udp_packet));
let eth_packet = EthernetPacket::construct(*eth_pkt.destination_address(), *eth_pkt.source_address(), &Layer3Packet::IPv4(ip_packet));
if let Err(e) = send_response.send(eth_packet).await {
log::warn!("Could not send response packet: {e:?}");
}
}
log::info!("Done executing command {cmd:?}");