mirror of
https://github.com/aramperes/onetun.git
synced 2025-09-09 06:38:32 -04:00
cleanup: SockSet can be owned by static
ref: https://github.com/smoltcp-rs/smoltcp/pull/813
This commit is contained in:
parent
83beb48b07
commit
10b88ccc60
2 changed files with 8 additions and 8 deletions
|
@ -21,14 +21,14 @@ use std::{
|
||||||
const MAX_PACKET: usize = 65536;
|
const MAX_PACKET: usize = 65536;
|
||||||
|
|
||||||
/// A virtual interface for proxying Layer 7 data to Layer 3 packets, and vice-versa.
|
/// A virtual interface for proxying Layer 7 data to Layer 3 packets, and vice-versa.
|
||||||
pub struct TcpVirtualInterface<'a> {
|
pub struct TcpVirtualInterface {
|
||||||
source_peer_ip: IpAddr,
|
source_peer_ip: IpAddr,
|
||||||
port_forwards: Vec<PortForwardConfig>,
|
port_forwards: Vec<PortForwardConfig>,
|
||||||
bus: Bus,
|
bus: Bus,
|
||||||
sockets: SocketSet<'a>,
|
sockets: SocketSet<'static>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TcpVirtualInterface<'a> {
|
impl TcpVirtualInterface {
|
||||||
/// Initialize the parameters for a new virtual interface.
|
/// Initialize the parameters for a new virtual interface.
|
||||||
/// Use the `poll_loop()` future to start the virtual interface poll loop.
|
/// Use the `poll_loop()` future to start the virtual interface poll loop.
|
||||||
pub fn new(port_forwards: Vec<PortForwardConfig>, bus: Bus, source_peer_ip: IpAddr) -> Self {
|
pub fn new(port_forwards: Vec<PortForwardConfig>, bus: Bus, source_peer_ip: IpAddr) -> Self {
|
||||||
|
@ -84,7 +84,7 @@ impl<'a> TcpVirtualInterface<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl VirtualInterfacePoll for TcpVirtualInterface<'_> {
|
impl VirtualInterfacePoll for TcpVirtualInterface {
|
||||||
async fn poll_loop(mut self, mut device: VirtualIpDevice) -> anyhow::Result<()> {
|
async fn poll_loop(mut self, mut device: VirtualIpDevice) -> anyhow::Result<()> {
|
||||||
// Create CIDR block for source peer IP + each port forward IP
|
// Create CIDR block for source peer IP + each port forward IP
|
||||||
let addresses = self.addresses();
|
let addresses = self.addresses();
|
||||||
|
|
|
@ -20,14 +20,14 @@ use std::{
|
||||||
|
|
||||||
const MAX_PACKET: usize = 65536;
|
const MAX_PACKET: usize = 65536;
|
||||||
|
|
||||||
pub struct UdpVirtualInterface<'a> {
|
pub struct UdpVirtualInterface {
|
||||||
source_peer_ip: IpAddr,
|
source_peer_ip: IpAddr,
|
||||||
port_forwards: Vec<PortForwardConfig>,
|
port_forwards: Vec<PortForwardConfig>,
|
||||||
bus: Bus,
|
bus: Bus,
|
||||||
sockets: SocketSet<'a>,
|
sockets: SocketSet<'static>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> UdpVirtualInterface<'a> {
|
impl UdpVirtualInterface {
|
||||||
/// Initialize the parameters for a new virtual interface.
|
/// Initialize the parameters for a new virtual interface.
|
||||||
/// Use the `poll_loop()` future to start the virtual interface poll loop.
|
/// Use the `poll_loop()` future to start the virtual interface poll loop.
|
||||||
pub fn new(port_forwards: Vec<PortForwardConfig>, bus: Bus, source_peer_ip: IpAddr) -> Self {
|
pub fn new(port_forwards: Vec<PortForwardConfig>, bus: Bus, source_peer_ip: IpAddr) -> Self {
|
||||||
|
@ -96,7 +96,7 @@ impl<'a> UdpVirtualInterface<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> VirtualInterfacePoll for UdpVirtualInterface<'a> {
|
impl VirtualInterfacePoll for UdpVirtualInterface {
|
||||||
async fn poll_loop(mut self, mut device: VirtualIpDevice) -> anyhow::Result<()> {
|
async fn poll_loop(mut self, mut device: VirtualIpDevice) -> anyhow::Result<()> {
|
||||||
// Create CIDR block for source peer IP + each port forward IP
|
// Create CIDR block for source peer IP + each port forward IP
|
||||||
let addresses = self.addresses();
|
let addresses = self.addresses();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue