mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-21 06:19:08 +00:00
nix usage
This commit is contained in:
parent
b21d7a6c2c
commit
060474fcc7
3 changed files with 7 additions and 7 deletions
10
Cargo.toml
10
Cargo.toml
|
@ -42,11 +42,6 @@ url = "2"
|
|||
[target.'cfg(target_os="linux")'.dependencies]
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
bincode = "1"
|
||||
nix = { version = "0.29", default-features = false, features = [
|
||||
"fs",
|
||||
"socket",
|
||||
"uio",
|
||||
] }
|
||||
|
||||
[target.'cfg(target_os="android")'.dependencies]
|
||||
android_logger = "0.14"
|
||||
|
@ -54,6 +49,11 @@ jni = { version = "0.21", default-features = false }
|
|||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
daemonize = "0.5"
|
||||
nix = { version = "0.29", default-features = false, features = [
|
||||
"fs",
|
||||
"socket",
|
||||
"uio",
|
||||
] }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
windows-service = "0.7"
|
||||
|
|
|
@ -180,7 +180,7 @@ pub fn parse_udp(udp_mtu: u16, data_len: usize, data: &[u8]) -> Result<(&[u8], u
|
|||
async fn process_udp(addr: SocketAddr, udp_timeout: u64, tx: Sender<Vec<u8>>, con: &mut UdpRequest) -> Result<()> {
|
||||
let std_sock = std::net::UdpSocket::bind("0.0.0.0:0")?;
|
||||
std_sock.set_nonblocking(true)?;
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(unix)]
|
||||
nix::sys::socket::setsockopt(&std_sock, nix::sys::socket::sockopt::ReuseAddr, &true)?;
|
||||
let socket = UdpSocket::from_std(std_sock)?;
|
||||
socket.send_to(&con.data, &con.server_addr).await?;
|
||||
|
|
|
@ -6,7 +6,7 @@ pub enum Error {
|
|||
#[error(transparent)]
|
||||
Io(#[from] std::io::Error),
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(unix)]
|
||||
#[error("nix::errno::Errno {0:?}")]
|
||||
NixErrno(#[from] nix::errno::Errno),
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue