diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da5060d7f..72fd75a8f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ env: IMAGE_NAME: "clash-rs" +# Arm builder https://github.blog/changelog/2024-09-03-github-actions-arm64-linux-and-windows-runners-are-now-generally-available/ jobs: compile: name: ${{ matrix.release-name || matrix.target || 'Unknown' }} @@ -114,6 +115,11 @@ jobs: cross: false postfix: ".exe" extra-args: "--all-features" + - os: windows-latest + target: aarch64-pc-windows-msvc + cross: false + postfix: ".exe" + extra-args: --features "shadowsocks tuic" # Windows static-crt - os: windows-latest target: x86_64-pc-windows-msvc @@ -129,6 +135,13 @@ jobs: postfix: ".exe" extra-args: "--all-features" rustflags: "-Ctarget-feature=+crt-static --cfg tokio_unstable" + - os: windows-latest + target: aarch64-pc-windows-msvc + release-name: aarch64-pc-windows-msvc-static-crt + cross: false + postfix: ".exe" + extra-args: --features "shadowsocks tuic" + rustflags: "-Ctarget-feature=+crt-static --cfg tokio_unstable" # MacOSX - os: macos-12 target: x86_64-apple-darwin @@ -195,7 +208,7 @@ jobs: env: RUSTFLAGS: ${{ matrix.rustflags || '--cfg tokio_unstable' }} - - name: Cargo test + - name: Cargo test (docker test on linux) uses: clechasseur/rs-cargo@v2 if: startsWith(matrix.os, 'ubuntu') with: @@ -206,9 +219,9 @@ jobs: CROSS_CONTAINER_OPTS: "--network host" RUSTFLAGS: ${{ matrix.rustflags || '--cfg tokio_unstable' }} - - name: Cargo test (no docker test) + - name: Cargo test (no docker test on windows-non-arm and macos) uses: clechasseur/rs-cargo@v2 - if: ${{ !startsWith(matrix.os, 'ubuntu') }} + if: ${{ !startsWith(matrix.os, 'ubuntu') && matrix.target != 'aarch64-pc-windows-msvc' }} with: use-cross: ${{ matrix.cross }} command: test diff --git a/docker/docker-compose.yml b/clash/tests/data/docker/docker-compose.yml similarity index 100% rename from docker/docker-compose.yml rename to clash/tests/data/docker/docker-compose.yml diff --git a/docker/nginx/nginx.conf b/clash/tests/data/docker/nginx/nginx.conf similarity index 100% rename from docker/nginx/nginx.conf rename to clash/tests/data/docker/nginx/nginx.conf diff --git a/docker/ss/Dockerfile b/clash/tests/data/docker/ss/Dockerfile similarity index 100% rename from docker/ss/Dockerfile rename to clash/tests/data/docker/ss/Dockerfile diff --git a/docker/v2ray/cert.pem b/clash/tests/data/docker/v2ray/cert.pem similarity index 100% rename from docker/v2ray/cert.pem rename to clash/tests/data/docker/v2ray/cert.pem diff --git a/docker/v2ray/config.json b/clash/tests/data/docker/v2ray/config.json similarity index 100% rename from docker/v2ray/config.json rename to clash/tests/data/docker/v2ray/config.json diff --git a/docker/v2ray/key.pem b/clash/tests/data/docker/v2ray/key.pem similarity index 100% rename from docker/v2ray/key.pem rename to clash/tests/data/docker/v2ray/key.pem diff --git a/docker/wg/wg0.conf b/clash/tests/data/docker/wg/wg0.conf similarity index 100% rename from docker/wg/wg0.conf rename to clash/tests/data/docker/wg/wg0.conf diff --git a/clash_lib/Cargo.toml b/clash_lib/Cargo.toml index e8d301ae7..76a303576 100644 --- a/clash_lib/Cargo.toml +++ b/clash_lib/Cargo.toml @@ -10,7 +10,7 @@ shadowsocks = ["dep:shadowsocks"] tuic = ["dep:tuic", "dep:tuic-quinn", "dep:quinn", "dep:register-count"] tracing = [] bench = ["dep:criterion"] -onion = ["arti-client/onion-service-client"] +onion = ["dep:arti-client", "dep:tor-rtcompat", "arti-client/onion-service-client"] [dependencies] # Async @@ -117,8 +117,8 @@ maxminddb = "0.24" public-suffix = "0.1" murmur3 = "0.5" -arti-client = { version = "0.22", default-features = false, features = ["tokio", "rustls", "static-sqlite"] } -tor-rtcompat = { version = "0.22", default-features = false } +arti-client = { version = "0.22", optional = true, default-features = false, features = ["tokio", "rustls", "static-sqlite"] } +tor-rtcompat = { version = "0.22", optional = true, default-features = false } # tuic tuic = { tag = "v1.2.0", optional = true, git = "https://github.com/Itsusinn/tuic.git" } diff --git a/clash_lib/src/app/outbound/manager.rs b/clash_lib/src/app/outbound/manager.rs index 05dffccb0..a979654b8 100644 --- a/clash_lib/src/app/outbound/manager.rs +++ b/clash_lib/src/app/outbound/manager.rs @@ -25,7 +25,7 @@ use crate::{ OutboundProxyProviderDef, PROXY_DIRECT, PROXY_GLOBAL, PROXY_REJECT, }, proxy::{ - fallback, loadbalance, selector, socks, tor, trojan, + fallback, loadbalance, selector, socks, trojan, utils::{DirectConnector, ProxyConnector}, vmess, wg, OutboundType, }, @@ -44,6 +44,8 @@ use super::utils::proxy_groups_dag_sort; #[cfg(feature = "shadowsocks")] use crate::proxy::shadowsocks; +#[cfg(feature = "onion")] +use crate::proxy::tor; #[cfg(feature = "tuic")] use crate::proxy::tuic; @@ -275,6 +277,7 @@ impl OutboundManager { }); } + #[cfg(feature = "onion")] OutboundProxyProtocol::Tor(tor) => { handlers.insert(tor.name.clone(), { let h: tor::Handler = tor.try_into()?; diff --git a/clash_lib/src/app/remote_content_manager/providers/proxy_provider/proxy_set_provider.rs b/clash_lib/src/app/remote_content_manager/providers/proxy_provider/proxy_set_provider.rs index ba9c24bc7..927746e6e 100644 --- a/clash_lib/src/app/remote_content_manager/providers/proxy_provider/proxy_set_provider.rs +++ b/clash_lib/src/app/remote_content_manager/providers/proxy_provider/proxy_set_provider.rs @@ -18,12 +18,14 @@ use crate::{ }, common::errors::map_io_error, config::internal::proxy::OutboundProxyProtocol, - proxy::{direct, reject, socks, tor, trojan, vmess, wg, AnyOutboundHandler}, + proxy::{direct, reject, socks, trojan, vmess, wg, AnyOutboundHandler}, Error, }; #[cfg(feature = "shadowsocks")] use crate::proxy::shadowsocks; +#[cfg(feature = "onion")] +use crate::proxy::tor; #[cfg(feature = "tuic")] use crate::proxy::tuic; @@ -139,6 +141,7 @@ impl ProxySetProvider { let h: wg::Handler = wg.try_into()?; Ok(Arc::new(h) as _) } + #[cfg(feature = "onion")] OutboundProxyProtocol::Tor(tor) => { let h: tor::Handler = tor.try_into()?; Ok(Arc::new(h) as _) diff --git a/clash_lib/src/config/internal/proxy.rs b/clash_lib/src/config/internal/proxy.rs index 9f5a0b705..ea8067650 100644 --- a/clash_lib/src/config/internal/proxy.rs +++ b/clash_lib/src/config/internal/proxy.rs @@ -62,6 +62,7 @@ pub enum OutboundProxyProtocol { Vmess(OutboundVmess), #[serde(rename = "wireguard")] Wireguard(OutboundWireguard), + #[cfg(feature = "onion")] #[serde(rename = "tor")] Tor(OutboundTor), #[cfg(feature = "tuic")] @@ -82,6 +83,7 @@ impl OutboundProxyProtocol { OutboundProxyProtocol::Wireguard(wireguard) => { &wireguard.common_opts.name } + #[cfg(feature = "onion")] OutboundProxyProtocol::Tor(tor) => &tor.name, #[cfg(feature = "tuic")] OutboundProxyProtocol::Tuic(tuic) => &tuic.common_opts.name, @@ -116,6 +118,7 @@ impl Display for OutboundProxyProtocol { OutboundProxyProtocol::Trojan(_) => write!(f, "Trojan"), OutboundProxyProtocol::Vmess(_) => write!(f, "Vmess"), OutboundProxyProtocol::Wireguard(_) => write!(f, "Wireguard"), + #[cfg(feature = "onion")] OutboundProxyProtocol::Tor(_) => write!(f, "Tor"), #[cfg(feature = "tuic")] OutboundProxyProtocol::Tuic(_) => write!(f, "Tuic"), diff --git a/clash_lib/src/proxy/converters/mod.rs b/clash_lib/src/proxy/converters/mod.rs index 25b3ddfb3..45eb25e00 100644 --- a/clash_lib/src/proxy/converters/mod.rs +++ b/clash_lib/src/proxy/converters/mod.rs @@ -1,6 +1,7 @@ #[cfg(feature = "shadowsocks")] pub mod shadowsocks; pub mod socks5; +#[cfg(feature = "onion")] pub mod tor; pub mod trojan; #[cfg(feature = "tuic")] diff --git a/clash_lib/src/proxy/mod.rs b/clash_lib/src/proxy/mod.rs index bcaff489d..f4850f9e2 100644 --- a/clash_lib/src/proxy/mod.rs +++ b/clash_lib/src/proxy/mod.rs @@ -35,6 +35,7 @@ pub mod converters; #[cfg(feature = "shadowsocks")] pub mod shadowsocks; pub mod socks; +#[cfg(feature = "onion")] pub mod tor; pub mod trojan; #[cfg(feature = "tuic")]