-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
crates/shadowsocks-service/src/local/tun/sys/unix/apple/others.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use std::io; | ||
use std::io::{self, Read, Write}; | ||
|
||
use tun::Device; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
use std::{ | ||
io::{self, ErrorKind, IoSlice}, | ||
io::{self, ErrorKind, IoSlice, Read, Write}, | ||
marker::Unpin, | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
crates/shadowsocks-service/src/local/tun/sys/unix/others.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters