mirror of
https://github.com/aramperes/onetun.git
synced 2025-09-07 11:38:30 -04:00
chore: udpate to smoltcp 0.12
This commit is contained in:
parent
ca3590a4c0
commit
0e93a6435a
6 changed files with 13 additions and 11 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1025,9 +1025,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
|||
|
||||
[[package]]
|
||||
name = "smoltcp"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a1a996951e50b5971a2c8c0fa05a381480d70a933064245c4a223ddc87ccc97"
|
||||
checksum = "dad095989c1533c1c266d9b1e8d70a1329dd3723c3edac6d03bbd67e7bf6f4bb"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"byteorder",
|
||||
|
|
|
@ -20,7 +20,7 @@ rand = "0.8"
|
|||
nom = "7"
|
||||
async-trait = "0.1"
|
||||
priority-queue = "1.3"
|
||||
smoltcp = { version = "0.11", default-features = false, features = [
|
||||
smoltcp = { version = "0.12", default-features = false, features = [
|
||||
"std",
|
||||
"log",
|
||||
"medium-ip",
|
||||
|
|
|
@ -109,11 +109,11 @@ pub struct RxToken {
|
|||
}
|
||||
|
||||
impl smoltcp::phy::RxToken for RxToken {
|
||||
fn consume<R, F>(mut self, f: F) -> R
|
||||
fn consume<R, F>(self, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&mut [u8]) -> R,
|
||||
F: FnOnce(&[u8]) -> R,
|
||||
{
|
||||
f(&mut self.buffer)
|
||||
f(&self.buffer)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use crate::Bus;
|
|||
use anyhow::Context;
|
||||
use async_trait::async_trait;
|
||||
use bytes::Bytes;
|
||||
use smoltcp::iface::PollResult;
|
||||
use smoltcp::{
|
||||
iface::{Config, Interface, SocketHandle, SocketSet},
|
||||
socket::tcp,
|
||||
|
@ -141,7 +142,7 @@ impl VirtualInterfacePoll for TcpVirtualInterface {
|
|||
}
|
||||
});
|
||||
|
||||
if iface.poll(loop_start, &mut device, &mut self.sockets) {
|
||||
if iface.poll(loop_start, &mut device, &mut self.sockets) == PollResult::SocketStateChanged {
|
||||
log::trace!("TCP virtual interface polled some packets to be processed");
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use crate::{Bus, PortProtocol};
|
|||
use anyhow::Context;
|
||||
use async_trait::async_trait;
|
||||
use bytes::Bytes;
|
||||
use smoltcp::iface::PollResult;
|
||||
use smoltcp::{
|
||||
iface::{Config, Interface, SocketHandle, SocketSet},
|
||||
socket::udp::{self, UdpMetadata},
|
||||
|
@ -140,7 +141,7 @@ impl VirtualInterfacePoll for UdpVirtualInterface {
|
|||
} => {
|
||||
let loop_start = smoltcp::time::Instant::now();
|
||||
|
||||
if iface.poll(loop_start, &mut device, &mut self.sockets) {
|
||||
if iface.poll(loop_start, &mut device, &mut self.sockets) == PollResult::SocketStateChanged {
|
||||
log::trace!("UDP virtual interface polled some packets to be processed");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::Bus;
|
||||
|
@ -253,7 +253,7 @@ impl WireGuardTunnel {
|
|||
Ok(IpVersion::Ipv4) => Ipv4Packet::new_checked(&packet)
|
||||
.ok()
|
||||
// Only care if the packet is destined for this tunnel
|
||||
.filter(|packet| Ipv4Addr::from(packet.dst_addr()) == self.source_peer_ip)
|
||||
.filter(|packet| packet.dst_addr() == self.source_peer_ip)
|
||||
.and_then(|packet| match packet.next_header() {
|
||||
IpProtocol::Tcp => Some(PortProtocol::Tcp),
|
||||
IpProtocol::Udp => Some(PortProtocol::Udp),
|
||||
|
@ -263,7 +263,7 @@ impl WireGuardTunnel {
|
|||
Ok(IpVersion::Ipv6) => Ipv6Packet::new_checked(&packet)
|
||||
.ok()
|
||||
// Only care if the packet is destined for this tunnel
|
||||
.filter(|packet| Ipv6Addr::from(packet.dst_addr()) == self.source_peer_ip)
|
||||
.filter(|packet| packet.dst_addr() == self.source_peer_ip)
|
||||
.and_then(|packet| match packet.next_header() {
|
||||
IpProtocol::Tcp => Some(PortProtocol::Tcp),
|
||||
IpProtocol::Udp => Some(PortProtocol::Udp),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue