Enum pro outgoing addr and some fixes

This commit is contained in:
Ivan 2024-09-26 19:15:16 +02:00
parent 4bd757173d
commit aec1eeef34
3 changed files with 28 additions and 17 deletions

View file

@ -71,14 +71,14 @@ where
}
pub fn ip_addr(&self) -> Option<IpAddr> {
if let Some(b) = self.ipv4 {
if let Some(ref b) = self.ipv4 {
let b = b.as_slice();
if b.len() == 4 {
let ip_bytes: &[u8; 4] = b[0..4].try_into().unwrap(); // Safe to unwrap as we check slice length
return Some(IpAddr::from(*ip_bytes));
}
}
if let Some(b) = self.ipv6 {
if let Some(ref b) = self.ipv6 {
let b = b.as_slice();
if b.len() == 16 {
let ip_bytes: &[u8; 16] = b[0..16].try_into().unwrap(); // Safe to unwrap as we check slice length