fix some warning
This commit is contained in:
parent
214e73a0b9
commit
c5b04eb843
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -1,4 +1,4 @@
|
||||
{
|
||||
"rust-analyzer.cargo.target": "x86_64-pc-windows-gnu"
|
||||
// "rust-analyzer.cargo.target": "x86_64-pc-windows-gnu"
|
||||
// "rust-analyzer.cargo.features": ["tun"]
|
||||
}
|
||||
@ -501,7 +501,7 @@ impl Node {
|
||||
encode_to_tcp_message::<SdlEmpty>(None, 0, PacketType::UnRegisterSuper as u8).unwrap();
|
||||
|
||||
let conn = get_tcp_conn();
|
||||
let _ = conn.send(&content).await;
|
||||
let _ = conn.send(content).await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -1143,7 +1143,7 @@ async fn send_query_peer(eee: &Node, dst_mac: Mac) -> Result<()> {
|
||||
return Err(SDLanError::NormalError("encode query error"));
|
||||
};
|
||||
let tcp_conn = get_tcp_conn();
|
||||
tcp_conn.send(&content).await
|
||||
tcp_conn.send(content).await
|
||||
}
|
||||
|
||||
pub async fn ping_to_sn() {
|
||||
@ -1153,7 +1153,7 @@ pub async fn ping_to_sn() {
|
||||
};
|
||||
debug!("ping to sn");
|
||||
let tcp_conn = get_tcp_conn();
|
||||
if let Err(e) = tcp_conn.send(&msg).await {
|
||||
if let Err(e) = tcp_conn.send(msg).await {
|
||||
error!("failed to ping to sn: {:?}", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
use myactor::{ActorError, SupervisedActor};
|
||||
use once_cell::sync::OnceCell;
|
||||
use prost::Message;
|
||||
use sdlan_sn_rs::config::AF_INET;
|
||||
use sdlan_sn_rs::peer::{SdlanSock, V6Info};
|
||||
use sdlan_sn_rs::utils::{Result, SDLanError, get_current_timestamp, ip_to_string, rsa_decrypt};
|
||||
use std::future::Future;
|
||||
use std::net::IpAddr;
|
||||
use std::process::Output;
|
||||
use std::sync::atomic::AtomicU64;
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
@ -342,6 +341,7 @@ async fn on_connected_callback<'a>(stream: &'a mut tokio::net::TcpStream, pkt_id
|
||||
error!("failed to write to tcp: {}", e.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ReadWriteActor {
|
||||
// actor接收的发送给tcp的接收端,由handle存放发送端
|
||||
// to_tcp: Receiver<Vec<u8>>,
|
||||
@ -350,7 +350,7 @@ pub struct ReadWriteActor {
|
||||
pong_time: Arc<AtomicU64>,
|
||||
// actor收到数据之后,发送给上层的发送端口,接收端由handle保存
|
||||
from_tcp: Sender<SdlanTcp>,
|
||||
cancel: CancellationToken,
|
||||
_cancel: CancellationToken,
|
||||
connecting_chan: Option<Sender<ConnectionInfo>>,
|
||||
ipv6_network_restarter: Option<Sender<bool>>,
|
||||
}
|
||||
@ -367,7 +367,7 @@ impl ReadWriteActor {
|
||||
) -> Self {
|
||||
Self {
|
||||
// to_tcp,
|
||||
cancel,
|
||||
_cancel: cancel,
|
||||
pong_time,
|
||||
connected,
|
||||
remote: remote.to_owned(),
|
||||
@ -381,17 +381,8 @@ impl ReadWriteActor {
|
||||
&self,
|
||||
keep_reconnect: bool,
|
||||
mut to_tcp: Receiver<Vec<u8>>,
|
||||
// on_connected: OnConnectedCallback<'_>,
|
||||
// on_disconnected: T2,
|
||||
mut start_stop_chan: Receiver<StartStopInfo>,
|
||||
// cancel: CancellationToken,
|
||||
) where
|
||||
// T: Fn(&mut TcpStream, Option<u32>) -> F2,
|
||||
// T2: Fn() -> F,
|
||||
// F: Future<Output = ()>,
|
||||
// F2: Future<Output = ()>,
|
||||
{
|
||||
// let (tx, rx) = channel(20);
|
||||
) {
|
||||
let mut started = false;
|
||||
let mut start_pkt_id = None;
|
||||
loop {
|
||||
@ -441,13 +432,6 @@ impl ReadWriteActor {
|
||||
let Ok(mut stream) = TcpStream::connect(&self.remote).await else {
|
||||
self.connected.store(false, Ordering::Relaxed);
|
||||
if keep_reconnect {
|
||||
/*
|
||||
tokio::select! {
|
||||
_ = tokio::time::sleep(Duration::from_secs(3)) => {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
*/
|
||||
tokio::time::sleep(Duration::from_secs(3)).await;
|
||||
continue;
|
||||
}
|
||||
@ -558,10 +542,10 @@ pub struct ReadWriterHandle {
|
||||
}
|
||||
|
||||
impl ReadWriterHandle {
|
||||
pub async fn send(&self, data: &[u8]) -> Result<()> {
|
||||
pub async fn send(&self, data: Vec<u8>) -> Result<()> {
|
||||
if self.connected.load(Ordering::Relaxed) {
|
||||
// connected, send to it
|
||||
if let Err(e) = self.send_to_tcp.send(Vec::from(data)).await {
|
||||
if let Err(e) = self.send_to_tcp.send(data).await {
|
||||
error!("failed to send to send_to_tcp: {}", e.to_string());
|
||||
return Err(SDLanError::NormalError("failed to send"));
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user