Skip to content

Commit

Permalink
fixed local-redir compatibility build on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Apr 15, 2021
1 parent 67179c1 commit 1d3e6b7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
4 changes: 3 additions & 1 deletion crates/shadowsocks-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos", target_os = "ios"))]
use std::ffi::OsString;
#[cfg(any(unix, target_os = "android", feature = "local-flow-stat"))]
use std::path::PathBuf;
use std::{
convert::{From, Infallible},
default::Default,
Expand All @@ -51,7 +53,7 @@ use std::{
io::Read,
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6},
option::Option,
path::{Path, PathBuf},
path::Path,
str::FromStr,
string::ToString,
time::Duration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl UdpRedirSocket {
}

/// Send data to the socket to the given target address
pub async fn send_to(&mut self, buf: &[u8], target: SocketAddr) -> io::Result<usize> {
pub async fn send_to(&self, buf: &[u8], target: SocketAddr) -> io::Result<usize> {
poll_fn(|cx| self.poll_send_to(cx, buf, target)).await
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
use std::{io, net::SocketAddr};
use std::{
io,
net::SocketAddr,
task::{Context, Poll},
};

use crate::{config::RedirType, local::redir::redir_ext::UdpSocketRedir};
use crate::{
config::RedirType,
local::redir::redir_ext::{RedirSocketOpts, UdpSocketRedir},
};

pub struct UdpRedirSocket;

Expand All @@ -15,7 +22,7 @@ impl UdpRedirSocket {
/// Create a new UDP socket binded to `addr`
///
/// This will allow binding to `addr` that is not in local host
pub fn bind_nonlocal(ty: RedirType, addr: SocketAddr) -> io::Result<UdpRedirSocket> {
pub fn bind_nonlocal(ty: RedirType, addr: SocketAddr, _redir_opts: &RedirSocketOpts) -> io::Result<UdpRedirSocket> {
UdpRedirSocket::bind(ty, addr, true)
}

Expand All @@ -24,7 +31,7 @@ impl UdpRedirSocket {
}

/// Send data to the socket to the given target address
pub async fn send_to(&mut self, _buf: &[u8], _target: &SocketAddr) -> io::Result<usize> {
pub async fn send_to(&self, _buf: &[u8], _target: SocketAddr) -> io::Result<usize> {
unimplemented!("UDP transparent proxy is not supported on Windows")
}

Expand Down
4 changes: 2 additions & 2 deletions crates/shadowsocks-service/src/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::{io, sync::Arc};

use log::{trace, warn};
use log::trace;
use shadowsocks::net::{AcceptOpts, ConnectOpts};

use crate::{
Expand All @@ -26,7 +26,7 @@ pub async fn run(config: Config) -> io::Result<()> {
if let Some(nofile) = config.nofile {
use crate::sys::set_nofile;
if let Err(err) = set_nofile(nofile) {
warn!("set_nofile {} failed, error: {}", nofile, err);
log::warn!("set_nofile {} failed, error: {}", nofile, err);
}
}

Expand Down

0 comments on commit 1d3e6b7

Please sign in to comment.