fix some warning
This commit is contained in:
parent
c4c1f109b1
commit
e7352c7b67
@ -1,13 +1,19 @@
|
|||||||
use std::{net::{IpAddr, Ipv6Addr}, time::Duration};
|
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
use std::{
|
||||||
|
net::{IpAddr, Ipv6Addr},
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
use sdlan_sn_rs::{config::AF_INET6, peer::SdlanSock};
|
use sdlan_sn_rs::{config::AF_INET6, peer::SdlanSock};
|
||||||
|
use std::sync::Arc;
|
||||||
use tokio::{net::UdpSocket, sync::mpsc::Receiver};
|
use tokio::{net::UdpSocket, sync::mpsc::Receiver};
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
use tracing::error;
|
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;
|
use super::Node;
|
||||||
|
|
||||||
@ -37,11 +43,10 @@ pub async fn run_ipv6(edge: &'static Node, mut v6_may_change: Receiver<bool>) {
|
|||||||
let socket_clone = socket.clone();
|
let socket_clone = socket.clone();
|
||||||
let cancel = CancellationToken::new();
|
let cancel = CancellationToken::new();
|
||||||
|
|
||||||
|
|
||||||
*edge.ipv6.write().unwrap() = Some(SdlanSock {
|
*edge.ipv6.write().unwrap() = Some(SdlanSock {
|
||||||
family: AF_INET6,
|
family: AF_INET6,
|
||||||
port,
|
port,
|
||||||
v4: [0;4],
|
v4: [0; 4],
|
||||||
v6: ipv6.octets(),
|
v6: ipv6.octets(),
|
||||||
});
|
});
|
||||||
*edge.udp_sock_v6.write().unwrap() = Some(socket);
|
*edge.udp_sock_v6.write().unwrap() = Some(socket);
|
||||||
@ -61,16 +66,16 @@ pub fn get_current_ipv6() -> Option<Ipv6Addr> {
|
|||||||
error!("failed to get ip address");
|
error!("failed to get ip address");
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (_, ip) in ips {
|
for (_, ip) in ips {
|
||||||
match ip {
|
match ip {
|
||||||
IpAddr::V4(_ipv4) => {
|
IpAddr::V4(_ipv4) => {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IpAddr::V6(ipv6) => {
|
IpAddr::V6(ipv6) => {
|
||||||
if (ipv6.octets()[0] & 0x70 == 0x20) {
|
if ipv6.octets()[0] & 0x70 == 0x20 {
|
||||||
println!("got global ip: {}", ipv6);
|
println!("got global ip: {}", ipv6);
|
||||||
return Some(ipv6)
|
return Some(ipv6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user