mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-02-09 01:59:16 +08:00
fix: missing Read + Write
This commit is contained in:
@@ -9,5 +9,8 @@ cfg_if! {
|
||||
} else if #[cfg(windows)] {
|
||||
mod windows;
|
||||
pub use self::windows::*;
|
||||
} else {
|
||||
mod others;
|
||||
pub use self::others::*;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
//! Other platforms
|
||||
use std::{
|
||||
io::{self, Read, Write},
|
||||
marker::Unpin,
|
||||
};
|
||||
|
||||
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||||
use tun::Device;
|
||||
|
||||
/// Packet Information length in bytes
|
||||
pub const IFF_PI_PREFIX_LEN: usize = 0;
|
||||
|
||||
/// Writing packet with packet information
|
||||
pub async fn write_packet_with_pi<W: AsyncWrite + Unpin>(writer: &mut W, packet: &[u8]) -> io::Result<()> {
|
||||
writer.write_all(packet).await
|
||||
}
|
||||
|
||||
/// Set platform specific route configuration
|
||||
pub async fn set_route_configuration(_: &mut TunDevice) -> io::Result<()> {
|
||||
pub async fn set_route_configuration<Q>(_: &mut (dyn Device<Queue = Q> + Send)) -> io::Result<()>
|
||||
where
|
||||
Q: Read + Write,
|
||||
{
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use std::{io, marker::Unpin};
|
||||
use std::{
|
||||
io::{self, Read, Write},
|
||||
marker::Unpin,
|
||||
};
|
||||
|
||||
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||||
use tun::Device;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::io;
|
||||
use std::io::{self, Read, Write};
|
||||
|
||||
use tun::Device;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
io::{self, ErrorKind, IoSlice},
|
||||
io::{self, ErrorKind, IoSlice, Read, Write},
|
||||
marker::Unpin,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use std::{io, marker::Unpin};
|
||||
use std::{
|
||||
io::{self, Read, Write},
|
||||
marker::Unpin,
|
||||
};
|
||||
|
||||
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||||
use tun::Device;
|
||||
|
||||
@@ -13,5 +13,8 @@ cfg_if! {
|
||||
} else if #[cfg(target_os = "android")] {
|
||||
mod android;
|
||||
pub use self::android::*;
|
||||
} else {
|
||||
mod others;
|
||||
pub use self::others::*;
|
||||
}
|
||||
}
|
||||
|
||||
23
crates/shadowsocks-service/src/local/tun/sys/unix/others.rs
Normal file
23
crates/shadowsocks-service/src/local/tun/sys/unix/others.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use std::{
|
||||
io::{self, Read, Write},
|
||||
marker::Unpin,
|
||||
};
|
||||
|
||||
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||||
use tun::Device;
|
||||
|
||||
/// Packet Information length in bytes
|
||||
pub const IFF_PI_PREFIX_LEN: usize = 0;
|
||||
|
||||
/// Writing packet with packet information
|
||||
pub async fn write_packet_with_pi<W: AsyncWrite + Unpin>(writer: &mut W, packet: &[u8]) -> io::Result<()> {
|
||||
writer.write_all(packet).await
|
||||
}
|
||||
|
||||
/// Set platform specific route configuration
|
||||
pub async fn set_route_configuration<Q>(_: &mut (dyn Device<Queue = Q> + Send)) -> io::Result<()>
|
||||
where
|
||||
Q: Read + Write,
|
||||
{
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
use std::{io, marker::Unpin};
|
||||
use std::{
|
||||
io::{self, Read, Write},
|
||||
marker::Unpin,
|
||||
};
|
||||
|
||||
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||||
use tun::Device;
|
||||
|
||||
Reference in New Issue
Block a user