mirror of
https://github.com/aramperes/onetun.git
synced 2025-09-08 23:58:31 -04:00
remove AnyIP; fix IPv6 virtual addresses
This commit is contained in:
parent
38fc217a29
commit
488a0e0807
2 changed files with 18 additions and 4 deletions
|
@ -10,7 +10,7 @@ use smoltcp::{
|
|||
iface::{Config, Interface, SocketHandle, SocketSet},
|
||||
socket::tcp,
|
||||
time::Instant,
|
||||
wire::{HardwareAddress, IpAddress, IpCidr},
|
||||
wire::{HardwareAddress, IpAddress, IpCidr, IpVersion},
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet, VecDeque},
|
||||
|
@ -78,7 +78,7 @@ impl<'a> TcpVirtualInterface<'a> {
|
|||
}
|
||||
addresses
|
||||
.into_iter()
|
||||
.map(|addr| IpCidr::new(addr, 32))
|
||||
.map(|addr| IpCidr::new(addr, addr_length(&addr)))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
@ -249,3 +249,10 @@ impl VirtualInterfacePoll for TcpVirtualInterface<'_> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fn addr_length(addr: &IpAddress) -> u8 {
|
||||
match addr.version() {
|
||||
IpVersion::Ipv4 => 32,
|
||||
IpVersion::Ipv6 => 128,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use smoltcp::{
|
|||
iface::{Config, Interface, SocketHandle, SocketSet},
|
||||
socket::udp::{self, UdpMetadata},
|
||||
time::Instant,
|
||||
wire::{HardwareAddress, IpAddress, IpCidr},
|
||||
wire::{HardwareAddress, IpAddress, IpCidr, IpVersion},
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet, VecDeque},
|
||||
|
@ -90,7 +90,7 @@ impl<'a> UdpVirtualInterface<'a> {
|
|||
}
|
||||
addresses
|
||||
.into_iter()
|
||||
.map(|addr| IpCidr::new(addr, 32))
|
||||
.map(|addr| IpCidr::new(addr, addr_length(&addr)))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
@ -219,3 +219,10 @@ impl<'a> VirtualInterfacePoll for UdpVirtualInterface<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fn addr_length(addr: &IpAddress) -> u8 {
|
||||
match addr.version() {
|
||||
IpVersion::Ipv4 => 32,
|
||||
IpVersion::Ipv6 => 128,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue