{"record":{"id":"c60606c9dac9bdc6","repo":"shadowsocks/shadowsocks-rust","slug":"not-supported-tcp-transparent-proxy-on-windows","errorCode":null,"errorMessage":"not supported tcp transparent proxy on Windows","messagePattern":"not supported tcp transparent proxy on Windows","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/shadowsocks-service/src/local/redir/tcprelay/sys/windows/mod.rs","lineNumber":16,"sourceCode":"use std::{\n    io::{self, Error, ErrorKind},\n    net::SocketAddr,\n};\n\nuse shadowsocks::net::AcceptOpts;\nuse tokio::net::{TcpListener, TcpStream};\n\nuse crate::{\n    config::RedirType,\n    local::redir::redir_ext::{TcpListenerRedirExt, TcpStreamRedirExt},\n};\n\nimpl TcpListenerRedirExt for TcpListener {\n    async fn bind_redir(_ty: RedirType, _addr: SocketAddr, _accept_opts: AcceptOpts) -> io::Result<TcpListener> {\n        let err = Error::new(\n            ErrorKind::InvalidInput,\n            \"not supported tcp transparent proxy on Windows\",\n        );\n        Err(err)\n    }\n}\n\nimpl TcpStreamRedirExt for TcpStream {\n    fn destination_addr(&self, _ty: RedirType) -> io::Result<SocketAddr> {\n        unreachable!(\"not supported tcp transparent on Windows\")\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/crates/shadowsocks-service/src/local/redir/tcprelay/sys/windows/mod.rs#L1-L29","documentation":"The Windows implementation of TcpListenerRedirExt::bind_redir is a stub that unconditionally returns InvalidInput: Windows has no transparent-proxy (redirect/tproxy/pf) support in this library, so any attempt to bind a TCP redir listener on Windows fails.","triggerScenarios":"Starting a shadowsocks local server on Windows with a redir (`type: redir`) inbound listener configured; bind_redir is called and immediately errors regardless of the RedirType passed.","commonSituations":"Reusing a Linux/macOS redir config on Windows, or scripts that launch the same local config on all developer machines.","solutions":["Remove the redir listener from the Windows config; use socks/http/tun inbound types instead.","Use WSL2 with a Linux build if transparent proxying is required.","Gate the config on OS (separate config files per platform).","For whole-system proxying on Windows consider TUN mode or a system-level TUN driver."],"exampleFix":"// before (config.json on Windows)\n\"locals\": [{ \"type\": \"redir\", \"local_address\": \"127.0.0.1:1081\" }]\n// after\n\"locals\": [{ \"type\": \"socks\", \"local_address\": \"127.0.0.1:1081\" }]","handlingStrategy":"validation","validationCode":"if cfg!(windows) {\n    eprintln!(\"transparent proxy (redir) is not supported on Windows; use socks/http/tun\");\n    std::process::exit(2);\n}","typeGuard":"fn redir_supported() -> bool { !cfg!(windows) }","tryCatchPattern":"if let Err(e) = bind_redir(ty, addr, accept_opts).await {\n    if cfg!(windows) {\n        // fall back to a SOCKS listener on Windows\n        return bind_socks(addr, accept_opts).await;\n    }\n    return Err(e);\n}","preventionTips":["Never ship redir inbounds in configs used on Windows","Use OS-conditional config loading","On Windows use SOCKS/HTTP inbound or TUN mode for system-wide proxying"],"tags":["windows","transparent-proxy","unsupported-platform","configuration"],"backgroundTag":"unsupported-platform","analyzedSha":"8eb0f0a65b1d976ab6bed5787327ef86529b0435","analyzedAt":"2026-09-09T12:20:43.168Z","contentChangedAt":"2026-09-09T12:20:43.168Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}