fix: Destination ports used in network traffic
This commit is contained in:
@@ -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,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::{
|
||||
collections::HashMap,
|
||||
net::Ipv4Addr,
|
||||
sync::{mpsc::channel, Arc, Mutex},
|
||||
thread, ffi::OsString,
|
||||
thread,
|
||||
};
|
||||
|
||||
use anyhow::{bail, Context};
|
||||
|
||||
Reference in New Issue
Block a user