diff --git a/crates/shadowsocks-service/src/config.rs b/crates/shadowsocks-service/src/config.rs index 880d4804ab2b..0bc026cf9716 100644 --- a/crates/shadowsocks-service/src/config.rs +++ b/crates/shadowsocks-service/src/config.rs @@ -68,7 +68,14 @@ use serde::{Deserialize, Serialize}; use shadowsocks::relay::socks5::Address; use shadowsocks::{ config::{ - ManagerAddr, Mode, ReplayAttackPolicy, ServerAddr, ServerConfig, ServerUser, ServerUserManager, ServerWeight, + ManagerAddr, + Mode, + ReplayAttackPolicy, + ServerAddr, + ServerConfig, + ServerUser, + ServerUserManager, + ServerWeight, }, crypto::CipherKind, plugin::PluginConfig, diff --git a/crates/shadowsocks-service/src/local/mod.rs b/crates/shadowsocks-service/src/local/mod.rs index 35ebe81f97d0..e098e471dfa2 100644 --- a/crates/shadowsocks-service/src/local/mod.rs +++ b/crates/shadowsocks-service/src/local/mod.rs @@ -371,9 +371,6 @@ impl Server { } #[cfg(feature = "local-tun")] ProtocolType::Tun => { - use log::info; - use shadowsocks::net::UnixListener; - let mut builder = TunBuilder::new(context.clone(), balancer); if let Some(address) = local_config.tun_interface_address { builder.address(address); @@ -397,6 +394,9 @@ impl Server { } else if let Some(ref fd_path) = local_config.tun_device_fd_from_path { use std::fs; + use log::info; + use shadowsocks::net::UnixListener; + let _ = fs::remove_file(fd_path); let listener = match UnixListener::bind(fd_path) { diff --git a/crates/shadowsocks-service/src/local/tun/sys/windows/mod.rs b/crates/shadowsocks-service/src/local/tun/sys/windows/mod.rs index 8b137891791f..9b50862005ab 100644 --- a/crates/shadowsocks-service/src/local/tun/sys/windows/mod.rs +++ b/crates/shadowsocks-service/src/local/tun/sys/windows/mod.rs @@ -1 +1,21 @@ +use std::{io, marker::Unpin}; +use tokio::io::{AsyncWrite, AsyncWriteExt}; +use tun::platform::Device as TunDevice; + +/// Packet Information length in bytes +/// +/// Tun device on Windows (https://wintun.net) doesn't have Packet Information header, so there is no prefix headers +pub const IFF_PI_PREFIX_LEN: usize = 0; + +/// Writing packet with packet information +/// +/// Tun device on Windows (https://wintun.net) doesn't have Packet Information header, so there is nothing to prepend on Windows +pub async fn write_packet_with_pi(writer: &mut W, packet: &[u8]) -> io::Result<()> { + writer.write_all(packet).await +} + +/// Set platform specific route configuration +pub async fn set_route_configuration(_device: &TunDevice) -> io::Result<()> { + Ok(()) +} diff --git a/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs b/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs index 7af315442bf3..9db908e0ee8f 100644 --- a/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs +++ b/crates/shadowsocks/src/dns_resolver/hickory_dns_resolver.rs @@ -20,7 +20,8 @@ use hickory_resolver::{ udp::{DnsUdpSocket, QuicLocalAddr}, TokioTime, }, - AsyncResolver, TokioHandle, + AsyncResolver, + TokioHandle, }; use log::trace; use tokio::{io::ReadBuf, net::UdpSocket};