Async unbounded fix

modified:   Cargo.lock
	modified:   Cargo.toml
	modified:   src/client.rs
This commit is contained in:
Michael Wain 2024-11-25 19:57:11 +03:00
parent 9f6de14855
commit 23d69ef79f
3 changed files with 7 additions and 7 deletions

2
Cargo.lock generated
View File

@ -1555,13 +1555,13 @@ name = "frida_vpn"
version = "0.1.7" version = "0.1.7"
dependencies = [ dependencies = [
"aes-gcm", "aes-gcm",
"async-channel",
"base64 0.22.1", "base64 0.22.1",
"block-modes", "block-modes",
"block-padding", "block-padding",
"chrono", "chrono",
"clap", "clap",
"console-subscriber", "console-subscriber",
"crossbeam-channel",
"dirs 5.0.1", "dirs 5.0.1",
"embed-resource", "embed-resource",
"env_logger", "env_logger",

View File

@ -37,7 +37,7 @@ env_logger = "0.9"
log = "0.4.20" log = "0.4.20"
futures = "0.3.30" futures = "0.3.30"
packet = "0.1.4" packet = "0.1.4"
crossbeam-channel = "0.5.13" async-channel = "2.3.1"
hex = "0.4" hex = "0.4"
serde_yaml = "0.9.34" serde_yaml = "0.9.34"
x25519-dalek = { version = "2.0.1", features = ["getrandom", "static_secrets"] } x25519-dalek = { version = "2.0.1", features = ["getrandom", "static_secrets"] }

View File

@ -1,7 +1,7 @@
pub mod general { pub mod general {
use crate::config::ClientConfiguration; use crate::config::ClientConfiguration;
use crossbeam_channel::{Receiver, Sender}; use async_channel::{Receiver, Sender};
use futures::{stream::SplitSink, StreamExt}; use futures::{stream::SplitSink, StreamExt};
use tokio_util::{codec::Framed, sync::CancellationToken}; use tokio_util::{codec::Framed, sync::CancellationToken};
use tokio::{net::UdpSocket, sync::{Mutex, mpsc}, io::{AsyncWriteExt, AsyncReadExt}, fs::File}; use tokio::{net::UdpSocket, sync::{Mutex, mpsc}, io::{AsyncWriteExt, AsyncReadExt}, fs::File};
@ -29,7 +29,7 @@ pub mod general {
// TODO: implement custom Error // TODO: implement custom Error
impl ReadWrapper for DevReader { impl ReadWrapper for DevReader {
async fn read(&mut self, buf: &mut Vec<u8>) -> Result<usize, ()> { async fn read(&mut self, buf: &mut Vec<u8>) -> Result<usize, ()> {
if let Ok(tb) = self.dr.recv() { if let Ok(tb) = self.dr.recv().await {
*buf = tb; *buf = tb;
return Ok(buf.len()); return Ok(buf.len());
} }
@ -70,7 +70,7 @@ pub mod general {
match msg { match msg {
WriterMessage::Plain(buf) => { WriterMessage::Plain(buf) => {
let l = buf.len(); let l = buf.len();
if let Ok(()) = self.dr.send(buf) { if let Ok(()) = self.dr.send(buf).await {
return Ok(l); return Ok(l);
} }
Err(()) Err(())
@ -278,7 +278,7 @@ pub mod desktop {
use futures::{SinkExt, StreamExt}; use futures::{SinkExt, StreamExt};
use log::info; use log::info;
use tokio::net::UdpSocket; use tokio::net::UdpSocket;
use crossbeam_channel::unbounded; use async_channel::unbounded;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use network_interface::{NetworkInterface, NetworkInterfaceConfig}; use network_interface::{NetworkInterface, NetworkInterfaceConfig};
@ -388,7 +388,7 @@ pub mod desktop {
tokio::spawn(async move { tokio::spawn(async move {
loop { loop {
if let Ok(buf) = wrx.recv() { if let Ok(buf) = wrx.recv().await {
let _ = dev_writer.send(buf).await; let _ = dev_writer.send(buf).await;
} }
} }