fix: Destination ports used in network traffic

This commit is contained in:
Andrew Rioux
2024-02-08 19:03:28 -05:00
parent 607fb72e65
commit 93754e2cba
4 changed files with 7 additions and 4 deletions

View File

@@ -40,6 +40,7 @@ struct ConnectionInformation {
srcip: Ipv4Addr,
dstip: Ipv4Addr,
srcport: u16,
listen_port: u16,
packet_sender: Sender<EthernetPacket>,
}
@@ -47,7 +48,7 @@ impl ConnectionInformation {
fn format_udp_packet(&self, data: &[u8]) -> EthernetPacket {
use packets::*;
let udp_packet = UDPPacket::construct(54248, self.srcport, data);
let udp_packet = UDPPacket::construct(self.listen_port, self.srcport, data);
let ip_packet =
IPv4Packet::construct(self.dstip, self.srcip, &Layer4Packet::UDP(udp_packet));
EthernetPacket::construct(self.dstmac, self.srcmac, &Layer3Packet::IPv4(ip_packet))
@@ -147,6 +148,7 @@ pub fn spawn_connection_handler(
srcip: ip_pkt.source_ip(),
dstip: ip_pkt.dest_ip(),
srcport: udp_pkt.srcport(),
listen_port: udp_pkt.dstport(),
packet_sender,
}
};

View File

@@ -2,7 +2,7 @@ use std::{
collections::HashMap,
net::Ipv4Addr,
sync::{mpsc::channel, Arc, Mutex},
thread, ffi::OsString,
thread,
};
use anyhow::{bail, Context};