mirror of
https://github.com/aramperes/onetun.git
synced 2025-09-09 12:18:31 -04:00
bugfix: Pass IP version when routing incoming TCP segment
This commit is contained in:
parent
f32f205cb3
commit
7132841876
1 changed files with 4 additions and 1 deletions
|
@ -251,6 +251,7 @@ impl WireGuardTunnel {
|
||||||
.map(|packet| match packet.protocol() {
|
.map(|packet| match packet.protocol() {
|
||||||
IpProtocol::Tcp => Some(
|
IpProtocol::Tcp => Some(
|
||||||
self.route_tcp_segment(
|
self.route_tcp_segment(
|
||||||
|
IpVersion::Ipv4,
|
||||||
packet.src_addr().into(),
|
packet.src_addr().into(),
|
||||||
packet.dst_addr().into(),
|
packet.dst_addr().into(),
|
||||||
packet.payload(),
|
packet.payload(),
|
||||||
|
@ -269,6 +270,7 @@ impl WireGuardTunnel {
|
||||||
.filter(|packet| Ipv6Addr::from(packet.dst_addr()) == self.source_peer_ip)
|
.filter(|packet| Ipv6Addr::from(packet.dst_addr()) == self.source_peer_ip)
|
||||||
.map(|packet| {
|
.map(|packet| {
|
||||||
self.route_tcp_segment(
|
self.route_tcp_segment(
|
||||||
|
IpVersion::Ipv6,
|
||||||
packet.src_addr().into(),
|
packet.src_addr().into(),
|
||||||
packet.dst_addr().into(),
|
packet.dst_addr().into(),
|
||||||
packet.payload(),
|
packet.payload(),
|
||||||
|
@ -286,6 +288,7 @@ impl WireGuardTunnel {
|
||||||
/// When the given segment is an invalid TCP packet, it returns `None`.
|
/// When the given segment is an invalid TCP packet, it returns `None`.
|
||||||
fn route_tcp_segment(
|
fn route_tcp_segment(
|
||||||
&self,
|
&self,
|
||||||
|
ip_version: IpVersion,
|
||||||
src_addr: IpAddress,
|
src_addr: IpAddress,
|
||||||
dst_addr: IpAddress,
|
dst_addr: IpAddress,
|
||||||
segment: &[u8],
|
segment: &[u8],
|
||||||
|
@ -298,7 +301,7 @@ impl WireGuardTunnel {
|
||||||
} else {
|
} else {
|
||||||
// Port is not in use, but it's a TCP packet so we'll craft a RST.
|
// Port is not in use, but it's a TCP packet so we'll craft a RST.
|
||||||
RouteResult::TcpReset(craft_tcp_rst_reply(
|
RouteResult::TcpReset(craft_tcp_rst_reply(
|
||||||
IpVersion::Ipv4,
|
ip_version,
|
||||||
src_addr,
|
src_addr,
|
||||||
tcp.src_port(),
|
tcp.src_port(),
|
||||||
dst_addr,
|
dst_addr,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue