From e7352c7b67436342f116af5595bab9ba9d4a93c8 Mon Sep 17 00:00:00 2001 From: asxalex Date: Fri, 25 Oct 2024 11:24:50 +0800 Subject: [PATCH] fix some warning --- src/network/ipv6.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/network/ipv6.rs b/src/network/ipv6.rs index 900b104..fadb22f 100644 --- a/src/network/ipv6.rs +++ b/src/network/ipv6.rs @@ -1,13 +1,19 @@ -use std::{net::{IpAddr, Ipv6Addr}, time::Duration}; use std::sync::Mutex; +use std::{ + net::{IpAddr, Ipv6Addr}, + time::Duration, +}; use sdlan_sn_rs::{config::AF_INET6, peer::SdlanSock}; +use std::sync::Arc; use tokio::{net::UdpSocket, sync::mpsc::Receiver}; use tokio_util::sync::CancellationToken; use tracing::error; -use std::sync::Arc; -use crate::{network::{loop_socket_v4, loop_socket_v6}, utils::Socket}; +use crate::{ + network::{loop_socket_v4, loop_socket_v6}, + utils::Socket, +}; use super::Node; @@ -37,11 +43,10 @@ pub async fn run_ipv6(edge: &'static Node, mut v6_may_change: Receiver) { let socket_clone = socket.clone(); let cancel = CancellationToken::new(); - *edge.ipv6.write().unwrap() = Some(SdlanSock { family: AF_INET6, port, - v4: [0;4], + v4: [0; 4], v6: ipv6.octets(), }); *edge.udp_sock_v6.write().unwrap() = Some(socket); @@ -61,16 +66,16 @@ pub fn get_current_ipv6() -> Option { error!("failed to get ip address"); return None; }; - + for (_, ip) in ips { match ip { IpAddr::V4(_ipv4) => { continue; } IpAddr::V6(ipv6) => { - if (ipv6.octets()[0] & 0x70 == 0x20) { + if ipv6.octets()[0] & 0x70 == 0x20 { println!("got global ip: {}", ipv6); - return Some(ipv6) + return Some(ipv6); } } }